Skip to content

Commit

Permalink
Fixed: issue of shipped qty not visible for some items in the Tranfer…
Browse files Browse the repository at this point in the history
…Order

Added check to identify the number of records fetched and the total number of records in the database and made the api call untill all the records are not fetched
  • Loading branch information
ymaheshwari1 authored and ravilodhi committed Jul 9, 2024
1 parent 8e70f24 commit 6d7d137
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 21 deletions.
45 changes: 31 additions & 14 deletions src/services/OrderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,38 @@ const fetchOrderItems = async (orderId: string): Promise<any> => {
}

const fetchShippedQuantity = async (orderId: string): Promise<any> => {
const params = {
"entityName": "ShippedItemQuantitySum",
"inputFields": {
"orderId": orderId,
},
"fieldList": ["orderId", "orderItemSeqId", "productId", "shippedQuantity"],
"viewSize": 250, // maximum records we could have
"distinct": "Y"
} as any;
let docCount = 0;
let shippedItemQuantitySum = [] as any
let viewIndex = 0;

return await api({
url: "performFind",
method: "get",
params
})
do {
const params = {
"entityName": "ShippedItemQuantitySum",
"inputFields": {
"orderId": orderId,
},
"fieldList": ["orderId", "orderItemSeqId", "productId", "shippedQuantity"],
"viewSize": 250, // maximum records we could have
"distinct": "Y",
viewIndex
} as any;

const resp = await api({
url: "performFind",
method: "get",
params
}) as any

if (!hasError(resp) && resp.data.count) {
shippedItemQuantitySum = [...shippedItemQuantitySum, ...resp.data.docs]
docCount = resp.data.docs.length;
viewIndex++;
} else {
docCount = 0
}
} while(docCount >= 250);

return shippedItemQuantitySum;
}

const fetchShipmentItems = async (orderId: string, shipmentId: string): Promise<any> => {
Expand Down
12 changes: 5 additions & 7 deletions src/store/modules/transferorder/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,11 @@ const actions: ActionTree<TransferOrderState, RootState> = {
//fetch shipped quantity
const shippedQuantityInfo = {} as any;
resp = await OrderService.fetchShippedQuantity(payload.orderId);
if (!hasError(resp)) {
resp.data.docs.forEach((doc:any) => {
shippedQuantityInfo[doc.orderItemSeqId] = doc.shippedQuantity;
});
orderDetail.shippedQuantityInfo = shippedQuantityInfo;
}

resp.forEach((doc:any) => {
shippedQuantityInfo[doc.orderItemSeqId] = doc.shippedQuantity;
});
orderDetail.shippedQuantityInfo = shippedQuantityInfo;

//fetch product details
const productIds = [...new Set(orderDetail.items.map((item:any) => item.productId))];

Expand Down

0 comments on commit 6d7d137

Please sign in to comment.