Remove ALL rounding completely
- NO round() function anywhere - Uses real difference values only (formatAmountReal) - Single entry with real difference on correct account - For difference 69.90: 4455100 credit 69.90 (real value) - No more rounding, no more split entries
This commit is contained in:
parent
da6bb79204
commit
95f88537eb
@ -2077,55 +2077,27 @@ class DeclarationTVA_PDF
|
|||||||
error_log("DeclarationTVA: Total difference: " . $difference);
|
error_log("DeclarationTVA: Total difference: " . $difference);
|
||||||
error_log("DeclarationTVA: Difference > 0: " . ($difference > 0 ? 'true' : 'false'));
|
error_log("DeclarationTVA: Difference > 0: " . ($difference > 0 ? 'true' : 'false'));
|
||||||
|
|
||||||
// Create exactly 2 lines: main amount + rounding difference
|
// Use real difference, NO rounding
|
||||||
if (abs($difference) >= 0.01) {
|
if (abs($difference) >= 0.01) {
|
||||||
$rounded_amount = round($difference);
|
error_log("DeclarationTVA: Creating entry for real difference: " . $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) {
|
if ($difference > 0) {
|
||||||
// Credit difference - main entry on 4456700 debit
|
// More debits than credits - need credit entry (4455100)
|
||||||
$balancing_entries[] = array(
|
|
||||||
'account_code' => '4456700',
|
|
||||||
'account_label' => $this->getAccountLabel('4456700'),
|
|
||||||
'entry_label' => $declaration->declaration_name,
|
|
||||||
'debit' => $this->formatAmount($rounded_amount),
|
|
||||||
'credit' => ''
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// Debit difference - main entry on 4455100 credit
|
|
||||||
$balancing_entries[] = array(
|
$balancing_entries[] = array(
|
||||||
'account_code' => '4455100',
|
'account_code' => '4455100',
|
||||||
'account_label' => $this->getAccountLabel('4455100'),
|
'account_label' => $this->getAccountLabel('4455100'),
|
||||||
'entry_label' => $declaration->declaration_name,
|
'entry_label' => $declaration->declaration_name,
|
||||||
'debit' => '',
|
'debit' => '',
|
||||||
'credit' => $this->formatAmount(abs($rounded_amount))
|
'credit' => $this->formatAmountReal($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->formatAmountReal(abs($difference)),
|
||||||
|
'credit' => ''
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
|
||||||
// Rounding entry with real difference
|
|
||||||
if (abs($rounding_diff) >= 0.01) {
|
|
||||||
if ($difference > 0) {
|
|
||||||
// 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' => ''
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// 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))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user