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

41 lines
1.2 KiB
JavaScript
Executable File

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