salix/print/templates/reports/exportation/exportation.js

39 lines
1.0 KiB
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: 'exportation',
async serverPrefetch() {
this.invoice = await this.fetchInvoice(this.reference);
if (!this.invoice)
throw new Error('Something went wrong');
this.company = await this.findOneFromDef('company', [this.invoice.companyFk]);
},
methods: {
fetchInvoice(reference) {
return this.findOneFromDef('invoice', [reference]);
}
},
computed: {
issued: function() {
const filters = this.$options.filters;
return filters.date(this.invoice.issued, '%d-%m-%Y');
}
},
components: {
'report-header': reportHeader.build(),
'report-footer': reportFooter.build()
},
props: {
reference: {
type: Number,
required: true,
description: 'The invoice ref'
}
}
};