80 lines
2.1 KiB
JavaScript
80 lines
2.1 KiB
JavaScript
import ngModule from '../../module';
|
|
import './style.scss';
|
|
|
|
class Controller {
|
|
constructor($stateParams, $translate, $scope, vnToken) {
|
|
this.$ = $scope;
|
|
this.$stateParams = $stateParams;
|
|
this.$translate = $translate;
|
|
|
|
this.accessToken = vnToken.token;
|
|
this.companyFk = window.localStorage.defaultCompanyFk;
|
|
this.filter = {
|
|
include: {
|
|
relation: 'company',
|
|
scope: {
|
|
fields: ['code'],
|
|
},
|
|
},
|
|
where: {
|
|
clientFk: $stateParams.id,
|
|
companyFk: this.companyFk
|
|
},
|
|
};
|
|
this.params = {
|
|
params: {
|
|
clientFk: this.$stateParams.id,
|
|
companyFk: this.companyFk,
|
|
},
|
|
};
|
|
}
|
|
setOrder(value) {
|
|
this.params.params.companyFk = value;
|
|
this.filter.where.companyFk = value;
|
|
}
|
|
|
|
refresh() {
|
|
this.$.model.refresh();
|
|
this.$.riskModel.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;
|
|
}
|
|
|
|
openCreateDialog() {
|
|
this.$.riskCreateDialog.companyFk = this.companyFk;
|
|
this.$.riskCreateDialog.onResponse = () => {
|
|
this.refresh();
|
|
};
|
|
this.$.riskCreateDialog.show();
|
|
}
|
|
|
|
onDownload() {
|
|
alert('Not implemented yet');
|
|
}
|
|
}
|
|
|
|
Controller.$inject = ['$stateParams', '$translate', '$scope', 'vnToken'];
|
|
|
|
ngModule.component('vnClientRiskIndex', {
|
|
template: require('./index.html'),
|
|
controller: Controller,
|
|
});
|