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

40 lines
1.1 KiB
JavaScript
Executable File

const Component = require(`${appPath}/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.invoiceId);
this.client = await this.fetchClient(this.invoiceId);
this.incoterms = await this.fetchIncoterms(this.invoiceId);
if (!this.invoice)
throw new Error('Something went wrong');
},
computed: {
},
methods: {
fetchInvoice(invoiceId) {
return this.findOneFromDef('invoice', [invoiceId]);
},
fetchClient(invoiceId) {
return this.findOneFromDef('client', [invoiceId]);
},
fetchIncoterms(invoiceId) {
return this.findOneFromDef('incoterms', {invoiceId});
}
},
components: {
'report-header': reportHeader.build(),
'report-footer': reportFooter.build()
},
props: {
invoiceId: {
type: String,
required: true
}
}
};