const Component = require(`vn-print/core/component`); const reportBody = new Component('report-body'); 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-body': reportBody.build(), 'report-footer': reportFooter.build() }, props: { id: { type: Number, required: true, description: 'Receipt id' } } };