From 59c663ae4252d140d83662e63ee4b6562a98e962 Mon Sep 17 00:00:00 2001 From: "Lucas Perais (lpe)" Date: Wed, 3 Jul 2019 11:32:13 +0000 Subject: [PATCH] [FIX] point_of_sale: correct compute fixed tax negative quantity Have a product with a fixed amount tax. Make a "return" of that product in the pos (i.e. negative quantity) Before this commit: - The amount of the return was `tax_amount + product_amount` instead of `-1 * positive_total_amount` - The amount differed from what can be observed in sales This was because the sign of the quantity was applied twice After this commit,: - the amounts of positive and negative amounts are symmetrical - they match the behavior in sale The logic is very similar to bb72dea98de4dae8f59e397f232a0636411d37ce OPW 2026278 closes odoo/odoo#34548 Signed-off-by: Lucas Perais (lpe) --- addons/point_of_sale/static/src/js/models.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 34a47c689fb..0904a8e242a 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1706,8 +1706,11 @@ exports.Orderline = Backbone.Model.extend({ }, _compute_all: function(tax, base_amount, quantity) { if (tax.amount_type === 'fixed') { - var sign_base_amount = base_amount >= 0 ? 1 : -1; - return (Math.abs(tax.amount) * sign_base_amount) * quantity; + var sign_base_amount = Math.sign(base_amount) || 1; + // Since base amount has been computed with quantity + // we take the abs of quantity + // Same logic as bb72dea98de4dae8f59e397f232a0636411d37ce + return tax.amount * sign_base_amount * Math.abs(quantity); } if ((tax.amount_type === 'percent' && !tax.price_include) || (tax.amount_type === 'division' && tax.price_include)){ return base_amount * tax.amount / 100;