diff options
| author | Nicolas Lempereur <nle@odoo.com> | 2021-05-17 14:57:45 +0000 |
|---|---|---|
| committer | Nicolas Lempereur <nle@odoo.com> | 2021-05-17 17:36:05 +0000 |
| commit | 23dd2ea535bea0a57dcac773a81e202135cd2ed6 (patch) | |
| tree | c973e8a95c080ffacde74c69570de266831c0432 /addons/point_of_sale/static/src/js | |
| parent | def7d7bb0231fef38e044803b245c9b990a90216 (diff) | |
[FIX] point_of_sale: rounding down near 0
Before 03025520b rounding applied was eg. for these numbers and UP and
DOWN rounding methods to multiple of 10:
```
Numbers | -8 | -2 | 2 | 8 | 12
DOWN | -2 | -8 | -2 | -8 | -2
UP | 8 | 2 | 8 | 2 | 8
```
which is correct for positive numbers but UP and DOWN are inversed for
negatives numbers.
After 03025520b this became:
```
Numbers | -8 | -2 | 2 | 8 | 12
DOWN | 8 | 2 | 8 | -8 | -2
UP | -2 | -8 | -2 | 2 | 8
```
which is correct for all cases except for positive numbers that are
before HALF of the precision (eg. number 2) for which UP and DOWN are
inversed.
This is happening because 03025520b uses the sign of the rounded value
=> this does not work for 0 so number 2 is broken (and if fixed number
-2 would be broken).
With this commit, the adjustement of sign is done based on original
number, so we get the equivalent of python equivalent methods:
```
Numbers | -8 | -2 | 2 | 8 | 12
DOWN | 8 | 2 | -2 | -8 | -2
UP | -2 | -8 | 8 | 2 | 8
```
opw-2451841
closes odoo/odoo#70910
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Diffstat (limited to 'addons/point_of_sale/static/src/js')
| -rw-r--r-- | addons/point_of_sale/static/src/js/models.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index a2cd058ac06..f2081eefd6d 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -3327,7 +3327,7 @@ exports.Order = Backbone.Model.extend({ if (!only_cash || (only_cash && last_line_is_cash)) { var remaining = this.get_total_with_tax() - this.get_total_paid(); var total = round_pr(remaining, this.pos.cash_rounding[0].rounding); - var sign = total > 0 ? 1.0 : -1.0; + var sign = remaining > 0 ? 1.0 : -1.0; var rounding_applied = total - remaining; rounding_applied *= sign; |
