feat(ocme): cycle count added to db will add to front end later for users to inspect
This commit is contained in:
@@ -3,6 +3,10 @@ import { alplaStockInv } from "./cycleCount/alplaStockInventory.js";
|
|||||||
import { emptyCount } from "./cycleCount/emptyCycleCount.js";
|
import { emptyCount } from "./cycleCount/emptyCycleCount.js";
|
||||||
import { fullLaneCount } from "./cycleCount/fullLaneCycleCount.js";
|
import { fullLaneCount } from "./cycleCount/fullLaneCycleCount.js";
|
||||||
import { ocmeInv } from "./cycleCount/ocmeInventory.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 =
|
export const prepareLane =
|
||||||
"https://usday1prod.alpla.net/application/public/v1.1/Warehousing/PrepareLaneForInventory";
|
"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.
|
// 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;
|
return combineBoth;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -31,6 +31,15 @@ export const assignedPrinters = async () => {
|
|||||||
const printers: any = print.data ?? [];
|
const printers: any = print.data ?? [];
|
||||||
const lots: any = l.data.length === 0 ? [] : l.data;
|
const lots: any = l.data.length === 0 ? [] : l.data;
|
||||||
|
|
||||||
|
if (!lots) {
|
||||||
|
createLog(
|
||||||
|
"error",
|
||||||
|
"lst",
|
||||||
|
"ocp",
|
||||||
|
`There was an error getting the lots: ${lots.message}`
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (let i = 0; i < printers.length; i++) {
|
for (let i = 0; i < printers.length; i++) {
|
||||||
// is the printer assinged in alplalabel online?
|
// is the printer assinged in alplalabel online?
|
||||||
const assigned = lots?.filter(
|
const assigned = lots?.filter(
|
||||||
|
|||||||
Reference in New Issue
Block a user