From f85c8843c90046ba3029f0f395ba1aa6778792b6 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 3 Nov 2017 12:57:34 +0100 Subject: [PATCH 1/2] [FIX] account, point_of_sale: tax with fixed amount - Create a tax: Fixed amount: 10 Price included - Add it by default to a product costing 100 - In a SO/PO/Invoice, add 2 units of the product The total price is 210 instead of 200. opw-779696 --- addons/account/models/account.py | 2 +- addons/account/tests/test_tax.py | 16 ++++++++++++++++ addons/point_of_sale/static/src/js/models.js | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/addons/account/models/account.py b/addons/account/models/account.py index 2f9b3ee8bce..846cc9ea132 100644 --- a/addons/account/models/account.py +++ b/addons/account/models/account.py @@ -795,7 +795,7 @@ class AccountTax(models.Model): incl_fixed_amount = incl_percent_amount = 0 if tax.price_include: if tax.amount_type == 'fixed': - incl_fixed_amount += tax.amount + incl_fixed_amount += quantity * tax.amount elif tax.amount_type == 'percent': incl_percent_amount += tax.amount # Start the computation of accumulated amounts at the total_excluded value. diff --git a/addons/account/tests/test_tax.py b/addons/account/tests/test_tax.py index f688e5ba9be..a214b8f35f8 100644 --- a/addons/account/tests/test_tax.py +++ b/addons/account/tests/test_tax.py @@ -232,6 +232,22 @@ class TestTax(AccountTestUsers): res ) + self.fixed_tax.price_include = True + self.fixed_tax.include_base_amount = False + res = self.fixed_tax.compute_all(100.0, quantity=2.0) + self._check_compute_all_results( + 180, # 'base' + 200, # 'total_included' + 180, # 'total_excluded' + [ + # base , amount | seq | amount | incl | incl_base + # --------------------------------------------------- + (180.0, 20.0), # | 1 | 20 | | t + # --------------------------------------------------- + ], + res + ) + def test_tax_include_base_amount_2(self): self.percent_tax.price_include = True self.percent_tax.amount = 21.0 diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 1df0dd7e3a0..08a21541e52 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1434,7 +1434,7 @@ exports.Orderline = Backbone.Model.extend({ } if(tax.price_include){ if(tax.amount_type === 'fixed') - incl_fixed_amount += tax.amount; + incl_fixed_amount += quantity * tax.amount; else if(tax.amount_type === 'percent') incl_percent_amount += tax.amount; } From 6c996723b212b8ea85aa7b5d6e935d80e37b83a9 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 3 Nov 2017 13:16:15 +0100 Subject: [PATCH 2/2] [FIX] point_of_sale: wrong variable name `tax_amount` is not defined here, making it impossible to remove an order line... --- addons/point_of_sale/static/src/js/models.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 08a21541e52..ab6d7517d3e 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1450,7 +1450,7 @@ exports.Orderline = Backbone.Model.extend({ var amount = self._compute_all(tax, base, quantity, false); if(!tax.price_include || base_gaps.length == 0) - return tax_amount; + return amount; var new_gap = base_gaps[base_gaps.length - 1] - amount;