[FIX] account: fix unreconciled amount on reconciliation widget
Try to reconcile a bank statement of 1000 to an invoice of 650 amount. The balance amount of 350 is missing on the resulting account.move and the bank amount is 650 instead of 1000. task: https://www.odoo.com/web#id=36342&view_type=form&model=project.task&action=333&active_id=967&menu_id=4720
This commit is contained in:
@@ -3,6 +3,8 @@ odoo.define('account.ReconciliationModel', function (require) {
|
||||
|
||||
var BasicModel = require('web.BasicModel');
|
||||
var field_utils = require('web.field_utils');
|
||||
var utils = require('web.utils');
|
||||
var session = require('web.session');
|
||||
var CrashManager = require('web.CrashManager');
|
||||
var core = require('web.core');
|
||||
var _t = core._t;
|
||||
@@ -579,7 +581,7 @@ var StatementModel = BasicModel.extend({
|
||||
}));
|
||||
}
|
||||
ids.push(line.id);
|
||||
values.push({
|
||||
var values_dict = {
|
||||
"partner_id": line.st_line.partner_id,
|
||||
"counterpart_aml_dicts": _.map(_.filter(props, function (prop) {
|
||||
return !isNaN(prop.id) && !prop.already_paid;
|
||||
@@ -590,7 +592,23 @@ var StatementModel = BasicModel.extend({
|
||||
"new_aml_dicts": _.map(_.filter(props, function (prop) {
|
||||
return isNaN(prop.id);
|
||||
}), self._formatToProcessReconciliation.bind(self, line)),
|
||||
});
|
||||
};
|
||||
// If the lines are not fully balanced, create an unreconciled amount.
|
||||
// line.st_line.currency_id is never false here because its equivalent to
|
||||
// statement_line.currency_id or statement_line.journal_id.currency_id or statement_line.journal_id.company_id.currency_id (Python-side).
|
||||
// see: get_statement_line_for_reconciliation_widget method in account/models/account_bank_statement.py for more details
|
||||
var currency = session.get_currency(line.st_line.currency_id);
|
||||
var balance = line.balance.amount;
|
||||
if (!utils.float_is_zero(balance, currency.digits)) {
|
||||
var unreconciled_amount_dict = {
|
||||
'account_id': line.st_line.open_balance_account_id,
|
||||
'credit': balance > 0 ? balance : 0,
|
||||
'debit': balance < 0 ? -balance : 0,
|
||||
'name': line.st_line.name + ' : ' + _t("Open balance"),
|
||||
};
|
||||
values_dict['new_aml_dicts'].push(unreconciled_amount_dict);
|
||||
}
|
||||
values.push(values_dict);
|
||||
line.reconciled = true;
|
||||
self.valuenow++;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user