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

32 lines
881 B
JavaScript
Executable File

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