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