From bfccdf07adba35a5838a35a7bba98a1d71c67d2f Mon Sep 17 00:00:00 2001 From: Robin Heinz Date: Tue, 25 May 2021 12:29:44 +0000 Subject: [FIX] point_of_sale: Fix down/up rounding While using the cash rounding, there were issues when rounding up and down. The pre filled amount was correct but the rest of the transaction was wrong. (Wrong due, wrong change,...) This commit re calculate the rounding applied when using up or down payment. closes odoo/odoo#71219 Signed-off-by: pimodoo --- addons/point_of_sale/static/src/js/models.js | 11 +++++++++-- 1 file changed, 9 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 62424ef80ef..a5cae7702c6 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -3333,12 +3333,19 @@ 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) { + } + 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 === "DOWN" && rounding_applied > 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 === "DOWN" && rounding_applied > 0 && remaining > 0){ rounding_applied -= this.pos.cash_rounding[0].rounding; } + else if(this.pos.cash_rounding[0].rounding_method === "DOWN" && rounding_applied < 0 && remaining < 0){ + rounding_applied += this.pos.cash_rounding[0].rounding; + } return sign * rounding_applied; } else { -- cgit v1.2.3