From 7e1a93512b96472513bed3f715cd16c1f616ab98 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 2 Oct 2025 07:48:33 -0500 Subject: [PATCH] fix(lottransfer): error in timing it would only allow for a 3min window --- .../controller/materials/consumeMaterial.ts | 3 ++- .../ocp/controller/materials/lotTransfer.ts | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lstV2/server/services/logistics/controller/materials/consumeMaterial.ts b/lstV2/server/services/logistics/controller/materials/consumeMaterial.ts index 417fe22..89cd69c 100644 --- a/lstV2/server/services/logistics/controller/materials/consumeMaterial.ts +++ b/lstV2/server/services/logistics/controller/materials/consumeMaterial.ts @@ -55,7 +55,7 @@ export const consumeMaterial = async (data: Data) => { "Content-Type": "application/json", }, }); - //console.log(results); + const { data: commandL, error: ce } = await tryCatch( db.insert(commandLog).values({ commandUsed: "consumeMaterial", @@ -68,6 +68,7 @@ export const consumeMaterial = async (data: Data) => { status: results.status, }; } catch (error: any) { + console.log(error); return { success: false, status: 200, diff --git a/lstV2/server/services/ocp/controller/materials/lotTransfer.ts b/lstV2/server/services/ocp/controller/materials/lotTransfer.ts index 69144c3..7bb23fa 100644 --- a/lstV2/server/services/ocp/controller/materials/lotTransfer.ts +++ b/lstV2/server/services/ocp/controller/materials/lotTransfer.ts @@ -88,7 +88,7 @@ export const lotMaterialTransfer = async (data: NewLotData) => { // shift split const shiftTimeSplit = shift?.data[0]?.shiftChange.split(":"); - //console.log(shiftTimeSplit); + console.log(parseInt(shiftTimeSplit[0]) - 1); // Current time const now = new Date(); @@ -97,12 +97,14 @@ export const lotMaterialTransfer = async (data: NewLotData) => { now.getFullYear(), now.getMonth(), 1, //now.getDate(), - shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[0]) - 1 : 5, // this will parse the hour to remove teh zero - shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) + 3 : 3, + shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[0]) : 5, // this will parse the hour to remove teh zero + shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) : 3, 0, 0 ); + console.log("target", target.toLocaleString(), "Now", now.toLocaleString()); + // to early time const early = new Date( now.getFullYear(), @@ -114,6 +116,8 @@ export const lotMaterialTransfer = async (data: NewLotData) => { 0 ); + console.log("early", early.toLocaleString(), "Now", now.toLocaleString()); + // next month just to be here const nextMonth = new Date( now.getFullYear(), @@ -125,6 +129,13 @@ export const lotMaterialTransfer = async (data: NewLotData) => { 0 ); + console.log( + "nextMonth", + nextMonth.toLocaleString(), + "Now", + now.toLocaleString() + ); + // console.log(early, target); // if we are to early return early only if we are sending over eom if (data.type === "eom" && (early > now || target < now)) {