fix: borrada propiedad transaction cuando se hace commit

This commit is contained in:
Vicent Llopis 2023-01-19 08:54:26 +01:00
parent 38e4349e17
commit 92a9004d98
1 changed files with 8 additions and 3 deletions

View File

@ -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;