Skip to content

Commit

Permalink
intrastat_product: suppl_unit_qty rounded to 1 if between 0 and 0.5
Browse files Browse the repository at this point in the history
Improve comment in the code about rounding
  • Loading branch information
alexis-via committed Nov 10, 2023
1 parent 3cdeff3 commit 64e1bf7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion intrastat_product/models/intrastat_product_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,11 +1149,16 @@ def _prepare_declaration_line(self):
computation_line["amount_company_currency"]
+ computation_line["amount_accessory_cost_company_currency"]
)
# round, otherwise odoo with truncate (6.7 -> 6... instead of 7 !)
# on computation lines, weight and suppl_unit_qty are floats
# on declaration lines, weight and suppl_unit_qty are integer => so we must round()
for field in fields_to_sum:
vals[field] = int(round(vals[field]))
# the intrastat specs say that, if the value is between 0 and 0.5,
# it should be rounded to 1
if not vals["weight"]:
vals["weight"] = 1
if vals["intrastat_unit_id"] and not vals["suppl_unit_qty"]:
vals["suppl_unit_qty"] = 1
vals["amount_company_currency"] = int(round(vals["amount_company_currency"]))
return vals

Expand Down

0 comments on commit 64e1bf7

Please sign in to comment.