refactor(sql): improved the return function to show data [] when not connected, prevents crashes
This commit is contained in:
@@ -29,13 +29,13 @@ export const abbottOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// articleInfo
|
||||
const { data: a, error: ae } = await tryCatch(
|
||||
const { data: article, error: ae } = await tryCatch(
|
||||
query(
|
||||
bulkOrderArticleInfo.replace("[articles]", articles),
|
||||
"Get Article data for bulk orders"
|
||||
)
|
||||
);
|
||||
|
||||
const a: any = article?.data;
|
||||
if (ae) {
|
||||
return {
|
||||
sucess: false,
|
||||
@@ -45,10 +45,12 @@ export const abbottOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// order state
|
||||
const { data: openOrders, error: oe } = await tryCatch(
|
||||
const { data: o, error: oe } = await tryCatch(
|
||||
query(orderState, "Gets the next 500 orders that have not been started")
|
||||
);
|
||||
|
||||
const openOrders: any = o?.data;
|
||||
|
||||
if (oe) {
|
||||
return {
|
||||
sucess: false,
|
||||
|
||||
@@ -24,10 +24,12 @@ export const energizerOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// order state
|
||||
const { data: openOrders, error: oe } = await tryCatch(
|
||||
const { data: o, error: oe } = await tryCatch(
|
||||
query(orderState, "Gets the next 500 orders that have not been started")
|
||||
);
|
||||
|
||||
const openOrders: any = o?.data;
|
||||
|
||||
if (oe) {
|
||||
return {
|
||||
sucess: false,
|
||||
@@ -37,9 +39,10 @@ export const energizerOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// order state
|
||||
const { data: i, error: ie } = await tryCatch(
|
||||
const { data: invoice, error: ie } = await tryCatch(
|
||||
query(invoiceAddress, "Gets invoices addresses")
|
||||
);
|
||||
const i: any = invoice?.data;
|
||||
|
||||
if (ie) {
|
||||
return {
|
||||
|
||||
@@ -25,10 +25,12 @@ export const standardOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// order state
|
||||
const { data: openOrders, error: oe } = await tryCatch(
|
||||
const { data: o, error: oe } = await tryCatch(
|
||||
query(orderState, "Gets the next 500 orders that have not been started")
|
||||
);
|
||||
|
||||
const openOrders: any = o?.data;
|
||||
|
||||
if (oe) {
|
||||
return {
|
||||
sucess: false,
|
||||
@@ -38,10 +40,10 @@ export const standardOrders = async (data: any, user: any) => {
|
||||
}
|
||||
|
||||
// order state
|
||||
const { data: i, error: ie } = await tryCatch(
|
||||
const { data: invoice, error: ie } = await tryCatch(
|
||||
query(invoiceAddress, "Gets invoices addresses")
|
||||
);
|
||||
|
||||
const i: any = invoice?.data;
|
||||
if (ie) {
|
||||
return {
|
||||
sucess: false,
|
||||
|
||||
@@ -19,7 +19,8 @@ export const consumeMaterial = async (data: Data, prod: any) => {
|
||||
let barcode;
|
||||
// get the barcode from the running number
|
||||
try {
|
||||
barcode = await query(rnReplace, "labelData");
|
||||
const r: any = await query(rnReplace, "labelData");
|
||||
barcode = r?.data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
createLog(
|
||||
|
||||
@@ -20,7 +20,8 @@ export const returnMaterial = async (data: Data, prod: any) => {
|
||||
let barcode;
|
||||
// get the barcode from the running number
|
||||
try {
|
||||
barcode = await query(rnReplace, "labelData");
|
||||
const r: any = await query(rnReplace, "labelData");
|
||||
barcode = r?.data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
createLog(
|
||||
@@ -31,10 +32,10 @@ export const returnMaterial = async (data: Data, prod: any) => {
|
||||
);
|
||||
}
|
||||
|
||||
const { data: laneData, error: laneError } = await tryCatch(
|
||||
const { data: l, error: laneError } = await tryCatch(
|
||||
query(laneQuery, "laneInfo")
|
||||
);
|
||||
|
||||
const laneData: any = l?.data;
|
||||
if (laneError) {
|
||||
return {
|
||||
success: false,
|
||||
|
||||
@@ -31,7 +31,7 @@ export const createSiloAdjustment = async (
|
||||
}
|
||||
|
||||
// getting stock data first so we have it prior to the adjustment
|
||||
const { data: stock, error: stockError } = await tryCatch(
|
||||
const { data: s, error: stockError } = await tryCatch(
|
||||
query(siloQuery, "Silo data Query")
|
||||
);
|
||||
|
||||
@@ -42,7 +42,7 @@ export const createSiloAdjustment = async (
|
||||
data: stockError,
|
||||
};
|
||||
}
|
||||
|
||||
const stock: any = s?.data as any;
|
||||
const { data: a, error: errorAdj } = await tryCatch(
|
||||
postAdjustment(data, user.prod)
|
||||
);
|
||||
|
||||
@@ -15,7 +15,7 @@ export const getStockSiloData = async () => {
|
||||
message: "There was a n error getting the silo data.",
|
||||
};
|
||||
}
|
||||
|
||||
const stockData: any = data?.data;
|
||||
return {
|
||||
success: true,
|
||||
message: "Current silo data from alplastock.",
|
||||
|
||||
@@ -17,7 +17,7 @@ export const getLanesToCycleCount = async () => {
|
||||
createLog("info", "warehouse", "logistics", "Lane triggered update.");
|
||||
lastCheck = currentTime;
|
||||
const ageQuery = cycleCountCheck.replaceAll("[ageOfRow]", "90");
|
||||
const { data: prodLanes, error: pl } = await tryCatch(
|
||||
const { data: p, error: pl } = await tryCatch(
|
||||
query(ageQuery, "Get Stock lane date.")
|
||||
);
|
||||
|
||||
@@ -31,6 +31,8 @@ export const getLanesToCycleCount = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const prodLanes: any = p?.data;
|
||||
|
||||
// run the update on the lanes
|
||||
for (let i = 0; i < prodLanes.length; i++) {
|
||||
const createLane = {
|
||||
|
||||
Reference in New Issue
Block a user