Fix small difference handling for proper rounding
- Added special handling for differences < 1.0 (like -0.90) - Small differences now create rounding-only entries (758000/658000) - No main balancing entry (4455100/4456700) for small differences - Should show 758000 with 0.90 instead of 4455100 with 1.00
This commit is contained in:
parent
23aa6cccb8
commit
c00894db2d
@ -2080,7 +2080,31 @@ class DeclarationTVA_PDF
|
|||||||
// Calculate rounded difference for main entry
|
// Calculate rounded difference for main entry
|
||||||
$rounded_difference = round($difference);
|
$rounded_difference = round($difference);
|
||||||
|
|
||||||
if ($rounded_difference != 0) {
|
// For very small differences, don't create main balancing entry
|
||||||
|
if (abs($difference) < 1.0) {
|
||||||
|
error_log("DeclarationTVA: Small difference detected: " . $difference . ", creating rounding-only entry");
|
||||||
|
if (abs($difference) >= 0.01) {
|
||||||
|
if ($difference > 0) {
|
||||||
|
// Credit difference - rounding goes to 658000 debit
|
||||||
|
$balancing_entries[] = array(
|
||||||
|
'account_code' => '658000',
|
||||||
|
'account_label' => $this->getAccountLabel('658000'),
|
||||||
|
'entry_label' => $declaration->declaration_name,
|
||||||
|
'debit' => $this->formatAmountReal($difference),
|
||||||
|
'credit' => ''
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Debit difference - rounding goes to 758000 credit
|
||||||
|
$balancing_entries[] = array(
|
||||||
|
'account_code' => '758000',
|
||||||
|
'account_label' => $this->getAccountLabel('758000'),
|
||||||
|
'entry_label' => $declaration->declaration_name,
|
||||||
|
'debit' => '',
|
||||||
|
'credit' => $this->formatAmountReal(abs($difference))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($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)
|
// More credits than debits - need debit entry (4456700)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user