From 7b633b99c596d48a16be29b42335cbe89de8cbfe Mon Sep 17 00:00:00 2001 From: Frank Cools Date: Tue, 7 Oct 2025 14:46:02 +0200 Subject: [PATCH] Add debugging to trace account selection logic - Added debug logging to show which account is being created - Added logging for difference calculation and condition evaluation - Should help identify why example 1 shows 4456700 instead of 4455100 - Will help trace the source of duplicate 4455100 entries --- core/class/declarationtva_pdf.class.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/class/declarationtva_pdf.class.php b/core/class/declarationtva_pdf.class.php index 786b461..8c5a557 100644 --- a/core/class/declarationtva_pdf.class.php +++ b/core/class/declarationtva_pdf.class.php @@ -2075,6 +2075,7 @@ class DeclarationTVA_PDF error_log("DeclarationTVA: Total debits: " . $total_debits); error_log("DeclarationTVA: Total credits: " . $total_credits); error_log("DeclarationTVA: Total difference: " . $difference); + error_log("DeclarationTVA: Difference > 0: " . ($difference > 0 ? 'true' : 'false')); // Calculate rounded difference for main entry $rounded_difference = round($difference); @@ -2083,6 +2084,7 @@ class DeclarationTVA_PDF // Main balancing entry with rounded amount if ($difference > 0) { // More credits than debits - need debit entry (4456700) + error_log("DeclarationTVA: Creating 4456700 debit entry for " . $rounded_difference); $balancing_entries[] = array( 'account_code' => '4456700', 'account_label' => $this->getAccountLabel('4456700'), @@ -2092,6 +2094,7 @@ class DeclarationTVA_PDF ); } else { // More debits than credits - need credit entry (4455100) + error_log("DeclarationTVA: Creating 4455100 credit entry for " . abs($rounded_difference)); $balancing_entries[] = array( 'account_code' => '4455100', 'account_label' => $this->getAccountLabel('4455100'),