build(notification): fixed fifo index ts errors

This commit is contained in:
2026-02-16 09:38:10 -06:00
parent 16edf58025
commit 29b3be41a1
2 changed files with 96 additions and 93 deletions

View File

@@ -1,7 +1,9 @@
import { OpenAPIHono } from "@hono/zod-openapi";
import { migrateAdjustments } from "./controller/siloAdjustments/migrateAdjustments.js";
import { getLanesToCycleCount } from "./controller/warehouse/cycleCountChecks/cyclecountCheck.js";
import attachSilo from "./route/attachSilo.js";
import bookOutPallet from "./route/bookout.js";
import comsumeMaterial from "./route/consumeMaterial.js";
import detachSilo from "./route/detachSilo.js";
import postBulkOrders from "./route/dm/bulkOrdersIn.js";
@@ -56,6 +58,7 @@ const routes = [
// logisitcs
removeAsNonReable,
getSSCC,
bookOutPallet,
] as const;
// app.route("/server", modules);

View File

@@ -1,21 +1,21 @@
import { isBefore } from "date-fns";
import { db } from "../../../../../database/dbclient.js";
import { fifoIndex } from "../../../../../database/schema/fifoIndex.js";
import { tryCatch } from "../../../../globalUtils/tryCatch.js";
import { query } from "../../../sqlServer/prodSqlServer.js";
import { currentInv } from "../../../sqlServer/querys/notifications/fifoIndex/currentInv.js";
import { shippedPallets } from "../../../sqlServer/querys/notifications/fifoIndex/shippedPallets.js";
import { db } from "../../../../../database/dbclient.js";
import { fifoIndex } from "../../../../../database/schema/fifoIndex.js";
export default async function fifoIndexCheck() {
/**
* getting the shipped pallets
*/
const { data: shipped, error: eShipped } = await tryCatch(
query(shippedPallets, "notify shipped pallets")
query(shippedPallets, "notify shipped pallets"),
);
const { data: currentStuff, error: eCurrentInv } = await tryCatch(
query(currentInv, "notify shipped pallets")
query(currentInv, "notify shipped pallets"),
);
// console.log(shipped?.data[2]);
@@ -24,14 +24,14 @@ export default async function fifoIndexCheck() {
/**
* We want to check if the each shippened pallet is out of fifo
*/
const check = shipped?.data.map((n: any) => {
const check: any = shipped?.data.map((n: any) => {
/**
* Returns all data so we know if we are in or out.
*/
//check if there are pallets older than the current one we are mapped on.
const fifoCheck = currentStuff?.data.filter(
(i: any) => isBefore(i.prodDate, n.prodDate) && i.av === n.av
);
(i: any) => isBefore(i.prodDate, n.prodDate) && i.av === n.av,
) as any;
//console.log(fifoCheck.length);
if (fifoCheck.length > 0) {
// console.log("Out of fifo", {
@@ -83,7 +83,7 @@ export default async function fifoIndexCheck() {
/**
* add the data to the db
*/
for (let i = 0; i < check.length; i++) {
for (let i = 0; i < check!.length; i++) {
const { data: dbInsert, error: dbE } = await tryCatch(
db
.insert(fifoIndex)
@@ -95,7 +95,7 @@ export default async function fifoIndexCheck() {
fifoFollowed: check[i].fifoFollowed,
add_Date: check[i].add_Date,
})
.onConflictDoNothing()
.onConflictDoNothing(),
);
}
@@ -105,7 +105,7 @@ export default async function fifoIndexCheck() {
data: {
palletsOut: check,
totalShipped: shipped?.data.length,
inFifo: shipped?.data.length - totalOut,
inFifo: shipped!.data.length - totalOut,
outOfFifoData: outOfFifo,
},
};