feat(silo): adjustments completed :D

This commit is contained in:
2025-04-07 07:01:50 -05:00
parent 31fbfa4eb3
commit 75f94eae14
5 changed files with 232 additions and 30 deletions

View File

@@ -58,6 +58,17 @@ export const createSiloAdjustment = async (
* Checking to see the difference, and send email if +/- 5% will change later if needed
*/
const sa: any = a;
if (!sa.success) {
console.log(`insde error`);
return {
success: sa.success,
message: sa.message,
data: sa.data,
};
}
const stockNummy = stock.filter((s: any) => s.LocationID === data.laneId);
const theDiff =
((data.quantity - stockNummy[0].Stock_Total) /
@@ -91,7 +102,7 @@ export const createSiloAdjustment = async (
data: postAdjError,
};
}
let adj: any = a;
if (Math.abs(theDiff) > 5) {
// console.log(`Send for comment due to being: ${theDiff.toFixed(2)}%`);
const server = set.filter((n: any) => n.name === "server");
@@ -123,8 +134,14 @@ export const createSiloAdjustment = async (
//console.log(emailSetup);
await sendEmail(emailSetup);
return {
success: adj.success,
message: `Silo adjustmnet was completed you will also receive and email due to the adjustment having a variation of ${Math.abs(
theDiff
).toFixed(2)}%`,
data: adj.data,
};
} else {
return { success: adj.success, message: adj.message, data: adj.data };
}
let adj: any = a;
return { success: adj.success, message: adj.message, data: adj.data };
};

View File

@@ -45,22 +45,45 @@ export const postAdjustment = async (data: any, prod: any) => {
})
);
let e = error as any;
if (error) {
return {
success: false,
message: "Error in posting the silo adjustment.",
data: {
status: e.response?.status,
statusText: e.response?.statusText,
data: e.response?.data,
},
};
if (e) {
if (e.status === 401) {
const data = {
success: false,
message: "Incorrect alpla prod password.",
data: {
status: e.response?.status,
statusText: e.response?.statusText,
data: e.response?.data,
},
};
return data;
} else {
return {
success: false,
message: "Error in posting the silo adjustment.",
data: {
status: e.response?.status,
statusText: e.response?.statusText,
data: e.response?.data,
},
};
}
}
if (silo.status !== 200) {
if (silo?.status !== 200) {
return {
success: false,
message: "Error in posting the silo adjustment",
data: {
status: silo?.status,
statusText: silo?.statusText,
data: silo?.data,
},
};
} else {
return {
success: true,
message: "Adjustment was completed",
data: {
status: silo.status,
statusText: silo.statusText,
@@ -68,14 +91,4 @@ export const postAdjustment = async (data: any, prod: any) => {
},
};
}
return {
success: true,
message: "Adjustment was completed",
data: {
status: silo.status,
statusText: silo.statusText,
data: silo.data,
},
};
};

View File

@@ -36,6 +36,7 @@ app.openapi(
data,
payload.user
);
return c.json(
{
success: createSiloAdj.success,