mirror of
https://gitlab.com/datalifeit/trytond-aeat_sii
synced 2023-12-13 20:30:37 +01:00
Update total and untaxed amount calculation based on taxes, to control the not needed amount taxes
This commit is contained in:
parent
b163dd06d9
commit
f1dd61225e
|
@ -45,11 +45,24 @@ class BaseTrytonInvoiceMapper(Model):
|
|||
nif = nif[2:]
|
||||
return nif
|
||||
|
||||
def get_untaxed_amount(self, invoice):
|
||||
taxes = self.taxes(invoice)
|
||||
untaxed = 0
|
||||
for tax in taxes:
|
||||
untaxed += tax.company_base
|
||||
return untaxed
|
||||
|
||||
def get_total_amount(self, invoice):
|
||||
taxes = self.taxes(invoice)
|
||||
total = 0
|
||||
for tax in taxes:
|
||||
total += (tax.company_base + tax.company_amount)
|
||||
return total
|
||||
|
||||
counterpart_id_type = attrgetter('party.sii_identifier_type')
|
||||
counterpart_id = counterpart_nif
|
||||
|
||||
untaxed_amount = attrgetter('company_untaxed_amount')
|
||||
total_amount = attrgetter('company_total_amount')
|
||||
untaxed_amount = get_untaxed_amount
|
||||
total_amount = get_total_amount
|
||||
tax_rate = attrgetter('tax.rate')
|
||||
tax_base = attrgetter('company_base')
|
||||
tax_amount = attrgetter('company_amount')
|
||||
|
@ -83,13 +96,9 @@ class BaseTrytonInvoiceMapper(Model):
|
|||
])
|
||||
|
||||
def taxes(self, invoice):
|
||||
return [
|
||||
invoice_tax for invoice_tax in invoice.taxes
|
||||
if (
|
||||
return [invoice_tax for invoice_tax in invoice.taxes if (
|
||||
invoice_tax.tax.sii_subjected_key == 'S1' and
|
||||
not invoice_tax.tax.recargo_equivalencia
|
||||
)
|
||||
]
|
||||
not invoice_tax.tax.recargo_equivalencia)]
|
||||
|
||||
def _tax_equivalence_surcharge(self, invoice_tax):
|
||||
parent_tax = invoice_tax.tax.parent
|
||||
|
|
Loading…
Reference in a new issue