From 340cbe3cde1954fdcb8ed6a50a8d3f011bc67de3 Mon Sep 17 00:00:00 2001 From: Robin Heinz Date: Tue, 25 May 2021 12:29:44 +0000 Subject: [PATCH] [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#71298 X-original-commit: bfccdf07adba35a5838a35a7bba98a1d71c67d2f 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 0992056dd19..20f01eb3b3c 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -3315,12 +3315,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 {