diff options
| author | Lucas Perais (lpe) <lpe@odoo.com> | 2017-07-26 11:44:51 +0200 |
|---|---|---|
| committer | qdp-odoo <qdp@odoo.com> | 2017-09-01 17:15:47 +0200 |
| commit | b6778ee752efe3b143786015f766933afac4273f (patch) | |
| tree | 0b8c2635e4c25797b8918ff0c238ec49ed9584cf /addons/web/static/src/js/framework | |
| parent | 4ca6945256f9353ab7f9633552872fd1fa7fdaca (diff) | |
[FIX] account: reconciliation_widget: rounding of reconciliation_amount computation
Use case:
- a tax of 10%, computation method: percentage of tax included
- a account_reconciliation_model with an amount of 90%
- make a statement of 1.31 (or something weird when it comes to digits)
- reconcile it with a counterpart
- prefill that counterpart with the account_reconciliation just created
- push on reconcile
Before this commit, the amount that was computed was not rounded, resulting in making unbalanced account_moves (by 0.001)
This was invisble since the display of monetary is rounded
After this commit, the rounding is done according to the currency's parameters and produces correct move_lines
OPW 751881
Diffstat (limited to 'addons/web/static/src/js/framework')
| -rw-r--r-- | addons/web/static/src/js/framework/utils.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/addons/web/static/src/js/framework/utils.js b/addons/web/static/src/js/framework/utils.js index e19246823c5..0dc66c6817f 100644 --- a/addons/web/static/src/js/framework/utils.js +++ b/addons/web/static/src/js/framework/utils.js @@ -350,6 +350,15 @@ function round_decimals (value, decimals) { return round_precision(value, Math.pow(10,-decimals)); } +/* Rounds a value according to a currency's digits + * @param {dict} The dict containing the currency's info, usually retrieved with session.get_currency + * @param {Number} The value to be rounded + */ +function round_currency(currency_dict, value) { + var digits = currency_dict && currency_dict.digits[1] || 4; + return round_decimals(value, digits); +} + function float_is_zero (value, decimals) { var epsilon = Math.pow(10, -decimals); return Math.abs(round_precision(value, epsilon)) < epsilon; @@ -516,6 +525,7 @@ return { human_number: human_number, round_precision: round_precision, round_decimals: round_decimals, + round_currency: round_currency, float_is_zero: float_is_zero, confine: confine, assert: assert, |
