Fix VAT credit scenario balancing logic
- Main balancing entry now uses rounded amount (formatAmount) for proper accounting - Rounding difference goes to 658000/758000 with real value (formatAmountReal) - Fixed fallback logic to handle both VAT debit and credit scenarios correctly - VAT credit: rounded amount on 4456700, real difference on 658000 - VAT debit: rounded amount on 4455100, real difference on 758000
This commit is contained in:
parent
ff314d043e
commit
ffe8a960e2
@ -2124,15 +2124,18 @@ class DeclarationTVA_PDF
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Fallback to original logic if no TD line found - use real value, not rounded
|
||||
error_log("DeclarationTVA: No TD line found, using fallback logic with real value");
|
||||
if (abs($difference) >= 0.01) {
|
||||
if ($difference < 0) {
|
||||
// Fallback to original logic if no TD line found
|
||||
error_log("DeclarationTVA: No TD line found, using fallback logic");
|
||||
|
||||
// Use rounded amount for main balancing entry
|
||||
$rounded_difference = round($difference);
|
||||
if ($rounded_difference != 0) {
|
||||
if ($rounded_difference < 0) {
|
||||
$balancing_entries[] = array(
|
||||
'account_code' => '4456700',
|
||||
'account_label' => $this->getAccountLabel('4456700'),
|
||||
'entry_label' => $declaration->declaration_name,
|
||||
'debit' => $this->formatAmountReal(abs($difference)),
|
||||
'debit' => $this->formatAmount(abs($rounded_difference)),
|
||||
'credit' => ''
|
||||
);
|
||||
} else {
|
||||
@ -2141,9 +2144,31 @@ class DeclarationTVA_PDF
|
||||
'account_label' => $this->getAccountLabel('4455100'),
|
||||
'entry_label' => $declaration->declaration_name,
|
||||
'debit' => '',
|
||||
'credit' => $this->formatAmountReal($difference)
|
||||
'credit' => $this->formatAmount($rounded_difference)
|
||||
);
|
||||
}
|
||||
|
||||
// Add rounding entry for the difference between real and rounded
|
||||
$rounding_diff = $difference - $rounded_difference;
|
||||
if (abs($rounding_diff) >= 0.01) {
|
||||
if ($rounding_diff < 0) {
|
||||
$balancing_entries[] = array(
|
||||
'account_code' => '658000',
|
||||
'account_label' => $this->getAccountLabel('658000'),
|
||||
'entry_label' => $declaration->declaration_name,
|
||||
'debit' => $this->formatAmountReal(abs($rounding_diff)),
|
||||
'credit' => ''
|
||||
);
|
||||
} else {
|
||||
$balancing_entries[] = array(
|
||||
'account_code' => '758000',
|
||||
'account_label' => $this->getAccountLabel('758000'),
|
||||
'entry_label' => $declaration->declaration_name,
|
||||
'debit' => '',
|
||||
'credit' => $this->formatAmountReal($rounding_diff)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user