[FIX] account: don't display alert in some cases

Before this commit, in the reconciliation widget, the reconciliation alert (exclamation mark) was displayed, even for amounts less than the total. It does not make sense, so we just hide it in that case.
This commit is contained in:
Christophe Matthieu
2017-04-25 10:00:48 +02:00
parent b25ba51e6f
commit f47775b039
3 changed files with 14 additions and 5 deletions
@@ -403,10 +403,10 @@ var StatementModel = BasicModel.extend({
togglePartialReconcile: function (handle) {
var line = this.getLine(handle);
var props = _.filter(line.reconciliation_proposition, {'invalid': false});
if (props.length !== 1) {
var prop = props[0];
if (props.length !== 1 || Math.abs(line.st_line.amount) >= Math.abs(prop.amount)) {
return $.Deferred().reject();
}
var prop = props[0];
prop.partial_reconcile = !prop.partial_reconcile;
if (!prop.partial_reconcile) {
return this._computeLine(line);
@@ -303,7 +303,11 @@ var LineRenderer = Widget.extend(FieldManagerMixin, {
.attr("data-content", qweb.render('reconciliation.line.mv_line.details', {'line': line}));
}
if ((state.balance.amount !== 0 || line.partial_reconcile) && props.length === 1) {
if ((state.balance.amount !== 0 || line.partial_reconcile) && props.length === 1 &&
(
(state.st_line.amount > 0 && state.st_line.amount < props[0].amount) ||
(state.st_line.amount < 0 && state.st_line.amount > props[0].amount))
) {
var $cell = $line.find(line.amount > 0 ? '.cell_right' : '.cell_left');
var text;
if (line.partial_reconcile) {
@@ -599,7 +599,7 @@ QUnit.module('account', {
QUnit.test('Reconciliation partial', function (assert) {
assert.expect(9);
assert.expect(10);
var clientAction = new ReconciliationClientAction.StatementAction(null, this.params.options);
testUtils.addMockEnvironment(clientAction, {
@@ -627,7 +627,12 @@ QUnit.module('account', {
clientAction.appendTo($('body'));
var widget = clientAction.widgets[1];
var widget = clientAction.widgets[0];
widget.$('.match .cell_account_code:first').trigger('click');
assert.notOk( widget.$('.cell_right .line_info_button').length, "should not display the partial reconciliation alert");
widget = clientAction.widgets[1];
assert.notOk( widget.$('.cell_left .line_info_button').length, "should not display the partial reconciliation alert");
widget.$('.accounting_view thead td:first').trigger('click');