diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2017-10-19 23:53:48 +0200 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2017-10-20 14:36:58 +0200 |
| commit | c6a9bab074492beffeddcb320cfdc042f021a285 (patch) | |
| tree | 83d19f3aabaabf4df33ec3efbede9dceb4a05c81 | |
| parent | 3be3c6f532fafff30c243d849e04e99547b4cad5 (diff) | |
[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 6e46ba7b460b5f155735c91f957a4dca3dec8f96
opw-777221
| -rw-r--r-- | addons/account/models/account.py | 6 | ||||
| -rw-r--r-- | addons/account/tests/test_tax.py | 21 |
2 files changed, 24 insertions, 3 deletions
diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 4630ece0eeb..02ff42a09f3 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -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 diff --git a/addons/account/tests/test_tax.py b/addons/account/tests/test_tax.py index 5b6361bf69c..df12bb1dd3a 100644 --- a/addons/account/tests/test_tax.py +++ b/addons/account/tests/test_tax.py @@ -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 |
