From f29fc68153a5a237b91ff48f4058770d5b1746ea Mon Sep 17 00:00:00 2001 From: Sergio Morillo Date: Tue, 9 Aug 2022 17:35:55 +0200 Subject: [PATCH] Consider tax deducible check in ReceivedInvoiceMapper. This commit refs #23921 --- aeat_mapping.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/aeat_mapping.py b/aeat_mapping.py index 046e3ef..c031f8c 100644 --- a/aeat_mapping.py +++ b/aeat_mapping.py @@ -458,6 +458,24 @@ class RecievedInvoiceMapper(BaseInvoiceMapper): specialkey_or_trascendence = attrgetter('sii_received_key') move_date = attrgetter('move.date') + def get_tax_rate(self, tax): + if not tax.tax.deducible: + return 0.0 + return tax.tax.rate + + def get_tax_base(self, tax): + amount = super().get_tax_base(tax) + if not tax.tax.deducible: + amount += super().get_tax_amount(tax) + return amount + + tax_rate = get_tax_rate + + def get_tax_amount(self, tax): + if not tax.tax.deducible: + return Decimal('0.0') + return super().get_tax_amount(tax) + def _is_first_semester(self, invoice): return self.specialkey_or_trascendence(invoice) == \ SEMESTER1_RECIEVED_SPECIALKEY @@ -536,11 +554,11 @@ class RecievedInvoiceMapper(BaseInvoiceMapper): def build_taxes(self, invoice, tax): ret = { - 'BaseImponible': self.tax_base(tax), + 'BaseImponible': self.get_tax_base(tax), } if self.specialkey_or_trascendence(invoice) != '02': ret['TipoImpositivo'] = tools._rate_to_percent(self.tax_rate(tax)) - ret['CuotaSoportada'] = self.tax_amount(tax) + ret['CuotaSoportada'] = self.get_tax_amount(tax) if self.tax_equivalence_surcharge_rate(tax): ret['TipoRecargoEquivalencia'] = \ tools._rate_to_percent(self.tax_equivalence_surcharge_rate( @@ -555,5 +573,5 @@ class RecievedInvoiceMapper(BaseInvoiceMapper): ret['PorcentCompensacionREAGYP'] = \ tools._rate_to_percent(self.tax_rate(tax)) ret['ImporteCompensacionREAGYP'] = \ - (self.tax_amount(tax)) + (self.get_tax_amount(tax)) return ret