fix(lottransfer): error in timing it would only allow for a 3min window

This commit is contained in:
2025-10-02 07:48:33 -05:00
parent 71713937c7
commit 7e1a93512b
2 changed files with 16 additions and 4 deletions

View File

@@ -55,7 +55,7 @@ export const consumeMaterial = async (data: Data) => {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}); });
//console.log(results);
const { data: commandL, error: ce } = await tryCatch( const { data: commandL, error: ce } = await tryCatch(
db.insert(commandLog).values({ db.insert(commandLog).values({
commandUsed: "consumeMaterial", commandUsed: "consumeMaterial",
@@ -68,6 +68,7 @@ export const consumeMaterial = async (data: Data) => {
status: results.status, status: results.status,
}; };
} catch (error: any) { } catch (error: any) {
console.log(error);
return { return {
success: false, success: false,
status: 200, status: 200,

View File

@@ -88,7 +88,7 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
// shift split // shift split
const shiftTimeSplit = shift?.data[0]?.shiftChange.split(":"); const shiftTimeSplit = shift?.data[0]?.shiftChange.split(":");
//console.log(shiftTimeSplit); console.log(parseInt(shiftTimeSplit[0]) - 1);
// Current time // Current time
const now = new Date(); const now = new Date();
@@ -97,12 +97,14 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
now.getFullYear(), now.getFullYear(),
now.getMonth(), now.getMonth(),
1, //now.getDate(), 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[0]) : 5, // this will parse the hour to remove teh zero
shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) + 3 : 3, shiftTimeSplit.length > 0 ? parseInt(shiftTimeSplit[1]) : 3,
0, 0,
0 0
); );
console.log("target", target.toLocaleString(), "Now", now.toLocaleString());
// to early time // to early time
const early = new Date( const early = new Date(
now.getFullYear(), now.getFullYear(),
@@ -114,6 +116,8 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
0 0
); );
console.log("early", early.toLocaleString(), "Now", now.toLocaleString());
// next month just to be here // next month just to be here
const nextMonth = new Date( const nextMonth = new Date(
now.getFullYear(), now.getFullYear(),
@@ -125,6 +129,13 @@ export const lotMaterialTransfer = async (data: NewLotData) => {
0 0
); );
console.log(
"nextMonth",
nextMonth.toLocaleString(),
"Now",
now.toLocaleString()
);
// console.log(early, target); // console.log(early, target);
// if we are to early return early only if we are sending over eom // if we are to early return early only if we are sending over eom
if (data.type === "eom" && (early > now || target < now)) { if (data.type === "eom" && (early > now || target < now)) {