import ngModule from '../module'; import Descriptor from 'salix/components/descriptor'; class Controller extends Descriptor { get supplier() { return this.entity; } set supplier(value) { this.entity = value; } get entryFilter() { if (!this.supplier) return null; const date = Date.vnNew(); date.setHours(0, 0, 0, 0); const from = new Date(date.getTime()); from.setDate(from.getDate() - 10); const to = new Date(date.getTime()); to.setDate(to.getDate() + 10); return JSON.stringify({ supplierFk: this.id, from, to }); } loadData() { const filter = { fields: [ 'id', 'name', 'nickname', 'nif', 'payMethodFk', 'payDemFk', 'payDay', 'isActive', 'isReal', 'isTrucker', 'account' ], include: [ { relation: 'payMethod', scope: { fields: ['id', 'name'] } }, { relation: 'payDem', scope: { fields: ['id', 'payDem'] } }, { relation: 'client', scope: { fields: ['id', 'fi'] } } ] }; return this.getData(`Suppliers/${this.id}`, {filter}) .then(res => this.supplier = res.data); } } ngModule.vnComponent('vnSupplierDescriptor', { template: require('./index.html'), controller: Controller, bindings: { supplier: '<' } });