Skip to content

Commit

Permalink
[FIX] 1l10n_it_intrastat_statement: Fixed grouping of intrastat lines…
Browse files Browse the repository at this point in the history
… if a reversed entry is not in the same period of the line
  • Loading branch information
LorenzoC0 committed Sep 6, 2024
1 parent 6ec0bf4 commit 566d552
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion l10n_it_intrastat_statement/models/intrastat_statement.py
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,10 @@ def compute_statement(self):
(2, 1), # Sale (Purchase) section 2 refunds section 1
(4, 3), # Sale (Purchase) section 4 refunds section 3
]

period_date_start = fields.Date.to_date(period_date_start)
period_date_stop = fields.Date.to_date(period_date_stop)

for section_type in ["purchase", "sale"]:
for section_number, refund_section_number in refund_map:
section_details = (section_type, section_number)
Expand All @@ -819,7 +823,14 @@ def compute_statement(self):
*refund_section_details
)
to_refund_model = self.env[refund_section_model]
self.refund_line(line, to_refund_model)
if not (
line.invoice_id.reversed_entry_id
and (
line.invoice_id.reversed_entry_id.date < period_date_start
or line.invoice_id.reversed_entry_id.date > period_date_stop
)
):
self.refund_line(line, to_refund_model)
return True

@staticmethod
Expand Down

0 comments on commit 566d552

Please sign in to comment.