[FIX] account: base amount when tax calculated
Commit 8ad0c0f3 introduces back the base amount taken into account for
tax calculation. However, the way it calculates the amount is wrong in
several cases:
- the tax amount is a percentage
- the tax is calculated thanks to Python code
opw-686846
This commit is contained in:
@@ -1287,9 +1287,10 @@ class AccountInvoiceTax(models.Model):
|
||||
base = 0.0
|
||||
for line in tax.invoice_id.invoice_line_ids:
|
||||
if tax.tax_id in line.invoice_line_tax_ids:
|
||||
base += line.price_subtotal
|
||||
# To add include base amount taxes
|
||||
base += sum((line.invoice_line_tax_ids.filtered(lambda t: t.include_base_amount) - tax.tax_id).mapped('amount'))
|
||||
price_unit = line.price_unit * (1 - (line.discount or 0.0) / 100.0)
|
||||
base += (line.invoice_line_tax_ids - tax.tax_id).compute_all(
|
||||
price_unit, line.invoice_id.currency_id, line.quantity, line.product_id, line.invoice_id.partner_id
|
||||
)['base']
|
||||
tax.base = base
|
||||
|
||||
invoice_id = fields.Many2one('account.invoice', string='Invoice', ondelete='cascade', index=True)
|
||||
|
||||
Reference in New Issue
Block a user