salix/print/templates/reports/invoice-incoterms/invoice-incoterms.js

41 lines
1.1 KiB
JavaScript
Executable File

const Component = require(`vn-print/core/component`);
const reportHeader = new Component('report-header');
const reportFooter = new Component('report-footer');
module.exports = {
name: 'invoice-incoterms',
async serverPrefetch() {
this.invoice = await this.fetchInvoice(this.ref);
this.client = await this.fetchClient(this.ref);
this.incoterms = await this.fetchIncoterms(this.ref);
if (!this.invoice)
throw new Error('Something went wrong');
},
computed: {
},
methods: {
fetchInvoice(ref) {
return this.findOneFromDef('invoice', [ref]);
},
fetchClient(ref) {
return this.findOneFromDef('client', [ref]);
},
fetchIncoterms(ref) {
return this.findOneFromDef('incoterms', [ref, ref, ref]);
}
},
components: {
'report-header': reportHeader.build(),
'report-footer': reportFooter.build()
},
props: {
ref: {
type: [Number, String],
required: true,
description: 'The invoice ref'
}
}
};