Skip to content

Commit

Permalink
[FIX] l10n_es_aeat_mod303: Avoid negatives in fee to compensate
Browse files Browse the repository at this point in the history
If the previous 303 report has remaining fee to compensate, and the
result of the report is positive and bigger than the fee to compensate,
when computing the current one, the constraint

  "The fee to compensate must be indicated as a positive number."

will raise always.

To avoid it, two changes have been done:

1. Only substract report result if it's of type C.
2. Nullify any possible result when it's less than 0.

Amendment of 4bd1c02

TT55245
  • Loading branch information
pedrobaeza committed Feb 26, 2025
1 parent 32f63d6 commit 5d3c7a7
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions l10n_es_aeat_mod303/models/mod303.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,18 +519,11 @@ def calculate(self):
- fields.Date.to_date(mod303.date_start)
),
)
if prev_report and (
prev_report.remaining_cuota_compensar > 0
or prev_report.result_type == "C"
):
mod303.write(
{
"potential_cuota_compensar": (
prev_report.remaining_cuota_compensar
- prev_report.resultado_liquidacion
),
}
)
if prev_report.remaining_cuota_compensar > 0:
amount = prev_report.remaining_cuota_compensar
if prev_report.result_type == "C":
amount -= prev_report.resultado_liquidacion
mod303.potential_cuota_compensar = amount if amount > 0 else 0
if mod303.return_last_period:
cuota_compensar = mod303.potential_cuota_compensar
elif (
Expand All @@ -547,7 +540,6 @@ def calculate(self):
else:
cuota_compensar = 0
mod303.cuota_compensar = cuota_compensar

return res

def button_confirm(self):
Expand Down

0 comments on commit 5d3c7a7

Please sign in to comment.