summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2020-02-26 07:44:16 +0000
committerNicolas Martinelli <nim@odoo.com>2020-03-20 09:29:39 +0000
commiteeee58c7ac59dccde4ed9be4600f76fa3b7edd15 (patch)
treeee4e1308e90d2694e9cc618607f8121f792655fb
parent8a6b1ed9e0f20d80d1dbf4030157f2b5ba2d4a8f (diff)
[FIX] account, point_of_sale: incorrect rounding
- Create a 12% tax, price included - Create an invoice for a single product @ 52.50 The total is 52.51. This happens be cause the tax is computed on a non-rounded base amount. opw-2198712 closes odoo/odoo#48084 X-original-commit: f307c29160675583c1c40ccf0f4452c6a1461cbe Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
-rw-r--r--addons/account/tests/test_tax.py44
1 files changed, 39 insertions, 5 deletions
diff --git a/addons/account/tests/test_tax.py b/addons/account/tests/test_tax.py
index 465f96aa260..218b6c55c84 100644
--- a/addons/account/tests/test_tax.py
+++ b/addons/account/tests/test_tax.py
@@ -114,8 +114,20 @@ class TestTaxCommon(AccountTestInvoicingCommon):
],
})
+ cls.tax_12_percent = cls.env['account.tax'].with_company(cls.company_data['company']).create({
+ 'name': "test_12_percent",
+ 'amount_type': 'percent',
+ 'amount': 12,
+ })
+
cls.tax_19_percent = cls.env['account.tax'].with_company(cls.company_data_2['company']).create({
- 'name': "test_rounding_methods_1",
+ 'name': "test_19_percent",
+ 'amount_type': 'percent',
+ 'amount': 19,
+ })
+
+ cls.tax_21_percent = cls.env['account.tax'].with_company(cls.company_data['company']).create({
+ 'name': "test_21_percent",
'amount_type': 'percent',
'amount': 19,
})
@@ -669,11 +681,12 @@ class TestTax(TestTaxCommon):
tax.compute_all(-1.0)
)
- def test_rounding_tax_excluded_round_per_line(self):
+ def test_rounding_tax_excluded_round_per_line_01(self):
''' Test the rounding of a 19% price excluded tax in an invoice having 22689 and 9176 as lines.
The decimal precision is set to zero.
The computation must be similar to round(22689 * 0.19) + round(9176 * 0.19).
'''
+ self.tax_19_percent.company_id.currency_id.rounding = 1.0
self.tax_19_percent.company_id.tax_calculation_rounding_method = 'round_per_line'
res1 = self.tax_19_percent.compute_all(22689)
@@ -735,12 +748,13 @@ class TestTax(TestTaxCommon):
res2
)
- def test_rounding_tax_included_round_per_line(self):
+ def test_rounding_tax_included_round_per_line_01(self):
''' Test the rounding of a 19% price included tax in an invoice having 27000 and 10920 as lines.
The decimal precision is set to zero.
The computation must be similar to round(27000 / 1.19) + round(10920 / 1.19).
'''
self.tax_19_percent.price_include = True
+ self.tax_19_percent.company_id.currency_id.rounding = 1.0
self.tax_19_percent.company_id.tax_calculation_rounding_method = 'round_per_line'
res1 = self.tax_19_percent.compute_all(27000)
@@ -769,7 +783,27 @@ class TestTax(TestTaxCommon):
res2
)
- def test_rounding_tax_included_round_globally(self):
+ def test_rounding_tax_included_round_per_line_02(self):
+ ''' Test the rounding of a 12% price included tax in an invoice having 52.50 as line.
+ The decimal precision is set to 2.
+ '''
+ self.tax_12_percent.price_include = True
+ self.tax_12_percent.company_id.currency_id.rounding = 0.01
+
+ res1 = self.tax_12_percent.compute_all(52.50)
+ self._check_compute_all_results(
+ 52.50, # 'total_included'
+ 46.88, # 'total_excluded'
+ [
+ # base , amount
+ # -------------
+ (46.88, 5.62),
+ # -------------
+ ],
+ res1
+ )
+
+ def test_rounding_tax_included_round_globally_01(self):
''' Test the rounding of a 19% price included tax in an invoice having 27000 and 10920 as lines.
The decimal precision is set to zero.
The computation must be similar to round((27000 + 10920) / 1.19).
@@ -803,7 +837,7 @@ class TestTax(TestTaxCommon):
res2
)
- def test_rounding_tax_included_round_globally_01(self):
+ def test_rounding_tax_included_round_globally_02(self):
''' Test the rounding of a 21% price included tax in an invoice having 11.90 and 2.80 as lines.
The decimal precision is set to 2.
'''