const vnReport = require('../../../core/mixins/vn-report.js'); const UserError = require('vn-loopback/util/user-error'); module.exports = { name: 'invoice-incoterms', mixins: [vnReport], async serverPrefetch() { this.invoice = await this.findOneFromDef('invoice', [this.reference]); this.checkMainEntity(this.invoice); this.client = await this.findOneFromDef('client', [this.reference]); this.incoterms = await this.findOneFromDef('incoterms', [this.reference, this.reference, this.reference, this.reference]); if (!this.incoterms) throw new UserError(`The address of the customer must have information about Incoterms and Customs Agent`); }, props: { reference: { type: String, required: true, description: 'The invoice ref' } } };