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.
This commit is contained in:
Frank Cools 2025-10-02 23:29:57 +02:00
parent 84017f33ce
commit e78e6061a8
3 changed files with 51 additions and 17 deletions

View File

@ -89,9 +89,15 @@ echo '<th class="right">' . $langs->trans("TotalAmount") . '</th>';
echo '<th>' . $langs->trans("MappingType") . '</th>';
echo '</tr>';
$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 '</tr>';
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 '<tr class="oddeven">';
echo '<td><strong>' . $account['account_code'] . '</strong></td>';
@ -113,6 +119,15 @@ if (!empty($base_accounts)) {
echo '<td>' . $account['mapping_type'] . '</td>';
echo '</tr>';
}
// Subtotal for BASE accounts
echo '<tr class="liste_titre">';
echo '<td colspan="2"><strong>' . $langs->trans("SubtotalBaseAccounts") . '</strong></td>';
echo '<td class="right"><strong>' . price($total_base_base) . '</strong></td>';
echo '<td class="right"><strong>' . price($total_vat_base) . '</strong></td>';
echo '<td class="right"><strong>' . price($total_amount_base) . '</strong></td>';
echo '<td></td>';
echo '</tr>';
}
// Display VAT accounts second (if any)
@ -122,9 +137,9 @@ if (!empty($vat_accounts)) {
echo '</tr>';
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 '<tr class="oddeven">';
echo '<td><strong>' . $account['account_code'] . '</strong></td>';
@ -135,13 +150,22 @@ if (!empty($vat_accounts)) {
echo '<td>' . $account['mapping_type'] . '</td>';
echo '</tr>';
}
// Subtotal for VAT accounts
echo '<tr class="liste_titre">';
echo '<td colspan="2"><strong>' . $langs->trans("SubtotalVATAccounts") . '</strong></td>';
echo '<td class="right"><strong>' . price($total_base_vat) . '</strong></td>';
echo '<td class="right"><strong>' . price($total_vat_vat) . '</strong></td>';
echo '<td class="right"><strong>' . price($total_amount_vat) . '</strong></td>';
echo '<td></td>';
echo '</tr>';
}
// 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 '<tr class="oddeven">';
echo '<td><strong>' . $account['account_code'] . '</strong></td>';
@ -153,12 +177,16 @@ foreach ($other_accounts as $account) {
echo '</tr>';
}
// 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 '<tr class="liste_titre">';
echo '<td colspan="2"><strong>' . $langs->trans("Total") . '</strong></td>';
echo '<td class="right"><strong>' . price($total_base) . '</strong></td>';
echo '<td class="right"><strong>' . price($total_vat) . '</strong></td>';
echo '<td class="right"><strong>' . price($total_amount) . '</strong></td>';
echo '<td colspan="2"><strong>' . $langs->trans("GrandTotal") . '</strong></td>';
echo '<td class="right"><strong>' . price($final_total_base) . '</strong></td>';
echo '<td class="right"><strong>' . price($final_total_vat) . '</strong></td>';
echo '<td class="right"><strong>' . price($final_total_amount) . '</strong></td>';
echo '<td></td>';
echo '</tr>';

View File

@ -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

View File

@ -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