Add line 23 subtotal for Section C
Added: - Line 23: Subtotal of lines 20, 21, 22 (for user reference) - calculateLine23() method that sums VAT amounts from lines 20, 21, 22 - Line 23 display in Section C between lines 22 and Section D - Line 23 shows as 'Sous-total TVA déductible (20 + 21 + 22)' with bold formatting - Provides subtotal for Section C just like line 16 for Section B
This commit is contained in:
parent
f53485eb9a
commit
39a2414d63
@ -284,6 +284,9 @@ class DeclarationTVA
|
|||||||
// Calculate line 16: Subtotal of lines 08, 09, 9B (for user reference)
|
// Calculate line 16: Subtotal of lines 08, 09, 9B (for user reference)
|
||||||
$this->calculateLine16($declaration_id);
|
$this->calculateLine16($declaration_id);
|
||||||
|
|
||||||
|
// Calculate line 23: Subtotal of lines 20, 21, 22 (for user reference)
|
||||||
|
$this->calculateLine23($declaration_id);
|
||||||
|
|
||||||
// Calculate D-section result lines (25, 26, 28, 29)
|
// Calculate D-section result lines (25, 26, 28, 29)
|
||||||
$this->calculateDSectionLines($declaration_id, $total_vat_collected, $total_vat_deductible);
|
$this->calculateDSectionLines($declaration_id, $total_vat_collected, $total_vat_deductible);
|
||||||
|
|
||||||
@ -332,6 +335,40 @@ class DeclarationTVA
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate line 23: Subtotal of lines 20, 21, 22 (for user reference)
|
||||||
|
*
|
||||||
|
* @param int $declaration_id Declaration ID
|
||||||
|
* @return bool Success
|
||||||
|
*/
|
||||||
|
private function calculateLine23($declaration_id)
|
||||||
|
{
|
||||||
|
// Get the amounts from lines 20, 21, 22
|
||||||
|
$sql = "SELECT ca3_line, vat_amount FROM " . MAIN_DB_PREFIX . "declarationtva_ca3_lines
|
||||||
|
WHERE declaration_id = " . (int)$declaration_id . "
|
||||||
|
AND ca3_line IN ('20', '21', '22')";
|
||||||
|
|
||||||
|
$result = $this->db->query($sql);
|
||||||
|
$line_23_total = 0;
|
||||||
|
$account_labels = array();
|
||||||
|
|
||||||
|
if ($result) {
|
||||||
|
while ($obj = $this->db->fetch_object($result)) {
|
||||||
|
$line_23_total += $obj->vat_amount;
|
||||||
|
$account_labels[] = "Line " . $obj->ca3_line . ": " . number_format($obj->vat_amount, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create line 23 record
|
||||||
|
$this->createCA3Line($declaration_id, '23', 'Subtotal: ' . implode(', ', $account_labels), array(
|
||||||
|
'base_amount' => 0,
|
||||||
|
'vat_amount' => $line_23_total,
|
||||||
|
'total_amount' => $line_23_total
|
||||||
|
));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculate D-section result lines (25, 26, 28, 29)
|
* Calculate D-section result lines (25, 26, 28, 29)
|
||||||
*
|
*
|
||||||
|
|||||||
@ -243,6 +243,14 @@ foreach ($section_c_lines as $line) {
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Line 23: Subtotal (calculated automatically)
|
||||||
|
$data = isset($ca3_data['23']) ? $ca3_data['23'] : array('line_label' => '', 'vat_amount' => 0);
|
||||||
|
print '<tr class="pair">';
|
||||||
|
print '<td><strong>23</strong></td>';
|
||||||
|
print '<td colspan="2"><strong>Sous-total TVA déductible (20 + 21 + 22)</strong></td>';
|
||||||
|
print '<td class="right"><strong>' . price($data['vat_amount']) . '</strong></td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
// Section D: Résultat
|
// Section D: Résultat
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<td colspan="4"><strong>D. ' . $langs->trans("CA3SectionD") . '</strong></td>';
|
print '<td colspan="4"><strong>D. ' . $langs->trans("CA3SectionD") . '</strong></td>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user