Fix rounding calculation to use real values instead of rounded
- Added debugging to TD line query to see why VAT amount is 0 - Fixed fallback logic to use formatAmountReal() instead of formatAmount() - When TD line has 0 VAT amount, now uses real difference (0.90) instead of rounded (1.00) - Added logging to track TD line query and results - Should now show 0.90 instead of 1.00 in rounding entry
This commit is contained in:
parent
c7cfd3e52d
commit
ff314d043e
@ -2124,15 +2124,15 @@ class DeclarationTVA_PDF
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Fallback to original logic if no TD line found
|
||||
$rounded_difference = round($difference);
|
||||
if ($rounded_difference != 0) {
|
||||
if ($rounded_difference < 0) {
|
||||
// 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) {
|
||||
$balancing_entries[] = array(
|
||||
'account_code' => '4456700',
|
||||
'account_label' => $this->getAccountLabel('4456700'),
|
||||
'entry_label' => $declaration->declaration_name,
|
||||
'debit' => $this->formatAmount(abs($rounded_difference)),
|
||||
'debit' => $this->formatAmountReal(abs($difference)),
|
||||
'credit' => ''
|
||||
);
|
||||
} else {
|
||||
@ -2141,7 +2141,7 @@ class DeclarationTVA_PDF
|
||||
'account_label' => $this->getAccountLabel('4455100'),
|
||||
'entry_label' => $declaration->declaration_name,
|
||||
'debit' => '',
|
||||
'credit' => $this->formatAmount($rounded_difference)
|
||||
'credit' => $this->formatAmountReal($difference)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -2163,12 +2163,16 @@ class DeclarationTVA_PDF
|
||||
AND ca3_line = 'TD'
|
||||
AND entity = " . $this->entity;
|
||||
|
||||
error_log("DeclarationTVA: TD line query: " . $sql);
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result && $this->db->num_rows($result) > 0) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
error_log("DeclarationTVA: TD line found with vat_amount: " . $obj->vat_amount);
|
||||
return (float)$obj->vat_amount;
|
||||
}
|
||||
|
||||
error_log("DeclarationTVA: TD line not found or has no rows");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user