From 298c23f0482b469333fb6dd43ee063bb75b6d964 Mon Sep 17 00:00:00 2001 From: rhe-odoo Date: Mon, 13 Dec 2021 11:42:23 +0000 Subject: [PATCH] [FIX] pos_cash_rounding: Fix value under rounding It should be allowed to pay amount that are not rounded if the value is less than the rounding value. Ex: Rounding value: 0.05 Amount to pay: 0.04 The amount to pay should remain 0.04 and not be rounded to 0.05. This fix allows the user to pay for values under the rounding value without applying the rounding. closes odoo/odoo#81392 X-original-commit: 523bc2f9b26bbb51ededcb734fa4ec384671575b Signed-off-by: Masereel Pierre --- addons/point_of_sale/static/src/js/models.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 01b43e9a513..5d5da0099d3 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -3588,8 +3588,9 @@ exports.Order = Backbone.Model.extend({ if (utils.float_is_zero(rounding_applied, this.pos.currency.decimals)){ // https://xkcd.com/217/ return 0; - } - else if(this.pos.cash_rounding[0].rounding_method === "UP" && rounding_applied < 0 && remaining > 0) { + } else if(this.get_total_with_tax() < this.pos.cash_rounding[0].rounding) { + return 0; + } else if(this.pos.cash_rounding[0].rounding_method === "UP" && rounding_applied < 0 && remaining > 0) { rounding_applied += this.pos.cash_rounding[0].rounding; } else if(this.pos.cash_rounding[0].rounding_method === "UP" && rounding_applied > 0 && remaining < 0) { @@ -3610,7 +3611,7 @@ exports.Order = Backbone.Model.extend({ return 0; }, has_not_valid_rounding: function() { - if(!this.pos.config.cash_rounding) + if(!this.pos.config.cash_rounding || this.get_total_with_tax() < this.pos.cash_rounding[0].rounding) return false; const only_cash = this.pos.config.only_round_cash_method; @@ -3641,6 +3642,8 @@ exports.Order = Backbone.Model.extend({ for(var id in this.get_paymentlines()) { var line = this.get_paymentlines()[id]; var diff = round_pr(round_pr(line.amount, cash_rounding) - round_pr(line.amount, default_rounding), default_rounding); + if(this.get_total_with_tax() < this.pos.cash_rounding[0].rounding) + return true; if(diff && line.payment_method.is_cash_count) { return false; } else if(!this.pos.config.only_round_cash_method && diff) {