41 lines
1.2 KiB
JavaScript
Executable File
41 lines
1.2 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.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-header': reportHeader.build(),
|
|
'report-footer': reportFooter.build()
|
|
},
|
|
props: {
|
|
reference: {
|
|
type: Number,
|
|
required: true,
|
|
description: 'The invoice ref'
|
|
}
|
|
}
|
|
};
|