summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/account/models/account_tax.py7
-rw-r--r--addons/account/tests/test_tax.py50
2 files changed, 56 insertions, 1 deletions
diff --git a/addons/account/models/account_tax.py b/addons/account/models/account_tax.py
index 19977d46831..d599d06f788 100644
--- a/addons/account/models/account_tax.py
+++ b/addons/account/models/account_tax.py
@@ -492,7 +492,12 @@ class AccountTax(models.Model):
incl_fixed_amount += tax_amount
# Avoid unecessary re-computation
cached_tax_amounts[i] = tax_amount
- if store_included_tax_total:
+ # In case of a zero tax, do not store the base amount since the tax amount will
+ # be zero anyway. Group and Python taxes have an amount of zero, so do not take
+ # them into account.
+ if store_included_tax_total and (
+ tax.amount or tax.amount_type not in ("percent", "division", "fixed")
+ ):
total_included_checkpoints[i] = base
store_included_tax_total = False
i -= 1
diff --git a/addons/account/tests/test_tax.py b/addons/account/tests/test_tax.py
index a038f9c272a..1964d626c96 100644
--- a/addons/account/tests/test_tax.py
+++ b/addons/account/tests/test_tax.py
@@ -124,6 +124,17 @@ class TestTaxCommon(AccountTestInvoicingCommon):
],
})
+ cls.tax_0_percent = cls.env['account.tax'].with_company(cls.company_data['company']).create({
+ 'name': "test_0_percent",
+ 'amount_type': 'percent',
+ 'amount': 0,
+ })
+
+ cls.tax_8_percent = cls.env['account.tax'].with_company(cls.company_data['company']).create({
+ 'name': "test_8_percent",
+ 'amount_type': 'percent',
+ 'amount': 8,
+ })
cls.tax_12_percent = cls.env['account.tax'].with_company(cls.company_data['company']).create({
'name': "test_12_percent",
'amount_type': 'percent',
@@ -828,6 +839,45 @@ class TestTax(TestTaxCommon):
res1
)
+ def test_rounding_tax_included_round_per_line_03(self):
+ ''' Test the rounding of a 8% and 0% price included tax in an invoice having 8 * 15.55 as line.
+ The decimal precision is set to 2.
+ '''
+ self.tax_0_percent.company_id.currency_id.rounding = 0.01
+ self.tax_0_percent.price_include = True
+ self.tax_8_percent.price_include = True
+
+ self.group_tax.children_tax_ids = [(6, 0, self.tax_0_percent.ids)]
+ self.group_tax_bis.children_tax_ids = [(6, 0, self.tax_8_percent.ids)]
+
+ res1 = (self.tax_8_percent | self.tax_0_percent).compute_all(15.55, quantity=8.0)
+ self._check_compute_all_results(
+ 124.40, # 'total_included'
+ 115.19, # 'total_excluded'
+ [
+ # base , amount
+ # -------------
+ (115.19, 9.21),
+ (115.19, 0.00),
+ # -------------
+ ],
+ res1
+ )
+
+ res2 = (self.tax_0_percent | self.tax_8_percent).compute_all(15.55, quantity=8.0)
+ self._check_compute_all_results(
+ 124.40, # 'total_included'
+ 115.19, # 'total_excluded'
+ [
+ # base , amount
+ # -------------
+ (115.19, 0.00),
+ (115.19, 9.21),
+ # -------------
+ ],
+ res2
+ )
+
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.