2121 - Client balance fix balance on pagination
gitea/salix/2121-client_balance_fix This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-02-17 08:38:19 +01:00
parent 6fe7106e4b
commit 578556b1d5
3 changed files with 58 additions and 4 deletions

View File

@ -85,9 +85,9 @@
</span>
</vn-td>
<vn-td number>{{::balance.bankFk}}</vn-td>
<vn-td number>{{::balance.debit | currency: 'EUR':2}}</vn-td>
<vn-td number>{{::balance.credit | currency: 'EUR':2}}</vn-td>
<vn-td number>{{balance.balance | currency: 'EUR':2}}</vn-td>
<vn-td number expand>{{::balance.debit | currency: 'EUR':2}}</vn-td>
<vn-td number expand>{{::balance.credit | currency: 'EUR':2}}</vn-td>
<vn-td number expand>{{balance.balance | currency: 'EUR':2}}</vn-td>
<vn-td center shrink>
<vn-check
ng-model="balance.isConciliate"

View File

@ -7,7 +7,6 @@ class Controller {
this.$ = $scope;
this.$stateParams = $stateParams;
this.$translate = $translate;
this.accessToken = vnToken.token;
this.vnConfig = vnConfig;
this.filter = {
@ -33,6 +32,18 @@ class Controller {
if (value) this.getData();
}
get balances() {
return this._balances;
}
set balances(value) {
this._balances = value;
const riskModel = this.$.riskModel;
if (value && riskModel.data)
this.getBalances();
}
getData() {
return this.$.model.applyFilter(null, {
clientId: this.$stateParams.id,

View File

@ -97,5 +97,48 @@ describe('Client', () => {
expect(expectedBalances[2].balance).toEqual(213.24);
});
});
describe('balances() setter', () => {
it('should set the balances data and not call the getBalances() method', () => {
spyOn(controller, 'getBalances');
controller.$.riskModel.data = null;
controller.balances = [{
id: 1,
debit: 1000,
credit: null
}, {
id: 2,
debit: null,
credit: 500
}, {
id: 3,
debit: null,
credit: 300
}];
expect(controller.balances).toBeDefined();
expect(controller.getBalances).not.toHaveBeenCalledWith();
});
it('should set the balances data and then call the getBalances() method', () => {
spyOn(controller, 'getBalances');
controller.balances = [{
id: 1,
debit: 1000,
credit: null
}, {
id: 2,
debit: null,
credit: 500
}, {
id: 3,
debit: null,
credit: 300
}];
expect(controller.balances).toBeDefined();
expect(controller.getBalances).toHaveBeenCalledWith();
});
});
});
});