Update 1.html
This commit is contained in:
parent
16730f1520
commit
bec4fec2b7
22
1.html
22
1.html
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user