[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
This commit is contained in:
committed by
qdp-odoo
parent
4ca6945256
commit
b6778ee752
@@ -763,7 +763,9 @@ var abstractReconciliationLine = Widget.extend({
|
||||
else if (preset_line.amount_type === "percentage") {
|
||||
self.amount_field.set_value(0);
|
||||
self.updateBalance();
|
||||
self.amount_field.set_value(-1 * self.get("balance") * preset_line.amount / 100);
|
||||
var currency_dict = session.get_currency(self.get("currency_id"));
|
||||
var preset_amount = utils.round_currency(currency_dict, -1 * self.get("balance") * preset_line.amount / 100);
|
||||
self.amount_field.set_value(preset_amount);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user