2019-10-31 11:43:04 +00:00
|
|
|
const Component = require(`${appPath}/core/component`);
|
2019-10-29 06:46:44 +00:00
|
|
|
const reportHeader = new Component('report-header');
|
|
|
|
const reportFooter = new Component('report-footer');
|
2019-03-05 13:59:18 +00:00
|
|
|
|
|
|
|
module.exports = {
|
2019-10-24 05:41:54 +00:00
|
|
|
name: 'receipt',
|
|
|
|
async serverPrefetch() {
|
|
|
|
this.client = await this.fetchClient(this.receiptId);
|
|
|
|
this.receipt = await this.fetchReceipt(this.receiptId);
|
2019-03-05 13:59:18 +00:00
|
|
|
|
2019-10-31 11:43:04 +00:00
|
|
|
if (!this.receipt)
|
|
|
|
throw new Error('Something went wrong');
|
2019-03-05 13:59:18 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2019-10-24 05:41:54 +00:00
|
|
|
fetchClient(receiptId) {
|
2020-09-28 11:54:02 +00:00
|
|
|
return this.findOneFromDef('client', [receiptId]);
|
2019-03-05 13:59:18 +00:00
|
|
|
},
|
2019-10-24 05:41:54 +00:00
|
|
|
fetchReceipt(receiptId) {
|
2020-09-28 11:54:02 +00:00
|
|
|
return this.findOneFromDef('receipt', [receiptId]);
|
2019-10-31 11:43:04 +00:00
|
|
|
}
|
2019-10-29 06:46:44 +00:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
'report-header': reportHeader.build(),
|
|
|
|
'report-footer': reportFooter.build()
|
2019-03-05 13:59:18 +00:00
|
|
|
},
|
2019-10-31 11:43:04 +00:00
|
|
|
props: {
|
|
|
|
receiptId: {
|
2022-01-17 11:44:43 +00:00
|
|
|
type: [Number, String],
|
2019-10-31 11:43:04 +00:00
|
|
|
required: true
|
|
|
|
}
|
|
|
|
}
|
2019-03-05 13:59:18 +00:00
|
|
|
};
|