fix(abbott orders): corrected the ignore function for already in progress orders
This commit is contained in:
@@ -90,6 +90,7 @@ export const abbottOrders = async (data: any, user: any) => {
|
||||
orders: [],
|
||||
};
|
||||
const oOrders: any = openOrders;
|
||||
|
||||
let correctedOrders: any = orderData
|
||||
.filter(
|
||||
(o: any) =>
|
||||
@@ -121,12 +122,29 @@ export const abbottOrders = async (data: any, user: any) => {
|
||||
});
|
||||
|
||||
// last map to remove orders that have already been started
|
||||
correctedOrders = correctedOrders.filter((oo: any) =>
|
||||
oOrders.some((o: any) => o.CustomerOrderNumber === oo.po)
|
||||
);
|
||||
// correctedOrders = correctedOrders.filter((oo: any) =>
|
||||
// oOrders.some((o: any) => o.CustomerOrderNumber === oo.po)
|
||||
// );
|
||||
let postedOrders: any = [];
|
||||
const filterOrders: any = correctedOrders;
|
||||
filterOrders.forEach((oo: any) => {
|
||||
const isMatch = openOrders.some(
|
||||
(o: any) =>
|
||||
String(o.CustomerOrderNumber).trim() ===
|
||||
String(oo.CustomerOrderNumber).trim()
|
||||
);
|
||||
if (!isMatch) {
|
||||
console.log(`ok to update: ${oo.CustomerOrderNumber}`);
|
||||
|
||||
postedOrders.push(oo);
|
||||
} else {
|
||||
console.log(`Not valid order to update: ${oo.CustomerOrderNumber}`);
|
||||
//console.log(oo)
|
||||
}
|
||||
});
|
||||
|
||||
// Map Excel data to predefinedObject format
|
||||
const orders = correctedOrders.map((o: any) => {
|
||||
const orders = filterOrders.map((o: any) => {
|
||||
return {
|
||||
customerId: customerID,
|
||||
invoiceAddressId: invoiceID,
|
||||
|
||||
Reference in New Issue
Block a user