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

69 lines
1.8 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 {
constructor($stateParams, $translate, $scope, vnToken) {
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 = vnToken.token;
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,
2019-01-25 07:50:13 +00:00
companyFk: this.companyFk
2018-11-14 09:55:15 +00:00
},
};
this.params = {
params: {
clientFk: this.$stateParams.id,
companyFk: this.companyFk,
},
};
}
setOrder(value) {
this.params.params.companyFk = value;
2019-01-25 07:50:13 +00:00
this.filter.where.companyFk = value;
2018-11-14 09:55:15 +00:00
this.$.model.refresh();
2019-01-25 07:50:13 +00:00
this.$.riskModel.refresh();
2018-11-14 09:55:15 +00:00
}
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
}
Controller.$inject = ['$stateParams', '$translate', '$scope', 'vnToken'];
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
});