Skip to content

Commit

Permalink
account_invoice_ubl: fix tax
Browse files Browse the repository at this point in the history
In case of tax exempt invoice where lines have a tax without repartition lines, declare tax based on the tax of the line
  • Loading branch information
jbaudoux committed Dec 4, 2024
1 parent a020632 commit ca16013
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions account_invoice_ubl/models/account_move.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,25 @@ def _ubl_add_tax_total(self, xml_root, ns, version="2.1"):
cur_name = self.currency_id.name
prec = self.currency_id.decimal_places

# There are as many tax line as there are repartition lines
tax_lines = {}
for tline in self.line_ids:
if not tline.tax_line_id:
continue
tax_lines.setdefault(
tline.tax_line_id,
{"base": 0.0, "amount": 0.0},
)
tax_lines[tline.tax_line_id]["base"] += tline.tax_base_amount
sign = 1 if tline.is_refund else -1
tax_lines[tline.tax_line_id]["amount"] += sign * tline.balance
if tline.tax_line_id:
# There are as many tax line as there are repartition lines
tax_lines.setdefault(
tline.tax_line_id,
{"base": 0.0, "amount": 0.0},
)
tax_lines[tline.tax_line_id]["base"] += tline.tax_base_amount
sign = 1 if tline.is_refund else -1
tax_lines[tline.tax_line_id]["amount"] += sign * tline.balance
elif tline.tax_ids:
# In case there are no repartition lines
for tax in tline.tax_ids:
tax_lines.setdefault(
tax,
{"base": 0.0, "amount": 0.0},
)
tax_lines[tax]["base"] += tline.balance

exempt = 0.0
exempt_taxes = self.line_ids.tax_line_id.browse()
Expand Down

0 comments on commit ca16013

Please sign in to comment.