feat(silo): adjustments completed :D
This commit is contained in:
@@ -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 };
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user