diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 9ff20fbc338..8274e6727b8 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -2329,11 +2329,18 @@ exports.Orderline = Backbone.Model.extend({ else var price_include = !price_exclude; if (tax.amount_type === 'fixed') { - 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); + // Use sign on base_amount and abs on quantity to take into account the sign of the base amount, + // which includes the sign of the quantity and the sign of the price_unit + // Amount is the fixed price for the tax, it can be negative + // Base amount included the sign of the quantity and the sign of the unit price and when + // a product is returned, it can be done either by changing the sign of quantity or by changing the + // sign of the price unit. + // When the price unit is equal to 0, the sign of the quantity is absorbed in base_amount then + // a "else" case is needed. + if (base_amount) + return Math.sign(base_amount) * Math.abs(quantity) * tax.amount; + else + return quantity * tax.amount; } if (tax.amount_type === 'percent' && !price_include){ return base_amount * tax.amount / 100;