salix/print/templates/reports/claim-pickup-order/claim-pickup-order.js

41 lines
1.0 KiB
JavaScript
Executable File

const Component = require(`vn-print/core/component`);
const reportBody = new Component('report-body');
const reportFooter = new Component('report-footer');
module.exports = {
name: 'claim-pickup-order',
async serverPrefetch() {
this.client = await this.fetchClient(this.id);
this.sales = await this.fetchSales(this.id);
if (!this.client)
throw new Error('Something went wrong');
},
computed: {
dated: function() {
const filters = this.$options.filters;
return filters.date(new Date(), '%d-%m-%Y');
}
},
methods: {
fetchClient(id) {
return this.findOneFromDef('client', [id]);
},
fetchSales(id) {
return this.rawSqlFromDef('sales', [id]);
}
},
components: {
'report-body': reportBody.build(),
'report-footer': reportFooter.build()
},
props: {
id: {
type: Number,
required: true,
description: 'The claim id'
}
}
};