From beeebbdf9c7522e7f9eaf1519001e815780ba313 Mon Sep 17 00:00:00 2001 From: vicent Date: Thu, 24 Aug 2023 09:33:58 +0200 Subject: [PATCH] =?UTF-8?q?refs=20#6013=20refactor:=20siempre=20se=20crea?= =?UTF-8?q?=20una=20tranacci=C3=B3n=20para=20cada=20dia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../back/methods/worker-time-control/sendMail.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/modules/worker/back/methods/worker-time-control/sendMail.js b/modules/worker/back/methods/worker-time-control/sendMail.js index 4988d1f46..66fb7cc23 100644 --- a/modules/worker/back/methods/worker-time-control/sendMail.js +++ b/modules/worker/back/methods/worker-time-control/sendMail.js @@ -180,10 +180,8 @@ module.exports = Self => { const workerTimeControlConfig = await models.WorkerTimeControlConfig.findOne(null, myOptions); for (let day of days[index]) { - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } + tx = await Self.beginTransaction({}); + myOptions.transaction = tx; try { workerFk = day.workerFk; if (day.timeWorkDecimal > 0 && day.timeWorkedDecimal == null @@ -368,10 +366,7 @@ module.exports = Self => { previousReceiver = day.receiver; } - if (tx) { - await tx.commit(); - delete myOptions.transaction; - } + if (tx) await tx.commit(); } catch (e) { const stmts = []; let stmt; @@ -394,7 +389,6 @@ module.exports = Self => { previousReceiver = day.receiver; if (tx) await tx.rollback(); - delete myOptions.transaction; continue; }