diff --git a/agent/reports/tax_summary.php b/agent/reports/tax_summary.php index 159566a4..19ef76df 100644 --- a/agent/reports/tax_summary.php +++ b/agent/reports/tax_summary.php @@ -70,47 +70,78 @@ $sql_tax = mysqli_query($mysqli, "SELECT `tax_name` FROM `taxes`"); "; - echo "" . $row['tax_name'] . ""; + echo "" . nullable_htmlentities($tax_name_raw) . ""; if ($view == 'monthly') { + for ($i = 1; $i <= 12; $i++) { - $monthly_tax = getMonthlyTax($tax_name, $i, $year, $mysqli); + $monthly_tax = (float) getMonthlyTax($tax_name, $i, $year, $mysqli); + + // Accumulate totals + $monthly_totals[$i] += $monthly_tax; + $grand_total += $monthly_tax; + echo "" . numfmt_format_currency($currency_format, $monthly_tax, $company_currency) . ""; } + + // Row total = sum of this tax’s 12 months + $row_total = 0.0; + for ($i = 1; $i <= 12; $i++) { + $row_total += (float) getMonthlyTax($tax_name, $i, $year, $mysqli); + } + echo "" . numfmt_format_currency($currency_format, $row_total, $company_currency) . ""; + } else { + + $row_total = 0.0; for ($q = 1; $q <= 4; $q++) { - $quarterly_tax = getQuarterlyTax($tax_name, $q, $year, $mysqli); + $quarterly_tax = (float) getQuarterlyTax($tax_name, $q, $year, $mysqli); + + // Accumulate totals + $quarterly_totals[$q] += $quarterly_tax; + $grand_total += $quarterly_tax; + + $row_total += $quarterly_tax; + echo "" . numfmt_format_currency($currency_format, $quarterly_tax, $company_currency) . ""; } + + echo "" . numfmt_format_currency($currency_format, $row_total, $company_currency) . ""; } - // Calculate total for row and echo bold - $total_tax = getTotalTax($tax_name, $year, $mysqli); - echo "" . numfmt_format_currency($currency_format, $total_tax, $company_currency) . ""; echo ""; } - ?> - - Total - " . numfmt_format_currency($currency_format, $monthly_tax, $company_currency) . ""; - } - } else { - for ($q = 1; $q <= 4; $q++) { - $quarterly_tax = getQuarterlyTax($tax_name, $q, $year, $mysqli); - echo "" . numfmt_format_currency($currency_format, $quarterly_tax, $company_currency) . ""; - } - } - ?> - - + // Totals row + echo ""; + echo "Total"; + + if ($view == 'monthly') { + for ($i = 1; $i <= 12; $i++) { + echo "" . numfmt_format_currency($currency_format, $monthly_totals[$i], $company_currency) . ""; + } + } else { + for ($q = 1; $q <= 4; $q++) { + echo "" . numfmt_format_currency($currency_format, $quarterly_totals[$q], $company_currency) . ""; + } + } + + echo "" . numfmt_format_currency($currency_format, $grand_total, $company_currency) . ""; + echo ""; + + ?>