[FIX] account: reconciliation widget monetary values comparison
Since balance_end and balance_end_real are floats, they cannot be compared without rounding. Fixes #9957
This commit is contained in:
parent
dfb0e4b8f1
commit
2a68634dca
|
@ -33,6 +33,7 @@ openerp.account = function (instance) {
|
||||||
this.model_bank_statement = new instance.web.Model("account.bank.statement");
|
this.model_bank_statement = new instance.web.Model("account.bank.statement");
|
||||||
this.model_bank_statement_line = new instance.web.Model("account.bank.statement.line");
|
this.model_bank_statement_line = new instance.web.Model("account.bank.statement.line");
|
||||||
this.reconciliation_menu_id = false; // Used to update the needaction badge
|
this.reconciliation_menu_id = false; // Used to update the needaction badge
|
||||||
|
this.monetaryIsZero; // Method that tests if a monetary amount == 0 ; loaded from the server
|
||||||
this.formatCurrency; // Method that formats the currency ; loaded from the server
|
this.formatCurrency; // Method that formats the currency ; loaded from the server
|
||||||
|
|
||||||
// Only for statistical purposes
|
// Only for statistical purposes
|
||||||
|
@ -176,6 +177,14 @@ openerp.account = function (instance) {
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Get the function to compare monetary values
|
||||||
|
deferred_promises.push(new instance.web.Model("decimal.precision")
|
||||||
|
.call("precision_get", ["Account"])
|
||||||
|
.then(function(digits) {
|
||||||
|
self.monetaryIsZero = _.partial(instance.web.float_is_zero, _, digits);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
// Get statement lines
|
// Get statement lines
|
||||||
deferred_promises.push(self.model_bank_statement_line
|
deferred_promises.push(self.model_bank_statement_line
|
||||||
.query(['id'])
|
.query(['id'])
|
||||||
|
@ -288,7 +297,7 @@ openerp.account = function (instance) {
|
||||||
keyboardShortcutsHandler: function(e) {
|
keyboardShortcutsHandler: function(e) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if ((e.which === 13 || e.which === 10) && (e.ctrlKey || e.metaKey)) {
|
if ((e.which === 13 || e.which === 10) && (e.ctrlKey || e.metaKey)) {
|
||||||
self.persistReconciliations(_.filter(self.getChildren(), function(o) { return o.get("balance").toFixed(3) === "0.000"; }));
|
self.persistReconciliations(_.filter(self.getChildren(), function(o) { return self.monetaryIsZero(o.get("balance")); }));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -574,7 +583,7 @@ openerp.account = function (instance) {
|
||||||
.filter([['id', 'in', self.statement_ids]])
|
.filter([['id', 'in', self.statement_ids]])
|
||||||
.all()
|
.all()
|
||||||
.then(function(data){
|
.then(function(data){
|
||||||
if (_.all(data, function(o) { return o.balance_end_real === o.balance_end })) {
|
if (_.all(data, function(o) { return self.monetaryIsZero(o.balance_end_real - o.balance_end) })) {
|
||||||
self.$(".button_close_statement").show();
|
self.$(".button_close_statement").show();
|
||||||
self.$(".button_close_statement").click(function() {
|
self.$(".button_close_statement").click(function() {
|
||||||
self.$(".button_close_statement").attr("disabled", "disabled");
|
self.$(".button_close_statement").attr("disabled", "disabled");
|
||||||
|
@ -650,6 +659,7 @@ openerp.account = function (instance) {
|
||||||
this._super(parent);
|
this._super(parent);
|
||||||
|
|
||||||
this.formatCurrency = this.getParent().formatCurrency;
|
this.formatCurrency = this.getParent().formatCurrency;
|
||||||
|
this.monetaryIsZero = this.getParent().monetaryIsZero;
|
||||||
if (context.initial_data_provided) {
|
if (context.initial_data_provided) {
|
||||||
// Process data
|
// Process data
|
||||||
_.each(context.reconciliation_proposition, function(line) {
|
_.each(context.reconciliation_proposition, function(line) {
|
||||||
|
@ -1283,7 +1293,7 @@ openerp.account = function (instance) {
|
||||||
|
|
||||||
// Find out if the counterpart is lower than, equal or greater than the transaction being reconciled
|
// Find out if the counterpart is lower than, equal or greater than the transaction being reconciled
|
||||||
var balance_type = undefined;
|
var balance_type = undefined;
|
||||||
if (Math.abs(self.get("balance")).toFixed(3) === "0.000") balance_type = "equal";
|
if (self.monetaryIsZero(self.get("balance"))) balance_type = "equal";
|
||||||
else if (self.get("balance") * self.st_line.amount > 0) balance_type = "greater";
|
else if (self.get("balance") * self.st_line.amount > 0) balance_type = "greater";
|
||||||
else if (self.get("balance") * self.st_line.amount < 0) balance_type = "lower";
|
else if (self.get("balance") * self.st_line.amount < 0) balance_type = "lower";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue