Added get_tax_amount and get_tax_base to base mapper class.

This commit is contained in:
Sergio Morillo 2023-10-05 16:50:40 +02:00
parent 7bef904ee6
commit 610044193c

View file

@ -56,11 +56,11 @@ class BaseTrytonInvoiceMapper(Model):
total = 0 total = 0
taxes_used = {} taxes_used = {}
for tax in taxes: 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 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]: if parent.id in list(taxes_used.keys()) and base == taxes_used[parent.id]:
continue continue
total += (base + tax.company_amount) total += (base + self.get_tax_amount(tax))
taxes_used[parent.id] = base taxes_used[parent.id] = base
return total return total
@ -69,8 +69,17 @@ class BaseTrytonInvoiceMapper(Model):
untaxed_amount = get_invoice_untaxed untaxed_amount = get_invoice_untaxed
total_amount = get_invoice_total total_amount = get_invoice_total
tax_rate = attrgetter('tax.rate') 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): def counterpart_name(self, invoice):
return tools.unaccent(invoice.party.name) return tools.unaccent(invoice.party.name)