Merge branch '2121-client_balance_fix' of verdnatura/salix into dev
gitea/salix/dev This commit looks good Details

This commit is contained in:
Bernat Exposito 2020-02-17 12:09:20 +00:00 committed by Gitea
commit f24c49fbcd
3 changed files with 58 additions and 4 deletions

View File

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

View File

@ -7,7 +7,6 @@ class Controller {
this.$ = $scope; this.$ = $scope;
this.$stateParams = $stateParams; this.$stateParams = $stateParams;
this.$translate = $translate; this.$translate = $translate;
this.accessToken = vnToken.token; this.accessToken = vnToken.token;
this.vnConfig = vnConfig; this.vnConfig = vnConfig;
this.filter = { this.filter = {
@ -33,6 +32,18 @@ class Controller {
if (value) this.getData(); 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() { getData() {
return this.$.model.applyFilter(null, { return this.$.model.applyFilter(null, {
clientId: this.$stateParams.id, clientId: this.$stateParams.id,

View File

@ -97,5 +97,48 @@ describe('Client', () => {
expect(expectedBalances[2].balance).toEqual(213.24); 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();
});
});
}); });
}); });