Reimplement location rules for not subject taxes.
This commit is contained in:
parent
c92609c7de
commit
e93deed771
|
@ -268,13 +268,13 @@ class IssuedInvoiceMapper(BaseInvoiceMapper):
|
|||
self.tax_equivalence_surcharge_amount(tax))
|
||||
return res
|
||||
|
||||
def location_rules(self, invoice):
|
||||
base = 0
|
||||
for line in invoice.lines:
|
||||
for tax in line.taxes:
|
||||
if tax.sii_issued_key == '08':
|
||||
base += attrgetter('amount')(line)
|
||||
return base
|
||||
def location_rules(self, tax, must_detail_op):
|
||||
return (tax.sii_issued_key == '08'
|
||||
or (must_detail_op and self.not_exempt_kind(tax) == 'S2')
|
||||
or (self.exempt_kind(tax) == 'NotSubject'))
|
||||
|
||||
def art_7_14(self, tax):
|
||||
return bool(tax.sii_issued_key == '10')
|
||||
|
||||
def build_issued_invoice(self, invoice):
|
||||
ret = {
|
||||
|
@ -371,20 +371,22 @@ class IssuedInvoiceMapper(BaseInvoiceMapper):
|
|||
'Exenta': {
|
||||
'DetalleExenta': {
|
||||
'CausaExencion': exempt_kind,
|
||||
'BaseImponible': self.get_tax_base(tax),
|
||||
'BaseImponible': baseimponible
|
||||
}
|
||||
}
|
||||
})
|
||||
if self.not_subject(invoice):
|
||||
detail['NoSujeta'].update({
|
||||
'ImportePorArticulos7_14_Otros': self.not_subject(
|
||||
invoice),
|
||||
})
|
||||
if self.location_rules(invoice):
|
||||
detail['NoSujeta'].update({
|
||||
'ImporteTAIReglasLocalizacion': self.location_rules(
|
||||
invoice)
|
||||
})
|
||||
elif self.art_7_14(tax.tax):
|
||||
detail['NoSujeta'].setdefault(
|
||||
'ImportePorArticulos7_14_Otros', 0)
|
||||
detail['NoSujeta']['ImportePorArticulos7_14_Otros'
|
||||
] += self.get_tax_base(tax)
|
||||
elif self.location_rules(tax.tax, must_detail_op):
|
||||
detail['NoSujeta'].setdefault(
|
||||
'ImporteTAIReglasLocalizacion', 0)
|
||||
detail['NoSujeta']['ImporteTAIReglasLocalizacion'
|
||||
] += self.get_tax_base(tax)
|
||||
else:
|
||||
raise NotImplementedError()
|
||||
|
||||
# remove unused key
|
||||
for key in ('Sujeta', 'NoSujeta'):
|
||||
|
|
Loading…
Reference in New Issue