fix: populate line 22 from prior credit and correct query
- Create line 22 from carry-forward before computing line 23 - Use numero_compte and entity filter to read 44567 balance - Ensures prior period VAT credit appears in current declaration
This commit is contained in:
parent
c02cc8071b
commit
ea11f50de2
@ -277,7 +277,17 @@ class DeclarationTVA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inject carry-forward into line 22 BEFORE computing line 23
|
||||||
|
// Line 22 should represent the carry-forward credit from previous periods
|
||||||
|
$carry_forward = $this->getVATCreditCarryForward($period['start_date']);
|
||||||
|
// Remove existing line 22 (created above) and recreate with carry-forward amount
|
||||||
|
$this->db->query("DELETE FROM " . MAIN_DB_PREFIX . "declarationtva_ca3_lines WHERE declaration_id = " . (int)$declaration_id . " AND ca3_line = '22'");
|
||||||
|
$this->createCA3Line($declaration_id, '22', 'Report du crédit apparaissant ligne 27 de la précédente déclaration', array(
|
||||||
|
'base_amount' => 0,
|
||||||
|
'vat_amount' => $carry_forward,
|
||||||
|
'total_amount' => $carry_forward
|
||||||
|
));
|
||||||
|
|
||||||
// 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);
|
||||||
|
|
||||||
@ -905,10 +915,12 @@ class DeclarationTVA
|
|||||||
$vat_to_receive_account = $journal_config['vat_to_receive'];
|
$vat_to_receive_account = $journal_config['vat_to_receive'];
|
||||||
|
|
||||||
// Check VAT credit account balance at declaration start date
|
// Check VAT credit account balance at declaration start date
|
||||||
|
// Use bookkeeping table columns: numero_compte, debit, credit, doc_date, entity
|
||||||
$sql = "SELECT SUM(debit - credit) as balance
|
$sql = "SELECT SUM(debit - credit) as balance
|
||||||
FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping
|
FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping
|
||||||
WHERE account_number = '" . $this->db->escape($vat_to_receive_account) . "'
|
WHERE numero_compte = '" . $this->db->escape($vat_to_receive_account) . "'
|
||||||
AND doc_date < '" . $declaration_start_date . "'";
|
AND doc_date < '" . $this->db->escape($declaration_start_date) . "'
|
||||||
|
AND entity = " . $this->entity;
|
||||||
|
|
||||||
$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) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user