-
-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FIX] 1l10n_it_intrastat_statement: Fixed grouping of intrastat lines of reversed entries #4361
base: 16.0
Are you sure you want to change the base?
[FIX] 1l10n_it_intrastat_statement: Fixed grouping of intrastat lines of reversed entries #4361
Conversation
… if a reversed entry is not in the same period of the line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test funzionale: OK
@LorenzoC0 Puoi cortesemente aggiungere sui test come descritto nella issue? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grazie della PR!
Puoi correggere il titolo del commit? C'è un 1 di troppo:
[FIX] 1l10n_it_intrastat_statement: Fixed grouping of intrastat lines if a reversed entry is not in the same period of the line
Potresti anche aggiungere un test? Così si evitano regressioni
line.invoice_id.reversed_entry_id.date < period_date_start | ||
or line.invoice_id.reversed_entry_id.date > period_date_stop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Questi stessi campi vengono usati qualche riga sopra per filtrare il campo invoice_date
, come mai qui invece viene usato date
?
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quindi la riga line
viene segnata come rimborso solo quando la sua fattura ha un rimborso con data inclusa nel periodo, giusto?
Potresti modificarlo come suggerito qui sotto?
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) | |
refund_date = line.invoice_id.reversed_entry_id.date | |
if refund_date and period_date_start <= refund_date <= period_date_stop: | |
self.refund_line(line, to_refund_model) |
Credo sia un po' più leggibile.
Inoltre, non serve anche che il rimborso sia intrastat
?
Forse si potrebbe cercare se il rimborso è tra le fatture delle righe che sono già state incluse nella dichiarazione qualche riga sopra, cosa ne dici? Così non serve rifare questi controlli sulle date.
period_date_start = fields.Date.to_date(period_date_start) | ||
period_date_stop = fields.Date.to_date(period_date_stop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
period_date_start/stop
sono già delle date
perché vengono da
l10n-italy/l10n_it_intrastat_statement/models/intrastat_statement.py
Lines 447 to 463 in b59b677
period_date_start = date(year, 1, 1) | |
period_date_stop = date(year, 12, 31) | |
if self.period_type == "M": | |
month = self.period_number | |
period_date_start = date(year, month, 1) | |
period_date_stop = ( | |
datetime(year, month, 1) + relativedelta(months=1) - timedelta(days=1) | |
) | |
elif self.period_type == "T": | |
quarter = self.period_number | |
month_start = int(12 / 4 * (quarter - 1) + 1) | |
period_date_start = date(year, month_start, 1) | |
period_date_stop = ( | |
period_date_start + relativedelta(months=3) - timedelta(days=1) | |
) | |
return period_date_start, period_date_stop |
come mai serve questa conversione?
Risolve #4360