Fix split rounding correctly
- Main amount: rounded value on 4455100/4456700 (formatAmount) - Rounding difference: real difference on 758000/658000 (formatAmountReal) - For difference 69.90: 4455100 credit 70.00 + 758000 credit 0.90 - For difference -0.90: 4456700 debit 1.00 + 658000 debit 0.90 - Should now show correct split between main and rounding accounts
This commit is contained in:
parent
95f88537eb
commit
0aa02d8318
@ -2077,9 +2077,14 @@ class DeclarationTVA_PDF
|
||||
error_log("DeclarationTVA: Total difference: " . $difference);
|
||||
error_log("DeclarationTVA: Difference > 0: " . ($difference > 0 ? 'true' : 'false'));
|
||||
|
||||
// Use real difference, NO rounding
|
||||
// Split into main amount (rounded) and rounding difference
|
||||
if (abs($difference) >= 0.01) {
|
||||
error_log("DeclarationTVA: Creating entry for real difference: " . $difference);
|
||||
$rounded_amount = round($difference);
|
||||
$rounding_diff = $difference - $rounded_amount;
|
||||
|
||||
error_log("DeclarationTVA: Difference: " . $difference . ", Rounded: " . $rounded_amount . ", Rounding diff: " . $rounding_diff);
|
||||
|
||||
// Main entry with rounded amount
|
||||
if ($difference > 0) {
|
||||
// More debits than credits - need credit entry (4455100)
|
||||
$balancing_entries[] = array(
|
||||
@ -2087,7 +2092,7 @@ class DeclarationTVA_PDF
|
||||
'account_label' => $this->getAccountLabel('4455100'),
|
||||
'entry_label' => $declaration->declaration_name,
|
||||
'debit' => '',
|
||||
'credit' => $this->formatAmountReal($difference)
|
||||
'credit' => $this->formatAmount($rounded_amount)
|
||||
);
|
||||
} else {
|
||||
// More credits than debits - need debit entry (4456700)
|
||||
@ -2095,10 +2100,33 @@ class DeclarationTVA_PDF
|
||||
'account_code' => '4456700',
|
||||
'account_label' => $this->getAccountLabel('4456700'),
|
||||
'entry_label' => $declaration->declaration_name,
|
||||
'debit' => $this->formatAmountReal(abs($difference)),
|
||||
'debit' => $this->formatAmount(abs($rounded_amount)),
|
||||
'credit' => ''
|
||||
);
|
||||
}
|
||||
|
||||
// Rounding entry with real difference
|
||||
if (abs($rounding_diff) >= 0.01) {
|
||||
if ($difference > 0) {
|
||||
// Debit difference - rounding on 758000 credit
|
||||
$balancing_entries[] = array(
|
||||
'account_code' => '758000',
|
||||
'account_label' => $this->getAccountLabel('758000'),
|
||||
'entry_label' => $declaration->declaration_name,
|
||||
'debit' => '',
|
||||
'credit' => $this->formatAmountReal(abs($rounding_diff))
|
||||
);
|
||||
} else {
|
||||
// Credit difference - rounding on 658000 debit
|
||||
$balancing_entries[] = array(
|
||||
'account_code' => '658000',
|
||||
'account_label' => $this->getAccountLabel('658000'),
|
||||
'entry_label' => $declaration->declaration_name,
|
||||
'debit' => $this->formatAmountReal(abs($rounding_diff)),
|
||||
'credit' => ''
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $balancing_entries;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user