[FIX] point_of_sale: correctly round total due in payment screen

Current behavior:
When you make a purchase that should be rounded down, for example 1.97
rounded down to 1.95. On the payment screen if you select a payment
method and pay with a greater amount than the base amount. The total due
would be rounded incorrectly to 2.00 instead of 1.95.

Steps to reproduce:
- Create a product with a price of 1.97
- Set a rouding down method of 0.05
- Open a pos session
- Add the product to the order
- Select a payment method, for example cash and enter an amount greater
  than the base amount, for example 5.00
- The total due will be 2.00 instead of 1.95

opw-3175726

closes odoo/odoo#114427

X-original-commit: 45994a5f8b3f87c46e39c260183663023d51e080
Signed-off-by: Heinz Robin (rhe) <rhe@odoo.com>
Signed-off-by: Engels Robin (roen) <roen@odoo.com>
This commit is contained in:
roen-odoo
2023-03-14 12:24:00 +01:00
parent b03cfce033
commit 4df87cf10f
4 changed files with 27 additions and 1 deletions
+1 -1
View File
@@ -3711,7 +3711,7 @@ export class Order extends PosModel {
(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;
rounding_method = rounding_method.endsWith("UP") ? "DOWN" : "UP";
}
remaining *= sign;
@@ -172,3 +172,19 @@ PaymentScreen.check.remainingIs('0.0');
PaymentScreen.check.changeIs('0.0');
registry.category("web_tour.tours").add('PaymentScreenRoundingHalfUp', { test: true, url: '/pos/ui', steps: getSteps() });
startSteps();
ProductScreen.do.clickHomeCategory();
ProductScreen.exec.addOrderline('Product Test', '1');
ProductScreen.do.clickPayButton();
PaymentScreen.check.totalIs('1.95');
PaymentScreen.exec.pay('Cash', '5');
PaymentScreen.check.remainingIs('0.0');
PaymentScreen.check.changeIs('3.05');
PaymentScreen.check.totalDueIs('1.95');
Chrome.do.clickTicketButton();
registry.category("web_tour.tours").add('PaymentScreenTotalDueWithOverPayment', { test: true, url: '/pos/ui', steps: getSteps() });
@@ -194,6 +194,15 @@ class Check {
},
];
}
totalDueIs(amount) {
return [
{
content: `total due is ${amount}`,
trigger: `.payment-status-total-due:contains("${amount}")`,
run: () => {},
},
];
}
}
class Execute {
@@ -633,6 +633,7 @@ 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")
self.start_tour("/pos/ui?config_id=%d" % self.main_pos_config.id, 'PaymentScreenTotalDueWithOverPayment', login="accountman")
def test_rounding_half_up(self):
rouding_method = self.env['account.cash.rounding'].create({