Update 1.html

This commit is contained in:
jagrit007 2025-10-11 19:58:38 +00:00
parent 16730f1520
commit bec4fec2b7

22
1.html
View File

@ -324,6 +324,28 @@
}
}
}
// Fix subtotal calculation when tax is present
let subtotalRow = document.querySelector('.total-row.subtotal span:last-child');
let taxRow = document.querySelector('.total-row:not(.subtotal):not(.grand-total) span:last-child');
let totalRow = document.querySelector('.total-row.grand-total span:last-child');
if (subtotalRow && taxRow && totalRow) {
// Extract numeric values
let subtotalText = subtotalRow.textContent.trim().replace(/[^\d.]/g, '');
let taxText = taxRow.textContent.trim().replace(/[^\d.]/g, '');
let totalText = totalRow.textContent.trim().split(' ')[0].replace(/[^\d.]/g, '');
let subtotalNum = parseFloat(subtotalText);
let taxNum = parseFloat(taxText);
let totalNum = parseFloat(totalText);
// If subtotal equals total, calculate actual subtotal (total - tax)
if (Math.abs(subtotalNum - totalNum) < 0.01 && taxNum > 0) {
let actualSubtotal = totalNum - taxNum;
subtotalRow.textContent = formatIndianNumber(actualSubtotal.toFixed(2));
}
}
});
</script>
</head>