From 1cf0d3d6a566d969d3a7f8e9c11fa73c041037c7 Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Thu, 2 Oct 2025 22:23:27 +0200 Subject: [PATCH] Fix D-section calculation logic Fixed: - Only sections B and C VAT amounts are summed for totals - Section A lines (A1-A5) are excluded from totals calculation - Only VAT amounts (not base amounts) are included in totals - This should fix line 25 showing correct value (406.28) --- core/class/declarationtva.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/class/declarationtva.class.php b/core/class/declarationtva.class.php index 661d93d..d55c7a9 100644 --- a/core/class/declarationtva.class.php +++ b/core/class/declarationtva.class.php @@ -268,10 +268,12 @@ class DeclarationTVA // Log the final amounts for debugging error_log("DeclarationTVA: Final amounts for line $ca3_line: base=$line_total_base, vat=$line_total_vat, total=$line_total_amount"); - // Update totals - if (in_array($ca3_line, ['A1', 'A2', 'A3', 'A4', 'A5', '08', '09', '9B', '17'])) { + // Update totals - only VAT amounts from sections B and C + if (in_array($ca3_line, ['08', '09', '9B', '17'])) { + // Section B: VAT amounts only $total_vat_collected += $line_total_vat; } elseif (in_array($ca3_line, ['20', '21', '22'])) { + // Section C: VAT amounts only $total_vat_deductible += $line_total_vat; } }