refactor(material checks): added proper logging to capture it all for auditing later

This commit is contained in:
2025-10-07 14:41:07 -05:00
parent 887cd6f87a
commit 26b769f477
2 changed files with 65 additions and 5 deletions

1
.gitignore vendored
View File

@@ -195,3 +195,4 @@ controller/Dockerfile-ignore
controller/docker-compose.yml
controller/index.html
controller/index.html
LogisticsSupportTool_API_DOCS/environments/lst.bru

View File

@@ -36,6 +36,12 @@ 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
if (!lot) {
createLog(
"info",
"mainMaterial",
"ocp",
"No lot was passed correctly."
);
return isStaged;
}
@@ -81,6 +87,17 @@ export const isMainMatStaged = async (lot: any) => {
if (subset.some(failCondition)) {
const failing = subset.filter(failCondition);
createLog(
"info",
"mainMaterial",
"ocp",
`lot: ${lot.lot}, is missing: ${failing
.map(
(o: any) =>
`${o.MaterialHumanReadableId} - ${o.MaterialDescription}`
)
.join(",\n ")} ${failMessage}`
);
return {
message: `lot: ${lot.lot}, is missing: ${failing
.map(
@@ -91,6 +108,12 @@ export const isMainMatStaged = async (lot: any) => {
success: false,
};
} else {
createLog(
"info",
"mainMaterial",
"ocp",
`lot: ${lot.lot}, ${JSON.stringify(results)}`
);
return { message: successMessage, success: true };
}
};
@@ -99,6 +122,12 @@ export const isMainMatStaged = async (lot: any) => {
const mainMaterial = res.find((n: any) => n.IsMainMaterial);
if (mainMaterial?.noMMShortage === "noMM") {
createLog(
"info",
"mainMaterial",
"ocp",
`Main material: ${mainMaterial.MaterialHumanReadableId} - ${mainMaterial.MaterialDescription}: is not staged for ${lot.lot}`
);
return {
message: `Main material: ${mainMaterial.MaterialHumanReadableId} - ${mainMaterial.MaterialDescription}: is not staged for ${lot.lot}`,
success: false,
@@ -125,7 +154,12 @@ export const isMainMatStaged = async (lot: any) => {
successMessage: "auto color is good",
});
if (!autoColor.success) return autoColor;
console.log(autoColor);
createLog(
"info",
"mainMaterial",
"ocp",
`Auto Color: ${JSON.stringify(autoColor)}`
);
// 3. Manual color
const manualColor = checkCondition({
@@ -141,7 +175,12 @@ export const isMainMatStaged = async (lot: any) => {
successMessage: "manual color is good",
});
if (!manualColor.success) return manualColor;
console.log(manualColor);
createLog(
"info",
"mainMaterial",
"ocp",
`Manual Color: ${JSON.stringify(manualColor)}`
);
} else {
createLog(
"info",
@@ -166,8 +205,12 @@ export const isMainMatStaged = async (lot: any) => {
successMessage: "auto PKG is good",
});
if (!pkgAuto.success) return pkgAuto;
console.log(pkgAuto);
createLog(
"info",
"mainMaterial",
"ocp",
`PKG Auto: ${JSON.stringify(pkgAuto)}`
);
// 5. Packaging manual
const pkgManual = checkCondition({
results: res,
@@ -182,7 +225,12 @@ export const isMainMatStaged = async (lot: any) => {
});
if (!pkgManual.success) return pkgManual;
console.log(pkgManual);
createLog(
"info",
"mainMaterial",
"ocp",
`PKG Manual: ${JSON.stringify(pkgManual)}`
);
} else {
createLog(
"info",
@@ -205,6 +253,17 @@ export const isMainMatStaged = async (lot: any) => {
(n: any) => n.noPKGManualShortage === "noManPkg"
)
) {
createLog(
"info",
"mainMaterial",
"ocp",
`lot: ${lot.lot}, is missing: ${packagingCheck
.map(
(o: any) =>
`${o.MaterialHumanReadableId} - ${o.MaterialDescription}`
)
.join(",\n ")} for pkg`
);
return (isStaged = {
message: `lot: ${lot.lot}, is missing: ${packagingCheck
.map(