46 lines
1.2 KiB
JavaScript
Executable File
46 lines
1.2 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');
|
|
|
|
module.exports = {
|
|
name: 'letter-debtor-nd',
|
|
async serverPrefetch() {
|
|
this.debtor = await this.fetchDebtor(this.id, this.companyId);
|
|
|
|
if (!this.debtor)
|
|
throw new Error('Something went wrong');
|
|
},
|
|
data() {
|
|
return {
|
|
attachments: [
|
|
{
|
|
filename: 'letter-debtor.pdf',
|
|
type: 'pdf',
|
|
path: `Clients/${this.id}/letter-debtor-pdf`
|
|
}
|
|
]
|
|
};
|
|
},
|
|
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,
|
|
required: true
|
|
},
|
|
companyId: {
|
|
type: Number,
|
|
required: true
|
|
}
|
|
}
|
|
};
|