Fix reversed account selection logic

- Debit difference: now uses 4455100 credit (not 4456700)
- Credit difference: now uses 4456700 debit (not 4455100)
- Rounding accounts also corrected: 758000 for debit diff, 658000 for credit diff
- Should now match user examples correctly
This commit is contained in:
Frank Cools 2025-10-07 14:43:21 +02:00
parent 43e4072a67
commit 6f742bda84

View File

@ -2082,22 +2082,22 @@ class DeclarationTVA_PDF
if ($rounded_difference != 0) { if ($rounded_difference != 0) {
// Main balancing entry with rounded amount // Main balancing entry with rounded amount
if ($difference > 0) { if ($difference > 0) {
// More credits than debits - need debit entry (4456700)
$balancing_entries[] = array(
'account_code' => '4456700',
'account_label' => $this->getAccountLabel('4456700'),
'entry_label' => $declaration->declaration_name,
'debit' => $this->formatAmount($rounded_difference),
'credit' => ''
);
} else {
// More debits than credits - need credit entry (4455100) // More debits than credits - need credit entry (4455100)
$balancing_entries[] = array( $balancing_entries[] = array(
'account_code' => '4455100', 'account_code' => '4455100',
'account_label' => $this->getAccountLabel('4455100'), 'account_label' => $this->getAccountLabel('4455100'),
'entry_label' => $declaration->declaration_name, 'entry_label' => $declaration->declaration_name,
'debit' => '', 'debit' => '',
'credit' => $this->formatAmount($rounded_difference) 'credit' => $this->formatAmount(abs($rounded_difference))
);
} else {
// More credits than debits - need debit entry (4456700)
$balancing_entries[] = array(
'account_code' => '4456700',
'account_label' => $this->getAccountLabel('4456700'),
'entry_label' => $declaration->declaration_name,
'debit' => $this->formatAmount(abs($rounded_difference)),
'credit' => ''
); );
} }
@ -2106,7 +2106,7 @@ class DeclarationTVA_PDF
error_log("DeclarationTVA: Rounding difference: " . $rounding_diff); error_log("DeclarationTVA: Rounding difference: " . $rounding_diff);
if (abs($rounding_diff) >= 0.01) { if (abs($rounding_diff) >= 0.01) {
if ($difference < 0) { if ($difference > 0) {
// Credit difference - rounding goes to 658000 debit // Credit difference - rounding goes to 658000 debit
$balancing_entries[] = array( $balancing_entries[] = array(
'account_code' => '658000', 'account_code' => '658000',