From 92a9004d98a09caa8987f2ac658e63d5afb02c6b Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 19 Jan 2023 08:54:26 +0100 Subject: [PATCH] fix: borrada propiedad transaction cuando se hace commit --- .../back/methods/worker-time-control/sendMail.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index f86f61746..78c212e9b 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -161,8 +161,10 @@ module.exports = Self => { const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions); for (let day of days[index]) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; + if (!myOptions.transaction) { + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; + } try { workerFk = day.workerFk; if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null @@ -346,7 +348,10 @@ module.exports = Self => { previousReceiver = day.receiver; } - if (tx) await tx.commit(); + if (tx) { + await tx.commit(); + delete myOptions.transaction; + } } catch (e) { if (tx) await tx.rollback(); throw e;