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;