fix(ocp): more material check work
This commit is contained in:
@@ -7,7 +7,10 @@ import { mmQuery } from "../../../sqlServer/querys/ocp/mainMaterial.js";
|
||||
|
||||
export const isMainMatStaged = async (lot: any) => {
|
||||
const set = serverSettings.length === 0 ? [] : serverSettings;
|
||||
// make staged false by deefault and error logged if theres an issue
|
||||
const checkColorSetting = set.filter((n) => n.name === "checkColor");
|
||||
const checkPKGSetting = set.filter((n) => n.name === "checkPKG");
|
||||
|
||||
// make staged false by default and error logged if theres an issue
|
||||
let isStaged = { message: "Material is staged", success: true };
|
||||
|
||||
const { data, error } = (await tryCatch(
|
||||
@@ -43,7 +46,7 @@ export const isMainMatStaged = async (lot: any) => {
|
||||
};
|
||||
}
|
||||
|
||||
// strangly the lot is not always sending over in slc so adding this in for now to see what line is cauing this issue
|
||||
// strangely the lot is not always sending over in slc so adding this in for now to see what line is cauing this issue
|
||||
if (!lot) {
|
||||
createLog("info", "mainMaterial", "ocp", "No lot was passed correctly.");
|
||||
return isStaged;
|
||||
@@ -125,7 +128,11 @@ export const isMainMatStaged = async (lot: any) => {
|
||||
createLog("info", "mainMaterial", "ocp", `Maint material query ran.`);
|
||||
|
||||
const mainMaterial = res.find((n: any) => n.IsMainMaterial);
|
||||
if (mainMaterial?.Staged === 1) {
|
||||
|
||||
if (
|
||||
mainMaterial?.Staged === 1 &&
|
||||
(checkColorSetting[0].value !== "1" || checkPKGSetting[0].value !== "1")
|
||||
) {
|
||||
createLog(
|
||||
"info",
|
||||
"mainMaterial",
|
||||
@@ -152,7 +159,6 @@ export const isMainMatStaged = async (lot: any) => {
|
||||
|
||||
// we need to filter the color stuff and then look for includes instead of a standard name. this way we can capture a everything and not a single type
|
||||
// for manual consume color if active to check colors
|
||||
const checkColorSetting = set.filter((n) => n.name === "checkColor");
|
||||
|
||||
// 2. Auto color
|
||||
if (checkColorSetting[0].value === "1") {
|
||||
@@ -162,7 +168,7 @@ export const isMainMatStaged = async (lot: any) => {
|
||||
results: res,
|
||||
lot,
|
||||
filterFn: (n) =>
|
||||
n.isManual &&
|
||||
!n.isManual &&
|
||||
!("noPKGAutoShortage" in n) &&
|
||||
!("noPKGManualShortage" in n), // pool = non-main, auto
|
||||
failCondition: (n) => n.autoConsumeCheck === "autoConsumeNOK", // column = autoConsumeCheck
|
||||
@@ -202,7 +208,7 @@ export const isMainMatStaged = async (lot: any) => {
|
||||
}
|
||||
|
||||
// // if we want to check the packaging
|
||||
const checkPKGSetting = set.filter((n) => n.name === "checkPKG");
|
||||
|
||||
if (checkPKGSetting[0].value === "1") {
|
||||
const pkgAuto = checkCondition({
|
||||
results: res,
|
||||
|
||||
Reference in New Issue
Block a user