refactor(bulk orders): improvments and changes that i wanted in but missed
This commit is contained in:
@@ -50,6 +50,7 @@ export const standardOrders = async (data: any, user: any) => {
|
||||
};
|
||||
}
|
||||
const plantToken = s.filter((s) => s.name === "plantToken");
|
||||
|
||||
const arrayBuffer = await data.arrayBuffer();
|
||||
const buffer = Buffer.from(arrayBuffer);
|
||||
|
||||
@@ -110,11 +111,15 @@ export const standardOrders = async (data: any, user: any) => {
|
||||
|
||||
// map everything out for each order
|
||||
const nOrder = newOrders.map((o: any) => {
|
||||
const invoice = i.filter(
|
||||
(i: any) => i.deliveryAddress === parseInt(customerID)
|
||||
);
|
||||
if (!invoice) {
|
||||
return;
|
||||
}
|
||||
return {
|
||||
customerId: parseInt(customerID),
|
||||
invoiceAddressId: i.filter(
|
||||
(i: any) => i.deliveryAddress === parseInt(customerID)
|
||||
)[0].invoiceAddress, // matched to the default invoice address
|
||||
invoiceAddressId: invoice[0].invoiceAddress, // matched to the default invoice address
|
||||
customerOrderNo: o.CustomerOrderNumber,
|
||||
orderDate: new Date(Date.now()).toLocaleString("en-US"),
|
||||
positions: [
|
||||
@@ -143,8 +148,10 @@ export const standardOrders = async (data: any, user: any) => {
|
||||
|
||||
postedOrders.push({
|
||||
customer: customerID,
|
||||
//totalOrders: orders?.length(),
|
||||
success: posting.success,
|
||||
message: posting.message,
|
||||
data: posting.data,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { abbottOrders } from "./customMappings/abbottTruckList.js";
|
||||
import { standardOrders } from "./customMappings/standardOrders.js";
|
||||
import { abbottOrders } from "./mappings/abbottTruckList.js";
|
||||
import { standardOrders } from "./mappings/standardOrders.js";
|
||||
|
||||
export const ordersIn = async (data: any, user: any) => {
|
||||
/**
|
||||
@@ -15,7 +15,7 @@ export const ordersIn = async (data: any, user: any) => {
|
||||
// run the standard orders in
|
||||
const standard = await standardOrders(data["postOrders"], user);
|
||||
success = standard.success ?? false;
|
||||
message = standard.message ?? "Error posting Abbott Orders";
|
||||
message = standard.message ?? "Error posting Standard Orders";
|
||||
orderData = standard.data;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user