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: [],
|
orders: [],
|
||||||
};
|
};
|
||||||
const oOrders: any = openOrders;
|
const oOrders: any = openOrders;
|
||||||
|
|
||||||
let correctedOrders: any = orderData
|
let correctedOrders: any = orderData
|
||||||
.filter(
|
.filter(
|
||||||
(o: any) =>
|
(o: any) =>
|
||||||
@@ -121,12 +122,29 @@ export const abbottOrders = async (data: any, user: any) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// last map to remove orders that have already been started
|
// last map to remove orders that have already been started
|
||||||
correctedOrders = correctedOrders.filter((oo: any) =>
|
// correctedOrders = correctedOrders.filter((oo: any) =>
|
||||||
oOrders.some((o: any) => o.CustomerOrderNumber === oo.po)
|
// 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
|
// Map Excel data to predefinedObject format
|
||||||
const orders = correctedOrders.map((o: any) => {
|
const orders = filterOrders.map((o: any) => {
|
||||||
return {
|
return {
|
||||||
customerId: customerID,
|
customerId: customerID,
|
||||||
invoiceAddressId: invoiceID,
|
invoiceAddressId: invoiceID,
|
||||||
|
|||||||
Reference in New Issue
Block a user