From 265599ac6130e5093462e7d359e0025700023cdf Mon Sep 17 00:00:00 2001 From: Mathias Behrle Date: Tue, 15 Oct 2024 11:28:00 +0200 Subject: [PATCH] Lookup parent taxes for unece tax codes. Child taxes do not respect the setting of the parent 'Override tmeplate', thus can not be configured for unece codes. It is anyway better to allow the code definition on the parent tax. --- edocument.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/edocument.py b/edocument.py index c71c002..26f2a9d 100644 --- a/edocument.py +++ b/edocument.py @@ -63,7 +63,8 @@ class Invoice(Invoice): numtax=len(line.invoice_taxes))) allowed_cat = ['AE', 'L', 'M', 'E', 'S', 'Z', 'G', 'O', 'K', 'B'] - if not line.invoice_taxes[0].tax.unece_category_code in allowed_cat: + unece_category_code = self.get_category_code(line.invoice_taxes[0].tax) + if unece_category_code not in allowed_cat: raise UserError(gettext( 'edocument_xrechnung.msg_linetax_invalid_catcode', taxname=line.invoice_taxes[0].tax.rec_name, @@ -99,14 +100,22 @@ class Invoice(Invoice): uomname=line.unit.rec_name)) return line.unit.unece_code + def get_category_code(self, tax): + while tax: + if tax.unece_category_code: + return tax.unece_category_code + break + tax = tax.parent + def tax_category_code(self, tax): """ read tax-category, fire exception if missing """ - if len(tax.unece_category_code or '') == 0: + unece_category_code = self.get_category_code(tax) + if not unece_category_code: raise UserError(gettext( 'edocument_xrechnung.mds_tax_category_missing', taxname=tax.rec_name)) - return tax.unece_category_code + return unece_category_code def quote_text(self, text): """ replace critical chars