From e78e6061a8a52faeabee4735470beb48f34fbe48 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Thu, 2 Oct 2025 23:29:57 +0200 Subject: [PATCH] Split totals for BASE and VAT accounts in CA-3 line details Fixed: - Separated totals for BASE accounts vs VAT accounts - Added subtotal rows for each account type - Clear visual separation between base and VAT contributions - Added 'Grand Total' row showing combined totals - Added translations for subtotal labels This eliminates confusion by showing: - Subtotal for BASE accounts (sales amounts) - Subtotal for VAT accounts (VAT amounts) - Grand Total (combined total) Users can now clearly see which accounts contribute to base vs VAT amounts. --- declarationtva_line_details_ajax.php | 62 ++++++++++++++++++++-------- langs/en_US/declarationtva.lang | 3 ++ langs/fr_FR/declarationtva.lang | 3 ++ 3 files changed, 51 insertions(+), 17 deletions(-) diff --git a/declarationtva_line_details_ajax.php b/declarationtva_line_details_ajax.php index a4e7e80..253ebaa 100644 --- a/declarationtva_line_details_ajax.php +++ b/declarationtva_line_details_ajax.php @@ -89,9 +89,15 @@ echo '' . $langs->trans("TotalAmount") . ''; echo '' . $langs->trans("MappingType") . ''; echo ''; -$total_base = 0; -$total_vat = 0; -$total_amount = 0; +$total_base_base = 0; +$total_vat_base = 0; +$total_amount_base = 0; +$total_base_vat = 0; +$total_vat_vat = 0; +$total_amount_vat = 0; +$total_base_other = 0; +$total_vat_other = 0; +$total_amount_other = 0; // Display BASE accounts first (if any) if (!empty($base_accounts)) { @@ -100,9 +106,9 @@ if (!empty($base_accounts)) { echo ''; foreach ($base_accounts as $account) { - $total_base += $account['base_amount']; - $total_vat += $account['vat_amount']; - $total_amount += $account['total_amount']; + $total_base_base += $account['base_amount']; + $total_vat_base += $account['vat_amount']; + $total_amount_base += $account['total_amount']; echo ''; echo '' . $account['account_code'] . ''; @@ -113,6 +119,15 @@ if (!empty($base_accounts)) { echo '' . $account['mapping_type'] . ''; echo ''; } + + // Subtotal for BASE accounts + echo ''; + echo '' . $langs->trans("SubtotalBaseAccounts") . ''; + echo '' . price($total_base_base) . ''; + echo '' . price($total_vat_base) . ''; + echo '' . price($total_amount_base) . ''; + echo ''; + echo ''; } // Display VAT accounts second (if any) @@ -122,9 +137,9 @@ if (!empty($vat_accounts)) { echo ''; foreach ($vat_accounts as $account) { - $total_base += $account['base_amount']; - $total_vat += $account['vat_amount']; - $total_amount += $account['total_amount']; + $total_base_vat += $account['base_amount']; + $total_vat_vat += $account['vat_amount']; + $total_amount_vat += $account['total_amount']; echo ''; echo '' . $account['account_code'] . ''; @@ -135,13 +150,22 @@ if (!empty($vat_accounts)) { echo '' . $account['mapping_type'] . ''; echo ''; } + + // Subtotal for VAT accounts + echo ''; + echo '' . $langs->trans("SubtotalVATAccounts") . ''; + echo '' . price($total_base_vat) . ''; + echo '' . price($total_vat_vat) . ''; + echo '' . price($total_amount_vat) . ''; + echo ''; + echo ''; } // Display other accounts (normal lines) foreach ($other_accounts as $account) { - $total_base += $account['base_amount']; - $total_vat += $account['vat_amount']; - $total_amount += $account['total_amount']; + $total_base_other += $account['base_amount']; + $total_vat_other += $account['vat_amount']; + $total_amount_other += $account['total_amount']; echo ''; echo '' . $account['account_code'] . ''; @@ -153,12 +177,16 @@ foreach ($other_accounts as $account) { echo ''; } -// Totals row +// Final totals row +$final_total_base = $total_base_base + $total_base_vat + $total_base_other; +$final_total_vat = $total_vat_base + $total_vat_vat + $total_vat_other; +$final_total_amount = $total_amount_base + $total_amount_vat + $total_amount_other; + echo ''; -echo '' . $langs->trans("Total") . ''; -echo '' . price($total_base) . ''; -echo '' . price($total_vat) . ''; -echo '' . price($total_amount) . ''; +echo '' . $langs->trans("GrandTotal") . ''; +echo '' . price($final_total_base) . ''; +echo '' . price($final_total_vat) . ''; +echo '' . price($final_total_amount) . ''; echo ''; echo ''; diff --git a/langs/en_US/declarationtva.lang b/langs/en_US/declarationtva.lang index 9942439..6cec5eb 100644 --- a/langs/en_US/declarationtva.lang +++ b/langs/en_US/declarationtva.lang @@ -463,3 +463,6 @@ ErrorLoadingDetails = Error loading details Summary = Summary BaseAccounts = Base Accounts (Sales) VATAccounts = VAT Accounts +SubtotalBaseAccounts = Subtotal Base Accounts +SubtotalVATAccounts = Subtotal VAT Accounts +GrandTotal = Grand Total diff --git a/langs/fr_FR/declarationtva.lang b/langs/fr_FR/declarationtva.lang index 4f369d6..e451294 100644 --- a/langs/fr_FR/declarationtva.lang +++ b/langs/fr_FR/declarationtva.lang @@ -452,3 +452,6 @@ ErrorLoadingDetails = Erreur lors du chargement des détails Summary = Résumé BaseAccounts = Comptes de base (ventes) VATAccounts = Comptes de TVA +SubtotalBaseAccounts = Sous-total comptes de base +SubtotalVATAccounts = Sous-total comptes de TVA +GrandTotal = Total général