diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 20a55452a10..b9a5c33414e 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -3399,8 +3399,8 @@ export class Order extends PosModel { var rounding_method = this.pos.cash_rounding[0].rounding_method; var remaining = this.get_total_with_tax() - this.get_total_paid(); var sign = this.get_total_with_tax() > 0 ? 1.0 : -1.0; - if(rounding_method !== "HALF-UP" && (this.get_total_with_tax() < 0 && remaining > 0 || this.get_total_with_tax() > 0 && remaining < 0)) { - rounding_method = rounding_method === "UP" ? "DOWN" : "UP"; + if(this.get_total_with_tax() < 0 && remaining > 0 || this.get_total_with_tax() > 0 && remaining < 0) { + rounding_method = rounding_method.endsWith("UP") ? "DOWN" : rounding_method; } remaining *= sign; diff --git a/addons/point_of_sale/static/tests/tours/PaymentScreen.tour.js b/addons/point_of_sale/static/tests/tours/PaymentScreen.tour.js index e7e15b579ca..03585fc5e1a 100644 --- a/addons/point_of_sale/static/tests/tours/PaymentScreen.tour.js +++ b/addons/point_of_sale/static/tests/tours/PaymentScreen.tour.js @@ -134,3 +134,41 @@ PaymentScreen.check.remainingIs('0.0'); PaymentScreen.check.changeIs('0.0'); registry.category("web_tour.tours").add('PaymentScreenRoundingDown', { test: true, url: '/pos/ui', steps: getSteps() }); + +startSteps(); + +ProductScreen.do.clickHomeCategory(); +ProductScreen.exec.addOrderline('Product Test 1.2', '1'); +ProductScreen.do.clickPayButton(); + +PaymentScreen.check.totalIs('1.00'); +PaymentScreen.do.clickPaymentMethod('Cash'); + +PaymentScreen.check.remainingIs('0.0'); +PaymentScreen.check.changeIs('0.0'); + +Chrome.do.clickTicketButton(); +TicketScreen.do.clickNewTicket(); + +ProductScreen.exec.addOrderline('Product Test 1.25', '1'); +ProductScreen.do.clickPayButton(); + +PaymentScreen.check.totalIs('1.5'); +PaymentScreen.do.clickPaymentMethod('Cash'); + +PaymentScreen.check.remainingIs('0.0'); +PaymentScreen.check.changeIs('0.0'); + +Chrome.do.clickTicketButton(); +TicketScreen.do.clickNewTicket(); + +ProductScreen.exec.addOrderline('Product Test 1.4', '1'); +ProductScreen.do.clickPayButton(); + +PaymentScreen.check.totalIs('1.5'); +PaymentScreen.do.clickPaymentMethod('Cash'); + +PaymentScreen.check.remainingIs('0.0'); +PaymentScreen.check.changeIs('0.0'); + +registry.category("web_tour.tours").add('PaymentScreenRoundingHalfUp', { test: true, url: '/pos/ui', steps: getSteps() }); diff --git a/addons/point_of_sale/tests/test_frontend.py b/addons/point_of_sale/tests/test_frontend.py index 47a9ad58085..20ead5c0fa1 100644 --- a/addons/point_of_sale/tests/test_frontend.py +++ b/addons/point_of_sale/tests/test_frontend.py @@ -633,3 +633,39 @@ class TestUi(TestPointOfSaleHttpCommon): self.main_pos_config.open_ui() self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenRoundingDown', login="accountman") + + def test_rounding_half_up(self): + rouding_method = self.env['account.cash.rounding'].create({ + 'name': 'Rounding HALF-UP', + 'rounding': 0.5, + 'rounding_method': 'HALF-UP', + }) + + self.env['product.product'].create({ + 'name': 'Product Test 1.2', + 'available_in_pos': True, + 'list_price': 1.2, + 'taxes_id': False, + }) + + self.env['product.product'].create({ + 'name': 'Product Test 1.25', + 'available_in_pos': True, + 'list_price': 1.25, + 'taxes_id': False, + }) + + self.env['product.product'].create({ + 'name': 'Product Test 1.4', + 'available_in_pos': True, + 'list_price': 1.4, + 'taxes_id': False, + }) + + self.main_pos_config.write({ + 'rounding_method': rouding_method.id, + 'cash_rounding': True, + }) + + self.main_pos_config.open_ui() + self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenRoundingHalfUp', login="accountman")