60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
import ngModule from '../../module';
|
|
import './style.scss';
|
|
|
|
class Controller {
|
|
constructor($stateParams, $translate, $scope) {
|
|
this.$ = $scope;
|
|
this.$stateParams = $stateParams;
|
|
this.$translate = $translate;
|
|
this.companyFk = window.localStorage.defaultCompanyFk;
|
|
this.filter = {
|
|
include: {
|
|
relation: 'company',
|
|
scope: {
|
|
fields: ['code'],
|
|
},
|
|
},
|
|
where: {
|
|
clientFk: $stateParams.id,
|
|
},
|
|
};
|
|
this.params = {
|
|
params: {
|
|
clientFk: this.$stateParams.id,
|
|
companyFk: this.companyFk,
|
|
},
|
|
};
|
|
}
|
|
setOrder(value) {
|
|
this.params.params.companyFk = value;
|
|
this.$.model.refresh();
|
|
}
|
|
|
|
set risks(value) {
|
|
if (value) {
|
|
for (let i = this.$.model.data.length - 1; i >= 0; i--) {
|
|
let row = this.$.model.data[i];
|
|
let tot;
|
|
if (i != this.$.model.data.length - 1)
|
|
row.balance = (row.credit - row.debit) + (this.$.model.data[i + 1].balance);
|
|
else
|
|
row.balance = row.credit - row.debit;
|
|
|
|
tot = tot + row.balance;
|
|
}
|
|
this._risks = this.$.model.data;
|
|
}
|
|
}
|
|
|
|
get risks() {
|
|
return this._risks;
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$stateParams', '$translate', '$scope'];
|
|
|
|
ngModule.component('vnClientRiskIndex', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
});
|