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 {
|
} else {
|
||||||
// Fallback to original logic if no TD line found
|
// Fallback to original logic if no TD line found - use real value, not rounded
|
||||||
$rounded_difference = round($difference);
|
error_log("DeclarationTVA: No TD line found, using fallback logic with real value");
|
||||||
if ($rounded_difference != 0) {
|
if (abs($difference) >= 0.01) {
|
||||||
if ($rounded_difference < 0) {
|
if ($difference < 0) {
|
||||||
$balancing_entries[] = array(
|
$balancing_entries[] = array(
|
||||||
'account_code' => '4456700',
|
'account_code' => '4456700',
|
||||||
'account_label' => $this->getAccountLabel('4456700'),
|
'account_label' => $this->getAccountLabel('4456700'),
|
||||||
'entry_label' => $declaration->declaration_name,
|
'entry_label' => $declaration->declaration_name,
|
||||||
'debit' => $this->formatAmount(abs($rounded_difference)),
|
'debit' => $this->formatAmountReal(abs($difference)),
|
||||||
'credit' => ''
|
'credit' => ''
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -2141,7 +2141,7 @@ class DeclarationTVA_PDF
|
|||||||
'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($rounded_difference)
|
'credit' => $this->formatAmountReal($difference)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2163,12 +2163,16 @@ class DeclarationTVA_PDF
|
|||||||
AND ca3_line = 'TD'
|
AND ca3_line = 'TD'
|
||||||
AND entity = " . $this->entity;
|
AND entity = " . $this->entity;
|
||||||
|
|
||||||
|
error_log("DeclarationTVA: TD line query: " . $sql);
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result && $this->db->num_rows($result) > 0) {
|
if ($result && $this->db->num_rows($result) > 0) {
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
|
error_log("DeclarationTVA: TD line found with vat_amount: " . $obj->vat_amount);
|
||||||
return (float)$obj->vat_amount;
|
return (float)$obj->vat_amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error_log("DeclarationTVA: TD line not found or has no rows");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user