[FIX] point_of_sale: rounding error
- Set 'Product Unit of Measure' to 5 - Set the UoM rounding to 0.001 - Create an excluded tax of 6 % - Create a product costing 7.0 - Open the POS, add the product with a quantity of 0.535 The tax is 0.22 instead of 0.23. The root cause of the issue is the in JS: ``` round_pr(0.535, Math.pow(10,-5)) * 7 = 3.744999999999999 round_pr(0.535, 0.00001) * 7 = 3.745 ``` The numerical error impacts the tax computation later on. As a workaround, we round by the maximum between the UoM rounding and the 'Product Unit of Measure', which is what will be done in the backend anyway. opw-2205092 closes odoo/odoo#47372 X-original-commit: 125cdf96e94a94146804091ad47e701240c2529e Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
@@ -1517,9 +1517,9 @@ exports.Orderline = Backbone.Model.extend({
|
||||
var unit = this.get_unit();
|
||||
if(unit){
|
||||
if (unit.rounding) {
|
||||
this.quantity = round_pr(quant, unit.rounding);
|
||||
var decimals = this.pos.dp['Product Unit of Measure'];
|
||||
this.quantity = round_di(this.quantity, decimals)
|
||||
var rounding = Math.max(unit.rounding, Math.pow(10, -decimals));
|
||||
this.quantity = round_pr(quant, rounding);
|
||||
this.quantityStr = field_utils.format.float(this.quantity, {digits: [69, decimals]});
|
||||
} else {
|
||||
this.quantity = round_pr(quant, 1);
|
||||
|
||||
Reference in New Issue
Block a user