[FIX] account: tax included
- Create a tax included of 21 %
- Create a product sold 7.00, set the 21 % tax
- Add the product in a SO
Amount w/o tax: 5.79
Amount tax: 1.22
Total: 7.01
We defer the base rounding to the end of the method so that the rounding
doesn't impact the tax computation of included taxes.
Complement of 6e46ba7b46
opw-777221
This commit is contained in:
@@ -758,7 +758,7 @@ class AccountTax(models.Model):
|
||||
# (145 - 15) / (1.0 + ((10 + 20) / 100.0)) = 130 / 1.3 = 100
|
||||
if fixed_amount == 0.0 and percent_amount == 0.0:
|
||||
return base_amount
|
||||
return round((base_amount - fixed_amount) / (1.0 + percent_amount / 100.0), prec)
|
||||
return (base_amount - fixed_amount) / (1.0 + percent_amount / 100.0)
|
||||
|
||||
base = round(price_unit * quantity, prec)
|
||||
|
||||
@@ -822,7 +822,7 @@ class AccountTax(models.Model):
|
||||
'id': tax.id,
|
||||
'name': tax.with_context(**{'lang': partner.lang} if partner else {}).name,
|
||||
'amount': sign * tax_amount,
|
||||
'base': sign * tax_base,
|
||||
'base': round(sign * tax_base, prec),
|
||||
'sequence': tax.sequence,
|
||||
'account_id': tax.account_id.id,
|
||||
'refund_account_id': tax.refund_account_id.id,
|
||||
@@ -833,7 +833,7 @@ class AccountTax(models.Model):
|
||||
'taxes': taxes_vals,
|
||||
'total_excluded': sign * (currency.round(total_excluded) if round_total else total_excluded),
|
||||
'total_included': sign * (currency.round(total_included) if round_total else total_included),
|
||||
'base': sign * base,
|
||||
'base': round(sign * base, prec),
|
||||
}
|
||||
|
||||
@api.v7
|
||||
|
||||
@@ -28,6 +28,12 @@ class TestTax(AccountTestUsers):
|
||||
'amount': 10,
|
||||
'sequence': 3,
|
||||
})
|
||||
self.percent_tax_bis = self.tax_model.create({
|
||||
'name': "Percent tax bis",
|
||||
'amount_type': 'percent',
|
||||
'amount': 21,
|
||||
'sequence': 3,
|
||||
})
|
||||
self.division_tax = self.tax_model.create({
|
||||
'name': "Division tax",
|
||||
'amount_type': 'division',
|
||||
@@ -172,6 +178,21 @@ class TestTax(AccountTestUsers):
|
||||
],
|
||||
res_percent
|
||||
)
|
||||
self.percent_tax_bis.price_include = True
|
||||
self.percent_tax_bis.include_base_amount = True
|
||||
res_percent = self.percent_tax_bis.compute_all(7.0)
|
||||
self._check_compute_all_results(
|
||||
7.0, # 'base'
|
||||
7.0, # 'total_included'
|
||||
5.79, # 'total_excluded'
|
||||
[
|
||||
# base , amount | seq | amount | incl | incl_base
|
||||
# ---------------------------------------------------
|
||||
(5.79, 1.21), # | 3 | 21% | t | t
|
||||
# ---------------------------------------------------
|
||||
],
|
||||
res_percent
|
||||
)
|
||||
|
||||
def test_tax_sequence_normalized_set(self):
|
||||
self.division_tax.sequence = 1
|
||||
|
||||
Reference in New Issue
Block a user