Fix Tax Summary double counting tax on partially paid invoices

This commit is contained in:
johnnyq
2026-09-03 13:12:31 -04:00
parent feae4719da
commit a0fe18fff1
2 changed files with 26 additions and 15 deletions

View File

@@ -86,21 +86,19 @@ $sql_tax = mysqli_query($mysqli, "SELECT `tax_name` FROM `taxes`");
if ($view == 'monthly') {
// Row total = sum of this taxs 12 months, accumulated as we go
$row_total = 0.0;
for ($i = 1; $i <= 12; $i++) {
$monthly_tax = (float) getMonthlyTax($tax_name, $i, $year, $mysqli);
// Accumulate totals
$monthly_totals[$i] += $monthly_tax;
$grand_total += $monthly_tax;
$row_total += $monthly_tax;
echo "<td class='text-end'>" . numfmt_format_currency($currency_format, $monthly_tax, $company_currency) . "</td>";
}
// Row total = sum of this taxs 12 months
$row_total = 0.0;
for ($i = 1; $i <= 12; $i++) {
$row_total += (float) getMonthlyTax($tax_name, $i, $year, $mysqli);
}
echo "<td class='text-end text-bold'>" . numfmt_format_currency($currency_format, $row_total, $company_currency) . "</td>";
} else {