Skip to content

Commit ca16013

Browse files
committed
account_invoice_ubl: fix tax
In case of tax exempt invoice where lines have a tax without repartition lines, declare tax based on the tax of the line
1 parent a020632 commit ca16013

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

account_invoice_ubl/models/account_move.py

+17-10
Original file line numberDiff line numberDiff line change
@@ -327,18 +327,25 @@ def _ubl_add_tax_total(self, xml_root, ns, version="2.1"):
327327
cur_name = self.currency_id.name
328328
prec = self.currency_id.decimal_places
329329

330-
# There are as many tax line as there are repartition lines
331330
tax_lines = {}
332331
for tline in self.line_ids:
333-
if not tline.tax_line_id:
334-
continue
335-
tax_lines.setdefault(
336-
tline.tax_line_id,
337-
{"base": 0.0, "amount": 0.0},
338-
)
339-
tax_lines[tline.tax_line_id]["base"] += tline.tax_base_amount
340-
sign = 1 if tline.is_refund else -1
341-
tax_lines[tline.tax_line_id]["amount"] += sign * tline.balance
332+
if tline.tax_line_id:
333+
# There are as many tax line as there are repartition lines
334+
tax_lines.setdefault(
335+
tline.tax_line_id,
336+
{"base": 0.0, "amount": 0.0},
337+
)
338+
tax_lines[tline.tax_line_id]["base"] += tline.tax_base_amount
339+
sign = 1 if tline.is_refund else -1
340+
tax_lines[tline.tax_line_id]["amount"] += sign * tline.balance
341+
elif tline.tax_ids:
342+
# In case there are no repartition lines
343+
for tax in tline.tax_ids:
344+
tax_lines.setdefault(
345+
tax,
346+
{"base": 0.0, "amount": 0.0},
347+
)
348+
tax_lines[tax]["base"] += tline.balance
342349

343350
exempt = 0.0
344351
exempt_taxes = self.line_ids.tax_line_id.browse()

0 commit comments

Comments
 (0)