feat(standard orders in): multi customer orders in plus ignore already started

This commit is contained in:
2025-04-17 23:04:50 -05:00
parent 632e07967a
commit 68ccf2382b
9 changed files with 444 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
import { abbottOrders } from "./customMappings/abbottTruckList.js";
import { standardOrders } from "./customMappings/standardOrders.js";
export const ordersIn = async (data: any, user: any) => {
/**
* Bulk orders in, and custom file parsing.
*/
let success = true;
let message = "";
let orderData: any = [];
// what type of order are we dealing with?
if (data["fileType"] === "standard") {
// run the standard orders in
const standard = await standardOrders(data["postOrders"], user);
success = standard.success ?? false;
message = standard.message ?? "Error posting Abbott Orders";
orderData = standard.data;
}
if (data["fileType"] === "abbott") {
// orders in
const abbott = await abbottOrders(data["postOrders"], user);
success = abbott.success ?? false;
message = abbott.message ?? "Error posting Abbott Orders";
orderData = abbott.data;
}
if (data["fileType"] === "energizer") {
// orders in
}
if (data["fileType"] === "loreal") {
// orders in
}
if (data["fileType"] === "pg") {
// orders in
}
return {
success,
message,
data: orderData,
};
};