calculation of the tax adjusted

This commit is contained in:
Frederik Jaeckel 2025-01-09 11:50:00 +01:00
parent e291608373
commit 9a13bc325d

View file

@ -5,7 +5,6 @@
from decimal import Decimal
import datetime
import html
from trytond.exceptions import UserError
from trytond.i18n import gettext
@ -101,20 +100,19 @@ class EdocumentMixin(object):
""" get tax of invoice-line,
fire exception if no/multiple taxes exists
"""
Tax = Pool().get('account.tax')
if len(line.taxes) != 1:
raise UserError(gettext(
'edocument_xrechnung.msg_linetax_invalid_number',
linename=line.rec_name,
numtax=len(line.taxes)))
tax = line.taxes[0]
date = line.invoice.accounting_date or line.invoice.invoice_date
for child in tax.childs:
start_date = child.start_date or datetime.date.min
end_date = child.end_date or datetime.date.max
if start_date <= date <= end_date:
tax = child
break
taxlines = Tax.compute(
line.taxes, Decimal('1'), 1.0,
line.invoice.accounting_date or line.invoice.invoice_date)
assert len(taxlines) == 1
tax = taxlines[0]['tax']
allowed_cat = ['AE', 'L', 'M', 'E', 'S', 'Z', 'G', 'O', 'K', 'B']
unece_category_code = self.get_category_code(tax)