Fix line 25 and TD logic for clear payment/receipt separation
Fixed: - Line 25: Only shows value if net_vat_due < 0 (VAT credit - we receive money) - Line TD: Only shows value if net_vat_due > 0 (VAT due - we pay money) - Clear separation between payment (TD) and receipt (25) scenarios - Line TD description: 'TVA due (montant à payer)' - This clearly separates when we need to pay vs receive VAT
This commit is contained in:
parent
7933d3f649
commit
893de77afc
@ -379,13 +379,24 @@ class DeclarationTVA
|
|||||||
*/
|
*/
|
||||||
private function calculateDSectionLines($declaration_id, $total_vat_collected, $total_vat_deductible)
|
private function calculateDSectionLines($declaration_id, $total_vat_collected, $total_vat_deductible)
|
||||||
{
|
{
|
||||||
// Line 25: TVA brute due (Total VAT due) - always positive
|
// Calculate net VAT due
|
||||||
$line_25_amount = $total_vat_collected;
|
$net_vat_due = $total_vat_collected - $total_vat_deductible;
|
||||||
$this->createCA3Line($declaration_id, '25', 'Calculated from sections A and B', array(
|
|
||||||
'base_amount' => 0,
|
// Line 25: TVA brute due (Total VAT due) - only if negative (VAT credit - we receive money)
|
||||||
'vat_amount' => $line_25_amount,
|
if ($net_vat_due < 0) {
|
||||||
'total_amount' => $line_25_amount
|
$line_25_amount = $total_vat_collected;
|
||||||
));
|
$this->createCA3Line($declaration_id, '25', 'Calculated from sections A and B', array(
|
||||||
|
'base_amount' => 0,
|
||||||
|
'vat_amount' => $line_25_amount,
|
||||||
|
'total_amount' => $line_25_amount
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
$this->createCA3Line($declaration_id, '25', 'Calculated from sections A and B', array(
|
||||||
|
'base_amount' => 0,
|
||||||
|
'vat_amount' => 0,
|
||||||
|
'total_amount' => 0
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// Line 26: TVA déductible totale (Total deductible VAT)
|
// Line 26: TVA déductible totale (Total deductible VAT)
|
||||||
$line_26_amount = $total_vat_deductible;
|
$line_26_amount = $total_vat_deductible;
|
||||||
@ -395,16 +406,21 @@ class DeclarationTVA
|
|||||||
'total_amount' => $line_26_amount
|
'total_amount' => $line_26_amount
|
||||||
));
|
));
|
||||||
|
|
||||||
// Calculate net VAT due
|
// Line TD: TVA due (VAT due) - only if positive (we need to pay)
|
||||||
$net_vat_due = $total_vat_collected - $total_vat_deductible;
|
if ($net_vat_due > 0) {
|
||||||
|
$line_td_amount = $net_vat_due;
|
||||||
// Line TD: TVA due (VAT due) - absolute value, never negative
|
$this->createCA3Line($declaration_id, 'TD', 'TVA due (amount to pay)', array(
|
||||||
$line_td_amount = abs($net_vat_due);
|
'base_amount' => 0,
|
||||||
$this->createCA3Line($declaration_id, 'TD', 'TVA due (absolute value)', array(
|
'vat_amount' => $line_td_amount,
|
||||||
'base_amount' => 0,
|
'total_amount' => $line_td_amount
|
||||||
'vat_amount' => $line_td_amount,
|
));
|
||||||
'total_amount' => $line_td_amount
|
} else {
|
||||||
));
|
$this->createCA3Line($declaration_id, 'TD', 'TVA due (amount to pay)', array(
|
||||||
|
'base_amount' => 0,
|
||||||
|
'vat_amount' => 0,
|
||||||
|
'total_amount' => 0
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
// Line 28: TVA nette due (Net VAT due) - if positive
|
// Line 28: TVA nette due (Net VAT due) - if positive
|
||||||
if ($net_vat_due > 0) {
|
if ($net_vat_due > 0) {
|
||||||
|
|||||||
@ -268,7 +268,7 @@ foreach ($section_d_lines as $line) {
|
|||||||
|
|
||||||
// Special handling for line TD
|
// Special handling for line TD
|
||||||
if ($line == 'TD') {
|
if ($line == 'TD') {
|
||||||
$description = 'TVA due (valeur absolue)';
|
$description = 'TVA due (montant à payer)';
|
||||||
} else {
|
} else {
|
||||||
$description = isset($ca3_definitions[$line]) ? $ca3_definitions[$line]['label'] : $data['line_label'];
|
$description = isset($ca3_definitions[$line]) ? $ca3_definitions[$line]['label'] : $data['line_label'];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user