Skip to Content
Menu
This question has been flagged
I have an invoice with 1 line, and two taxes. I need the price to change according to the selected tax.
example:
price:500, Quantity:1
tax1: (price * 0.084)* %tax1
tax2: (price * 1) * %Tax2
Being a single line, the price is the same for both taxes. 
The error is that it always takes the same price for the calculation of the two taxes. despite the filter. (if xx.code [10])
code:
    @api.multi

def get_taxes_values(self):#para calcular el valor de los impuestos.
tax_grouped = {}
for line in self.invoice_line_ids:
if len(line.invoice_line_tax_ids)==2:
for line_tax in line.invoice_line_tax_ids:
taxes={}
taxesisc={}
if line_tax.tipo_afectacion_igv.code in ["10"]:
price_unit = line.price_unit * (1 - (line.discount or 0.0) / 100.0)-line.descuento_unitario
taxes=line.invoice_line_tax_ids.compute_all(price_unit, self.currency_id, line.quantity, line.product_id, self.partner_id)['taxes']
for tax in taxes:
if line_tax.tipo_afectacion_igv.code in ["10"]:
val = self._prepare_tax_line_vals(line, tax)
key = self.env['account.tax'].browse(tax['id']).get_grouping_key(val) if key not in tax_grouped:
tax_grouped[key] = val
else: tax_grouped[key]['amount'] = val['amount']
tax_grouped[key]['base'] = val['base'] elif line_tax.tipo_afectacion_igv.code in ["99"]:
price_unitisc = line.price_unit*0.847 * (1 - (line.discount or 0.0) / 100.0)-line.descuento_unitario
taxesisc=line.invoice_line_tax_ids.compute_all(price_unitisc, self.currency_id, line.quantity, line.product_id, self.partner_id)['taxes']
for taxisc in taxesisc:
if line_tax.tipo_afectacion_igv.code in ["99"]:
val1 = self._prepare_tax_line_vals(line, taxisc)
key = self.env['account.tax'].browse(taxisc['id']).get_grouping_key(val1)
if key not in tax_grouped:
tax_grouped[key] = val1
else:
tax_grouped[key]['amount'] = val1['amount']
tax_grouped[key]['base'] = val1['base'] return tax_grouped
Avatar
Discard
Related Posts Replies Views Activity
4
Mar 24
71882
1
Oct 22
7112
1
Dec 18
3463
2
May 24
1609
2
Jan 23
3049