From dbd0e77e12c5f5fc0bc620dea0e01d2421d42557 Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 9 Nov 2022 09:14:32 +0100 Subject: [PATCH] feat: send mail with the invoice pdf --- .../back/methods/invoiceOut/invoiceClient.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js index ec3244344..c3ad9508a 100644 --- a/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js +++ b/modules/invoiceOut/back/methods/invoiceOut/invoiceClient.js @@ -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; };