[FIX] account: reconciliation widget: Don't loose pager on adding last line
Have a statement line with multiple pages of propositions Go to the last page Add everything Before this commit, after clicking on the last item of the list, a write-off creation was displayed, without any means to come back to the other propositions After this commit, we display the page before
This commit is contained in:
@@ -128,6 +128,20 @@ var StatementModel = BasicModel.extend({
|
||||
var line = this.getLine(handle);
|
||||
var prop = _.clone(_.find(line.mv_lines, {'id': mv_line_id}));
|
||||
this._addProposition(line, prop);
|
||||
|
||||
// Check whether we have some propositions left
|
||||
// If we don't, it means we are on an empty page
|
||||
// so let's go back to the previous page
|
||||
// Through the offset
|
||||
var propLineIds = _.map(line.reconciliation_proposition, function(prop) {
|
||||
return prop.id;
|
||||
});
|
||||
var leftOversProps = _.filter(line.mv_lines, function(mv_line) {
|
||||
return propLineIds.indexOf(mv_line.id) === -1;
|
||||
});
|
||||
if (line.offset && !leftOversProps.length) {
|
||||
line.offset -= line.limitMoveLines;
|
||||
}
|
||||
return $.when(this._computeLine(line), this._performMoveLine(handle));
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -1798,5 +1798,54 @@ QUnit.module('account', {
|
||||
|
||||
clientAction.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('Automatic Reconciliation: Don\'t loose pager when adding last line of a page', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
function standard_partner (list, partner_id) {
|
||||
_.each(list, function (item) {
|
||||
item.partner_id = partner_id;
|
||||
});
|
||||
};
|
||||
|
||||
this.params.options.params.limitMoveLines = 1;
|
||||
standard_partner(this.params.mv_lines['[5,"",0,6]'], 8);
|
||||
|
||||
// Overlap of those requests is normal
|
||||
// the pager is implemented as:
|
||||
// if there is at least 1 more line than my limit, the pager is active
|
||||
this.params.mv_lines['[5,"",0,2]'] = this.params.mv_lines['[5,"",0,6]'].slice(0,2);
|
||||
this.params.mv_lines['[5,"",1,2]'] = this.params.mv_lines['[5,"",0,6]'].slice(1,2);
|
||||
|
||||
var clientAction = new ReconciliationClientAction.StatementAction(null, this.params.options);
|
||||
testUtils.addMockEnvironment(clientAction, {
|
||||
data: this.params.data,
|
||||
session: {
|
||||
currencies: {
|
||||
3: {
|
||||
digits: [69, 2],
|
||||
position: "before",
|
||||
symbol: "$"
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
clientAction.appendTo($('#qunit-fixture'));
|
||||
|
||||
var widget = clientAction.widgets[0];
|
||||
|
||||
var $nextPage = widget.$('.match .match_controls .fa-chevron-right:not(disabled)');
|
||||
assert.ok($nextPage.length,
|
||||
'We should have a next page');
|
||||
$nextPage.click();
|
||||
|
||||
// Add the second's page record
|
||||
widget.$('.match tr[data-line-id=112] td:first').click();
|
||||
|
||||
assert.ok(widget.$('.match tr[data-line-id=109]').length,
|
||||
'the record of the first page must be proposed');
|
||||
|
||||
clientAction.destroy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user