How to change the price according to the selected tax.
Detail of invoice, with 2 types of taxes in the same invoice line.
amount = 1
price: 500
Tax to: 10%
Value: 1 * 500 * 10% = 50
tax b: 18%
the tax b: takes as a basis the price * amount + (tax A)
amount * price + (tax A) * 18%
1 * 500 + (50) = 550 * 18% = 99
code
I need to differentiate the price according to the selected tax code. All the lines of the
The tax is calculated in the same way.
Observation: I am considering +50 test on the price.
class AccountInvoice(models.Model):
_inherit = "account.invoice"
......
..........
@api.multi
def get_taxes_values(self):
tax_grouped = {}
for line in self.invoice_line_ids:
if len(line.invoice_line_tax_ids)>0:
for line2 in line.invoice_line_tax_ids:
if line_tax.tipo_afectacion_igv.code in ["10"]:
taxes=line.invoice_line_tax_ids.compute_all(price_unit+50 if line_tax.tipo_afectacion_igv.code in ["10"] else price_unit, self.currency_id, line.quantity, line.product_id, self.partner_id)['taxes']
for tax in taxes:
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']
return tax_grouped