From 9479a15939cda4fe08de0dea421cfe062df815dd Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 6 Feb 2024 19:19:31 +0530 Subject: [PATCH 1/3] Improved: added support to create product facility location(#256) --- src/services/ProductService.ts | 32 ++++++++++++++++++++++++++++++++ src/views/count.vue | 21 ++++++++++++++++++--- 2 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/services/ProductService.ts b/src/services/ProductService.ts index 45fb9448..d3c2ed33 100644 --- a/src/services/ProductService.ts +++ b/src/services/ProductService.ts @@ -69,11 +69,43 @@ const addProductToFacility = async (payload: any): Promise => { }); } +const getCurrentFacilityLocation = async (facilityId: string): Promise => { + let locationSeqId; + try { + const params = { + "inputFields": { + facilityId + }, + "viewSize": 1, + "entityName": "FacilityLocation", + "fieldList": ["areaId", "aisleId", "sectionId", "levelId", "positionId", "locationSeqId"] + } + + const resp = await ProductService.getFacilityLocations(params); + if (!hasError(resp) && resp.data.docs.length) { + locationSeqId = resp.data.docs[0].locationSeqId + } + } catch (err) { + console.error(err); + } + return locationSeqId; +} + +const createProductFacilityLocation = async (payload: any): Promise => { + return api({ + url: "service/createProductFacilityLocation", + method: "post", + data: payload + }); +} + export const ProductService = { addProductToFacility, + createProductFacilityLocation, fetchProducts, importInventoryCount, isProductFacilityAssocExists, + getCurrentFacilityLocation, getFacilityLocations, updateVariance } \ No newline at end of file diff --git a/src/views/count.vue b/src/views/count.vue index 72baf8c1..64a540a9 100644 --- a/src/views/count.vue +++ b/src/views/count.vue @@ -212,12 +212,12 @@ }); await picker.present(); }, - updateProductInventoryCount() { + async updateProductInventoryCount() { if (this.quantity) { this.product.quantity = this.quantity; this.product.availableQOH = this.availableQOH; //Create the ProductFacility record if it does not exist. - this.checkAndCreateProductFacilityAssoc(); + await this.checkAndCreateProductFacilityAssoc(); this.store.dispatch('product/updateInventoryCount', { ...this.product, locationId: this.product.locationId }); showToast(translate("Item added to upload list"), [{ text: translate('View'), @@ -232,15 +232,30 @@ } }, async checkAndCreateProductFacilityAssoc() { + let resp; try { if (!await ProductService.isProductFacilityAssocExists(this.product.productId, this.facility.facilityId)) { - const resp = await ProductService.addProductToFacility({ + resp = await ProductService.addProductToFacility({ productId: this.product.productId, facilityId: this.facility.facilityId }); if (hasError(resp)) { throw resp.data; } + + const locationSeqId = await ProductService.getCurrentFacilityLocation(this.facility.facilityId) + + resp = await ProductService.createProductFacilityLocation({ + productId: this.product.productId, + facilityId: this.facility.facilityId, + locationSeqId + }); + + if (!hasError(resp)) { + await this.getFacilityLocations() + } else { + throw resp.data; + } } } catch (err) { console.error(err); From ee259d188fc799549875ed7072ed5f929fa6f4f5 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 6 Feb 2024 19:32:01 +0530 Subject: [PATCH 2/3] Improved: syntax for clean code structure (#256) --- src/services/ProductService.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/services/ProductService.ts b/src/services/ProductService.ts index d3c2ed33..502fd298 100644 --- a/src/services/ProductService.ts +++ b/src/services/ProductService.ts @@ -71,6 +71,7 @@ const addProductToFacility = async (payload: any): Promise => { const getCurrentFacilityLocation = async (facilityId: string): Promise => { let locationSeqId; + try { const params = { "inputFields": { @@ -88,6 +89,7 @@ const getCurrentFacilityLocation = async (facilityId: string): Promise => { } catch (err) { console.error(err); } + return locationSeqId; } From f595cafee9eb1e407700e26574bb0acf6ae5be85 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Wed, 7 Feb 2024 10:28:19 +0530 Subject: [PATCH 3/3] Improved: add support to product association to facility in variance flow (#256) --- src/views/count.vue | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/views/count.vue b/src/views/count.vue index 64a540a9..27256c47 100644 --- a/src/views/count.vue +++ b/src/views/count.vue @@ -354,6 +354,9 @@ }, async updateProductVarianceCount() { emitter.emit("presentLoader"); + + await this.checkAndCreateProductFacilityAssoc(); + let resp; try { const params = {