refactor(ocme): added new error in posting where we know when the pallet is not instock
This commit is contained in:
@@ -38,6 +38,13 @@ export const postLabelData = async (data: any) => {
|
|||||||
"There was an error getting the labelData"
|
"There was an error getting the labelData"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (label.length === 0) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
message: "The label you scanned dose not exist in stock.",
|
||||||
|
};
|
||||||
|
}
|
||||||
const newPost = {
|
const newPost = {
|
||||||
sscc: newData.sscc ? newData.sscc : await createSSCC(newData.runningNr),
|
sscc: newData.sscc ? newData.sscc : await createSSCC(newData.runningNr),
|
||||||
runningNr: newData.runningNr,
|
runningNr: newData.runningNr,
|
||||||
@@ -50,6 +57,7 @@ export const postLabelData = async (data: any) => {
|
|||||||
const enterNewData = await db
|
const enterNewData = await db
|
||||||
.insert(ocmeData)
|
.insert(ocmeData)
|
||||||
.values(newPost)
|
.values(newPost)
|
||||||
|
.onConflictDoUpdate({ target: ocmeData.runningNr, set: newPost })
|
||||||
.returning({
|
.returning({
|
||||||
sscc: ocmeData.sscc,
|
sscc: ocmeData.sscc,
|
||||||
runningNr: ocmeData.runningNr,
|
runningNr: ocmeData.runningNr,
|
||||||
@@ -69,8 +77,8 @@ export const postLabelData = async (data: any) => {
|
|||||||
//console.log(error);
|
//console.log(error);
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
message: "Data was posted to ocme info",
|
message: "Was not posted",
|
||||||
data: [],
|
data: [error],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user