[FIX] point_of_sale: rouding half up gives wrong value
To Reproduce ============ - set cash rounding method to half-up with a value (1 for example) - create a product available on pos with price (1.61$ in my example) - on pos select this product and proceed to payment with cash - with 2$ cash the total will be 1$ and change 1$ which is wrong Problem ======= - the function responsible on applying the rounding method doesn't take into account the rounding method `"HALF-UP"` Solution ======== - update the function to apply `"HALF-UP"` correctly opw-3143698 closes odoo/odoo#111930 X-original-commit: 092b3d5637a02786baa75255eb29b554a5d9f8b8 Signed-off-by: abla001 <abla@odoo.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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() });
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user