60 lines
1.8 KiB
JavaScript
Executable File
60 lines
1.8 KiB
JavaScript
Executable File
const database = require(`${appPath}/lib/database`);
|
|
const emailHeader = require('../email-header');
|
|
const emailFooter = require('../email-footer');
|
|
const UserException = require(`${appPath}/lib/exceptions/userException`);
|
|
|
|
module.exports = {
|
|
name: 'letter-debtor-nd',
|
|
async asyncData(ctx, params) {
|
|
const data = {
|
|
isPreview: ctx.method === 'GET',
|
|
};
|
|
|
|
if (!params.clientFk)
|
|
throw new UserException('No client id specified');
|
|
|
|
if (!params.companyFk)
|
|
throw new UserException('No company id specified');
|
|
|
|
return this.methods.fetchClientData(params.clientFk, params.companyFk)
|
|
.then(([result]) => {
|
|
return Object.assign(data, result[0]);
|
|
});
|
|
},
|
|
created() {
|
|
this.$i18n.locale = this.locale;
|
|
},
|
|
data() {
|
|
return {
|
|
attachments: ['http://localhost:8080/report/delivery-note'],
|
|
};
|
|
},
|
|
methods: {
|
|
fetchClientData(clientFk, companyFk) {
|
|
return database.pool.query(`
|
|
SELECT
|
|
u.lang locale,
|
|
c.email recipient,
|
|
c.dueDay,
|
|
c.iban,
|
|
sa.iban,
|
|
be.name AS bankName
|
|
FROM client c
|
|
JOIN company AS cny
|
|
JOIN supplierAccount AS sa ON sa.id = cny.supplierAccountFk
|
|
JOIN bankEntity be ON be.id = sa.bankEntityFk
|
|
JOIN account.user u ON u.id = c.id
|
|
WHERE c.id = ? AND cny.id = ?`, [clientFk, companyFk]);
|
|
},
|
|
},
|
|
computed: {
|
|
accountAddress: function() {
|
|
return this.iban.slice(-4);
|
|
},
|
|
},
|
|
components: {
|
|
'email-header': emailHeader,
|
|
'email-footer': emailFooter,
|
|
},
|
|
};
|