44 lines
1.2 KiB
JavaScript
44 lines
1.2 KiB
JavaScript
|
const Component = require(`${appPath}/core/component`);
|
||
|
const emailHeader = new Component('email-header');
|
||
|
const emailFooter = new Component('email-footer');
|
||
|
const db = require(`${appPath}/core/database`);
|
||
|
|
||
|
module.exports = {
|
||
|
name: 'payment-update',
|
||
|
async serverPrefetch() {
|
||
|
this.client = await this.fetchClient(this.clientId);
|
||
|
|
||
|
if (!this.client)
|
||
|
throw new Error('Something went wrong');
|
||
|
},
|
||
|
computed: {
|
||
|
accountAddress: function() {
|
||
|
return this.iban.slice(-4);
|
||
|
},
|
||
|
},
|
||
|
methods: {
|
||
|
// Redmine #1854 Replace payMethodId by code
|
||
|
fetchClient(id) {
|
||
|
return db.findOne(
|
||
|
`SELECT
|
||
|
c.dueDay,
|
||
|
c.iban,
|
||
|
pm.id payMethodId,
|
||
|
pm.name payMethodName
|
||
|
FROM client c
|
||
|
JOIN payMethod pm ON pm.id = c.payMethodFk
|
||
|
JOIN account.user u ON u.id = c.id
|
||
|
WHERE c.id = :clientId`, {clientId: id});
|
||
|
}
|
||
|
},
|
||
|
components: {
|
||
|
'email-header': emailHeader.build(),
|
||
|
'email-footer': emailFooter.build()
|
||
|
},
|
||
|
props: {
|
||
|
clientId: {
|
||
|
required: true
|
||
|
}
|
||
|
}
|
||
|
};
|