Consider tax deducible check in ReceivedInvoiceMapper.

This commit refs #23921
This commit is contained in:
Sergio Morillo 2022-08-09 17:35:55 +02:00
parent d952a9b8be
commit f29fc68153
1 changed files with 21 additions and 3 deletions

View File

@ -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