salix/print/templates/reports/receipt/receipt.js

34 lines
905 B
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: 'receipt',
async serverPrefetch() {
this.client = await this.fetchClient(this.id);
this.receipt = await this.fetchReceipt(this.id);
if (!this.receipt)
throw new Error('Something went wrong');
},
methods: {
fetchClient(id) {
return this.findOneFromDef('client', [id]);
},
fetchReceipt(id) {
return this.findOneFromDef('receipt', [id]);
}
},
components: {
'report-header': reportHeader.build(),
'report-footer': reportFooter.build()
},
props: {
id: {
type: [Number, String],
required: true,
description: 'Receipt id'
}
}
};