From 610044193cd6d176134caeee3c7dfdfccae38b64 Mon Sep 17 00:00:00 2001 From: Sergio Morillo Date: Thu, 5 Oct 2023 16:50:40 +0200 Subject: [PATCH] Added get_tax_amount and get_tax_base to base mapper class. --- aeat_mapping.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/aeat_mapping.py b/aeat_mapping.py index b7aca7a..b934120 100644 --- a/aeat_mapping.py +++ b/aeat_mapping.py @@ -56,11 +56,11 @@ class BaseTrytonInvoiceMapper(Model): total = 0 taxes_used = {} for tax in taxes: - base = tax.company_base + base = self.get_tax_base(tax) parent = tax.tax.parent if tax.tax.parent else tax.tax if parent.id in list(taxes_used.keys()) and base == taxes_used[parent.id]: continue - total += (base + tax.company_amount) + total += (base + self.get_tax_amount(tax)) taxes_used[parent.id] = base return total @@ -69,8 +69,17 @@ class BaseTrytonInvoiceMapper(Model): untaxed_amount = get_invoice_untaxed total_amount = get_invoice_total tax_rate = attrgetter('tax.rate') - tax_base = attrgetter('company_base') - tax_amount = attrgetter('company_amount') + + def get_tax_amount(self, tax): + val = attrgetter('company_amount')(tax) + return val + + def get_tax_base(self, tax): + val = attrgetter('company_base')(tax) + return val + + tax_base = get_tax_base + tax_amount = get_tax_amount def counterpart_name(self, invoice): return tools.unaccent(invoice.party.name)