Fix balancing logic to create only one main entry
- Removed duplicate 4455100 entry creation - Now creates either 4455100 (credit) OR 4456700 (debit), not both - Added debug logging for total debits/credits to trace calculation - Should eliminate the unwanted 4455100 line in journal table
This commit is contained in:
parent
240360a393
commit
34b9864a4e
@ -2072,6 +2072,8 @@ class DeclarationTVA_PDF
|
|||||||
$balancing_entries = array();
|
$balancing_entries = array();
|
||||||
|
|
||||||
// Debug logging
|
// Debug logging
|
||||||
|
error_log("DeclarationTVA: Total debits: " . $total_debits);
|
||||||
|
error_log("DeclarationTVA: Total credits: " . $total_credits);
|
||||||
error_log("DeclarationTVA: Total difference: " . $difference);
|
error_log("DeclarationTVA: Total difference: " . $difference);
|
||||||
|
|
||||||
// Calculate rounded difference for main entry
|
// Calculate rounded difference for main entry
|
||||||
@ -2079,16 +2081,7 @@ 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(abs($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',
|
||||||
@ -2097,6 +2090,15 @@ class DeclarationTVA_PDF
|
|||||||
'debit' => '',
|
'debit' => '',
|
||||||
'credit' => $this->formatAmount($rounded_difference)
|
'credit' => $this->formatAmount($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' => ''
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Rounding entry for the difference between real and rounded
|
// Rounding entry for the difference between real and rounded
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user