salix/print/templates/email/letter-debtor-st/letter-debtor-st.js

39 lines
1.0 KiB
JavaScript
Executable File

const Component = require(`vn-print/core/component`);
const emailHeader = new Component('email-header');
const emailFooter = new Component('email-footer');
const attachment = new Component('attachment');
const attachments = require('./attachments.json');
module.exports = {
name: 'letter-debtor-st',
async serverPrefetch() {
this.debtor = await this.fetchDebtor(this.id, this.companyId);
if (!this.debtor)
throw new Error('Something went wrong');
},
data() {
return {attachments};
},
methods: {
fetchDebtor(id, companyId) {
return this.findOneFromDef('client', [id, companyId]);
}
},
components: {
'email-header': emailHeader.build(),
'email-footer': emailFooter.build(),
'attachment': attachment.build()
},
props: {
id: {
type: [Number, String],
required: true
},
companyId: {
type: [Number, String],
required: true
},
}
};