From 9a13bc325d535b43ae9e9b3a24effc72fef1c831 Mon Sep 17 00:00:00 2001 From: Frederik Jaeckel Date: Thu, 9 Jan 2025 11:50:00 +0100 Subject: [PATCH] calculation of the tax adjusted --- mixin.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/mixin.py b/mixin.py index e8762fe..8a75aca 100644 --- a/mixin.py +++ b/mixin.py @@ -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)