salix/modules/client/front/risk/index/index.js

66 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-10-19 06:40:32 +00:00
import ngModule from '../../module';
2018-11-14 09:55:15 +00:00
import './style.scss';
2018-10-19 06:40:32 +00:00
class Controller {
2019-01-14 16:26:59 +00:00
constructor($stateParams, $translate, $scope, $cookies) {
2018-11-14 09:55:15 +00:00
this.$ = $scope;
2018-10-19 06:40:32 +00:00
this.$stateParams = $stateParams;
2018-11-14 09:55:15 +00:00
this.$translate = $translate;
2019-01-14 16:26:59 +00:00
this.accessToken = $cookies.get('vnToken');
2018-11-14 09:55:15 +00:00
this.companyFk = window.localStorage.defaultCompanyFk;
2018-10-19 06:40:32 +00:00
this.filter = {
include: {
2018-11-14 09:55:15 +00:00
relation: 'company',
2018-10-19 06:40:32 +00:00
scope: {
2018-11-14 09:55:15 +00:00
fields: ['code'],
},
2018-10-19 06:40:32 +00:00
},
where: {
2018-11-14 09:55:15 +00:00
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;
2018-10-19 06:40:32 +00:00
}
2019-01-14 16:26:59 +00:00
onDownload() {
alert('Not implemented yet');
}
2018-10-19 06:40:32 +00:00
}
2019-01-14 16:26:59 +00:00
Controller.$inject = ['$stateParams', '$translate', '$scope', '$cookies'];
2018-10-19 06:40:32 +00:00
ngModule.component('vnClientRiskIndex', {
template: require('./index.html'),
2018-11-14 09:55:15 +00:00
controller: Controller,
2018-10-19 06:40:32 +00:00
});