Fix rounding logic for small differences
- Added handling for cases where rounded difference is 0 but real difference is not 0 - Now creates rounding-only entry when difference is small (like -0.90) - Should show 758000 with 0.90 instead of 1.00 - Handles edge cases where difference rounds to 0 but real value is significant
This commit is contained in:
parent
7b633b99c5
commit
23aa6cccb8
@ -2129,6 +2129,30 @@ class DeclarationTVA_PDF
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If rounded difference is 0, but real difference is not 0, create rounding entry only
|
||||
if (abs($difference) >= 0.01) {
|
||||
error_log("DeclarationTVA: Creating rounding-only entry for " . $difference);
|
||||
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))
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $balancing_entries;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user