diff options
| author | Nicolas Martinelli <nim@odoo.com> | 2020-03-10 14:08:53 +0000 |
|---|---|---|
| committer | Nicolas Martinelli <nim@odoo.com> | 2020-03-11 11:06:11 +0000 |
| commit | 4aa7e101a90f2281e581389e7c24909dd35fb00f (patch) | |
| tree | ad8f270fb6cce3ec5d980348a212e54df5a704c5 /addons/point_of_sale/static/src/js/models.js | |
| parent | 8ec70c9072ccd3b49b4b0c3cd7cdf22fb21cd4af (diff) | |
[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>
Diffstat (limited to 'addons/point_of_sale/static/src/js/models.js')
| -rw-r--r-- | addons/point_of_sale/static/src/js/models.js | 4 |
1 files changed, 2 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 b3c832cc794..12c488793d0 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -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); |
