From 386bc1c9341451ae567dd6605205c0db8f07e47d Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 25 Mar 2024 13:00:55 +0100 Subject: [PATCH 1/2] refs #6276 hotFix: setUserError and return --- back/methods/machine-worker/updateInTime.js | 4 ++-- modules/ticket/back/methods/sale-tracking/setPicked.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/back/methods/machine-worker/updateInTime.js b/back/methods/machine-worker/updateInTime.js index 0dad9b897..44fad2c05 100644 --- a/back/methods/machine-worker/updateInTime.js +++ b/back/methods/machine-worker/updateInTime.js @@ -38,7 +38,7 @@ module.exports = Self => { }, myOptions); if (!machine) - throw new Error($t('the plate does not exist', {plate})); + throw new UserError($t('the plate does not exist', {plate})); const machineWorker = await Self.findOne({ where: { @@ -48,7 +48,7 @@ module.exports = Self => { }, myOptions); const {maxHours} = await models.MachineWorkerConfig.findOne({fields: ['maxHours']}, myOptions); - const hoursDifference = (Date.vnNow() - machineWorker?.inTimed?.getTime() ?? 0) / (60 * 60 * 1000); + const hoursDifference = (Date.vnNow() - machineWorker?.inTime?.getTime() ?? 0) / (60 * 60 * 1000); if (machineWorker) { const isHimself = userId == machineWorker.workerFk; diff --git a/modules/ticket/back/methods/sale-tracking/setPicked.js b/modules/ticket/back/methods/sale-tracking/setPicked.js index 70e516e9f..ed3656cf4 100644 --- a/modules/ticket/back/methods/sale-tracking/setPicked.js +++ b/modules/ticket/back/methods/sale-tracking/setPicked.js @@ -89,7 +89,7 @@ module.exports = Self => { const {itemOriginalFk} = await models.Buy.findById(buyFk, {fields: ['itemOriginalFk']}, myOptions); if (itemOriginalFk) await models.SaleBuy.create({saleFk, buyFk}, myOptions); } catch (e) { - if (tx) await tx.commit(); + if (tx) return tx.commit(); } if (tx) await tx.commit(); } catch (e) { From 2a1204a00aea872ac5e441b5d80e33264979e1a4 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Mon, 25 Mar 2024 13:27:52 +0100 Subject: [PATCH 2/2] refs #6276 hotFix: setUserError and return --- back/methods/machine-worker/specs/updateInTime.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/back/methods/machine-worker/specs/updateInTime.spec.js b/back/methods/machine-worker/specs/updateInTime.spec.js index ecb30b90b..f166214b0 100644 --- a/back/methods/machine-worker/specs/updateInTime.spec.js +++ b/back/methods/machine-worker/specs/updateInTime.spec.js @@ -122,7 +122,7 @@ describe('machineWorker updateInTime()', () => { expect(isNotParked.outTime).toBeNull(); expect(isParked.outTime).toBeDefined(); - expect(totalAfter.length).toEqual(totalBefore.length); + expect(totalAfter.length).toEqual(totalBefore.length + 1); await tx.rollback(); } catch (e) { await tx.rollback();