feat: send mail with the invoice pdf
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-11-09 09:14:32 +01:00
parent 9bcfebcae6
commit dbd0e77e12
1 changed files with 15 additions and 3 deletions

View File

@ -109,9 +109,6 @@ module.exports = Self => {
if (newInvoice.id) {
await Self.rawSql('CALL invoiceOutBooking(?)', [newInvoice.id], myOptions);
query = `INSERT IGNORE INTO invoiceOutQueue(invoiceFk) VALUES(?)`;
await Self.rawSql(query, [newInvoice.id], myOptions);
invoiceId = newInvoice.id;
}
} catch (e) {
@ -128,6 +125,21 @@ module.exports = Self => {
throw e;
}
const invoiceOut = await models.InvoiceOut.findById(invoiceId, {
include: {
relation: 'client'
}
});
try {
ctx.args = {
reference: invoiceOut.ref,
recipientId: invoiceOut.clientFk,
recipient: invoiceOut.client().email
};
await models.InvoiceOut.invoiceEmail(ctx);
} catch (err) {}
return invoiceId;
};