refactor code
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-11-09 10:19:27 +01:00
parent 79e9edcee9
commit 574f2757f4
1 changed files with 8 additions and 8 deletions

View File

@ -63,6 +63,7 @@ module.exports = Self => {
}
let invoiceId;
let invoiceOut;
try {
const client = await models.Client.findById(args.clientId, {
fields: ['id', 'hasToInvoiceByAddress']
@ -119,25 +120,24 @@ module.exports = Self => {
await notifyFailures(ctx, failedClient, myOptions);
}
invoiceOut = await models.InvoiceOut.findById(invoiceId, {
include: {
relation: 'client'
}
}, myOptions);
if (tx) await tx.commit();
} catch (e) {
if (tx) await tx.rollback();
throw e;
}
const invoiceOut = await models.InvoiceOut.findById(invoiceId, {
include: {
relation: 'client'
}
});
ctx.args = {
reference: invoiceOut.ref,
recipientId: invoiceOut.clientFk,
recipient: invoiceOut.client().email
};
try {
await models.InvoiceOut.invoiceEmail(ctx);
} catch (err) {}
await models.InvoiceOut.invoiceEmail(ctx);
return invoiceId;
};