From 3eba720982c79b29117db9147fa140b61c50648f Mon Sep 17 00:00:00 2001 From: Yash Maheshwari Date: Wed, 26 Jun 2024 18:09:17 +0530 Subject: [PATCH] Fixed: issue when rendering products information on the inventory review page Added check to create products information based on the identification selected Fixed issue when getting location for facility, as location information is stored based on facilityId and not externalFacilityId --- src/store/modules/stock/actions.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/store/modules/stock/actions.ts b/src/store/modules/stock/actions.ts index fc16d60..4417c48 100644 --- a/src/store/modules/stock/actions.ts +++ b/src/store/modules/stock/actions.ts @@ -38,10 +38,20 @@ const actions: ActionTree = { identificationTypeId: items[0]?.identificationTypeId //fetching identificationTypeId from first item, as all the items will have one identification type } const cachedProducts = await store.dispatch("product/fetchProducts", payload); + + // creating products object based on identification selected, if not doing so, and if we select an identification that is not equal to pseudoId of the product then the products are not displayed + const products: any = Object.values(cachedProducts).reduce((updatedProducts: any, product: any) => { + const identification = product.identifications.find((identification: any) => payload.identificationTypeId.toLowerCase() === identification.productIdTypeEnumId.toLowerCase()) + updatedProducts[identification.idValue] = product + return updatedProducts; + }, {}) + const parsed = [] as any; const initial = items.map((item: any) => { - const product = cachedProducts[item.identification]; - const facilityLocation = rootGetters['util/getFacilityLocationsByFacilityId'](item.externalFacilityId)?.[0]; + const product = products[item.identification]; + // Getting facilityId using externalFacilityId as the locations are saved by using facilityId as key + const facilityId = facilityMapping[item.externalFacilityId] + const facilityLocation = facilityId ? rootGetters['util/getFacilityLocationsByFacilityId'](facilityId)?.[0] : ''; item.locationSeqId = facilityLocation?.locationSeqId; parsed.push(item);