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
This commit is contained in:
Frank Cools 2025-10-07 14:46:02 +02:00
parent 6f742bda84
commit 7b633b99c5

View File

@ -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'),