Skip to content

Commit

Permalink
FIX l10n_it_fatturapa_in, Setting Italian timezone by default, otherw…
Browse files Browse the repository at this point in the history
…ise e_invoice_received_date could be set the day before of the actual date

Example:
receiving date = 2022-04-01 00:16
saved in DB, UTC format, as 2022-03-31 22:16:03
converted to date = 2022-03-31

In this case, the invoice would be registered in the wrong period (month)
  • Loading branch information
eLBati authored and sergiocorato committed Jan 17, 2025
1 parent eae23da commit 85ced0e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion l10n_it_fatturapa_in/wizard/wizard_import_fatturapa.py
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,22 @@ def _prepare_invoice_values(self, fatt, fatturapa_attachment, FatturaBody, partn
if causLst:
for rel_doc in causLst:
comment += rel_doc + "\n"
e_invoice_received_date = self._get_received_date(fatturapa_attachment)

if (
not fatturapa_attachment.env.context.get("tz")
and not fatturapa_attachment.env.user.tz
):
# Setting Italian timezone, otherwise e_invoice_received_date
# could be set the day before of the actual date.
fatturapa_attachment = fatturapa_attachment.with_context(tz="Europe/Rome")
if fatturapa_attachment.e_invoice_received_date:
e_invoice_received_date = fields.Datetime.context_timestamp(
fatturapa_attachment, fatturapa_attachment.e_invoice_received_date
).date()
else:
e_invoice_received_date = fields.Datetime.context_timestamp(
fatturapa_attachment, fatturapa_attachment.create_date
).date()
e_invoice_date = datetime.strptime(
FatturaBody.DatiGenerali.DatiGeneraliDocumento.Data, "%Y-%m-%d"
).date()
Expand Down

0 comments on commit 85ced0e

Please sign in to comment.