import ngModule from '../../module'; import './style.scss'; class Controller { constructor($stateParams, $translate, $scope, $cookies) { this.$ = $scope; this.$stateParams = $stateParams; this.$translate = $translate; this.accessToken = $cookies.get('vnToken'); 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; } onDownload() { alert('Not implemented yet'); } } Controller.$inject = ['$stateParams', '$translate', '$scope', '$cookies']; ngModule.component('vnClientRiskIndex', { template: require('./index.html'), controller: Controller, });