feat(ocme): cycle count added to db will add to front end later for users to inspect

This commit is contained in:
2025-04-14 22:17:51 -05:00
parent 26798ca140
commit fbc2282aee
3 changed files with 89 additions and 49 deletions

View File

@@ -3,6 +3,10 @@ import { alplaStockInv } from "./cycleCount/alplaStockInventory.js";
import { emptyCount } from "./cycleCount/emptyCycleCount.js";
import { fullLaneCount } from "./cycleCount/fullLaneCycleCount.js";
import { ocmeInv } from "./cycleCount/ocmeInventory.js";
import { ocmeCycleCounts } from "../../../../database/schema/ocmeCycleCounts.js";
import { db } from "../../../../database/dbclient.js";
import { tryCatch } from "../../../globalUtils/tryCatch.js";
import { createLog } from "../../logger/logger.js";
export const prepareLane =
"https://usday1prod.alpla.net/application/public/v1.1/Warehousing/PrepareLaneForInventory";
@@ -74,6 +78,33 @@ export const cycleCount = async (lane: any, user: User) => {
}
// store in the db so we have a record.... for later when we fully randomize and automate this.
const postCount = {
laneId: ocme[0].alpla_laneID,
warehouseName: "",
laneName: alplaStock[0].alpla_laneDescription,
good: !combineBoth.every(
(s) => !s.info.includes("Validate") || !s.info.includes("sent")
),
cycleCount: combineBoth,
add_User: user.username,
};
const { data, error } = await tryCatch(
db.insert(ocmeCycleCounts).values(postCount)
);
if (error) {
createLog(
"error",
"lst",
"ocme",
`There was an error entering the cycle count data: ${error}`
);
}
if (data) {
createLog("info", "lst", "ocme", `Cycle Count data just added.`);
}
return combineBoth;
};