Fix balancing entry account codes for proper VAT accounting

- If difference < 0 (more credits): Use 4456700 (TVA à payer) on debit side
- If difference > 0 (more debits): Use 4455100 (TVA à recevoir) on credit side
- Each account gets its real label from chart of accounts
- Proper French VAT accounting logic for balancing entries
This commit is contained in:
Frank Cools 2025-10-07 12:03:31 +02:00
parent 009ad50d65
commit ea624ba3cb

View File

@ -2073,23 +2073,24 @@ class DeclarationTVA_PDF
return null; return null;
} }
// Get real account description for 4456700
$account_label = $this->getAccountLabel('4456700');
$entry = array(
'account_code' => '4456700',
'account_label' => $account_label,
'entry_label' => $declaration->declaration_name,
'debit' => '',
'credit' => ''
);
if ($difference < 0) { if ($difference < 0) {
// More credits than debits, add debit to balance // More credits than debits, add debit to balance (TVA à payer)
$entry['debit'] = $this->formatAmount(round(abs($difference))); $entry = array(
'account_code' => '4456700',
'account_label' => $this->getAccountLabel('4456700'),
'entry_label' => $declaration->declaration_name,
'debit' => $this->formatAmount(round(abs($difference))),
'credit' => ''
);
} else { } else {
// More debits than credits, add credit to balance // More debits than credits, add credit to balance (TVA à recevoir)
$entry['credit'] = $this->formatAmount(round($difference)); $entry = array(
'account_code' => '4455100',
'account_label' => $this->getAccountLabel('4455100'),
'entry_label' => $declaration->declaration_name,
'debit' => '',
'credit' => $this->formatAmount(round($difference))
);
} }
return $entry; return $entry;