From ff3d23bf12fc06629363bc5468b19b7da473d2fd Mon Sep 17 00:00:00 2001 From: Ritika-Patel08 Date: Tue, 13 Feb 2024 12:15:57 +0530 Subject: [PATCH 1/6] Fixed: quantity updation even if qty value is empty --- src/store/modules/shipment/actions.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index 0bfa860c..2abe58ce 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -36,6 +36,9 @@ const actions: ActionTree = { async updateShipmentProductCount ({ commit, state }, payload) { await state.current.items.find((item: any) => { if(item.sku === payload){ + if (item.quantityAccepted === "") { + item.quantityAccepted = 0; + } item.quantityAccepted = parseInt(item.quantityAccepted) + 1; } }); From 62d33f8b69e77fa8695c27afc303ad1a3e0634ac Mon Sep 17 00:00:00 2001 From: Ritika-Patel08 Date: Tue, 13 Feb 2024 14:45:00 +0530 Subject: [PATCH 2/6] Fixed: code by giving the toast messege when product not found --- src/store/modules/shipment/actions.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index 2abe58ce..b4033785 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -34,14 +34,17 @@ const actions: ActionTree = { }, async updateShipmentProductCount ({ commit, state }, payload) { - await state.current.items.find((item: any) => { - if(item.sku === payload){ - if (item.quantityAccepted === "") { - item.quantityAccepted = 0; - } - item.quantityAccepted = parseInt(item.quantityAccepted) + 1; + const findItem = state.current.items.find((item:any) => item.sku === payload); + + if (findItem ) { + if (findItem.quantityAccepted === "") { + findItem.quantityAccepted = 0; } - }); + findItem.quantityAccepted = parseInt(findItem.quantityAccepted) + 1; + } else { + showToast(translate("Product not found")); + } + commit(types.SHIPMENT_CURRENT_UPDATED, state); }, async setCurrent ({ commit }, payload) { From 998d4d14cb82fdcebad422e75bfe731fb9596aaa Mon Sep 17 00:00:00 2001 From: Ritika-Patel08 Date: Tue, 13 Feb 2024 16:07:09 +0530 Subject: [PATCH 3/6] Improved: logic by using ternary operator instead for nested if statement --- src/store/modules/shipment/actions.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index b4033785..3f406b74 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -6,6 +6,7 @@ import * as types from './mutation-types' import { hasError, showToast } from '@/utils' import { translate } from '@hotwax/dxp-components' import emitter from '@/event-bus' +import { Item } from "@ionic/core/dist/types/components/item/item"; const actions: ActionTree = { async findShipment ({ commit, state }, payload) { @@ -34,13 +35,9 @@ const actions: ActionTree = { }, async updateShipmentProductCount ({ commit, state }, payload) { - const findItem = state.current.items.find((item:any) => item.sku === payload); - - if (findItem ) { - if (findItem.quantityAccepted === "") { - findItem.quantityAccepted = 0; - } - findItem.quantityAccepted = parseInt(findItem.quantityAccepted) + 1; + const item = state.current.items.find((item: any)=> item.sku === payload); + if (item) { + item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : parseInt("0") + 1; } else { showToast(translate("Product not found")); } From 13ebe8058c4268b0f28120972a155040d7ba1e7d Mon Sep 17 00:00:00 2001 From: Ritika-Patel08 Date: Wed, 14 Feb 2024 15:38:08 +0530 Subject: [PATCH 4/6] Fixed: updateProductCount now uses 'parseInt' to handle count of product as an integer, avoiding concatenation errors --- src/store/modules/order/actions.ts | 12 +++++++----- src/store/modules/shipment/actions.ts | 1 - 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 5474f691..8d0b2dc5 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -41,11 +41,13 @@ const actions: ActionTree = { return resp; }, async updateProductCount({ commit, state }, payload ) { - state.current.items.find((item: any) => { - if (item.internalName === payload) { - item.quantityAccepted = item.quantityAccepted + 1; - } - }); + const item = state.current.items.find((item: any)=> item.internalName === payload); + if (item) { + item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : parseInt("0") + 1; + } else { + showToast(translate("Product not found")); + } + commit(types.ORDER_CURRENT_UPDATED, state.current ) }, async addOrderItem ({ commit }, payload) { diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index 3f406b74..9a3551e5 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -6,7 +6,6 @@ import * as types from './mutation-types' import { hasError, showToast } from '@/utils' import { translate } from '@hotwax/dxp-components' import emitter from '@/event-bus' -import { Item } from "@ionic/core/dist/types/components/item/item"; const actions: ActionTree = { async findShipment ({ commit, state }, payload) { From f05bbf1d4e0674a1eeb8f96790a637e3efba5ef5 Mon Sep 17 00:00:00 2001 From: Ritika-Patel08 Date: Wed, 14 Feb 2024 17:06:22 +0530 Subject: [PATCH 5/6] Improved: code by simplifying the logic by removing unnecessary parseInt in false condition and added space inside find() --- src/store/modules/order/actions.ts | 4 ++-- src/store/modules/shipment/actions.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 8d0b2dc5..f0436368 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -41,9 +41,9 @@ const actions: ActionTree = { return resp; }, async updateProductCount({ commit, state }, payload ) { - const item = state.current.items.find((item: any)=> item.internalName === payload); + const item = state.current.items.find((item: any) => item.internalName === payload); if (item) { - item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : parseInt("0") + 1; + item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : 1; } else { showToast(translate("Product not found")); } diff --git a/src/store/modules/shipment/actions.ts b/src/store/modules/shipment/actions.ts index 9a3551e5..42ba78e7 100644 --- a/src/store/modules/shipment/actions.ts +++ b/src/store/modules/shipment/actions.ts @@ -34,9 +34,9 @@ const actions: ActionTree = { }, async updateShipmentProductCount ({ commit, state }, payload) { - const item = state.current.items.find((item: any)=> item.sku === payload); + const item = state.current.items.find((item: any) => item.sku === payload); if (item) { - item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : parseInt("0") + 1; + item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : 1; } else { showToast(translate("Product not found")); } From aff6163155bca333cdfb7b361f60b8dcc5fe1b43 Mon Sep 17 00:00:00 2001 From: Ritika-Patel08 Date: Mon, 19 Feb 2024 18:54:35 +0530 Subject: [PATCH 6/6] Fixed: scanning failure issue caused by empty quantity values when scanning barcode in 'Returns' --- src/store/modules/return/actions.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/store/modules/return/actions.ts b/src/store/modules/return/actions.ts index 0a0df3cf..15e259f6 100644 --- a/src/store/modules/return/actions.ts +++ b/src/store/modules/return/actions.ts @@ -33,11 +33,13 @@ const actions: ActionTree = { return resp; }, async updateReturnProductCount ({ commit, state }, payload) { - await state.current.items.find((item: any) => { - if(item.sku === payload){ - item.quantityAccepted = parseInt(item.quantityAccepted) + 1; - } - }); + const item = state.current.items.find((item: any) => item.sku === payload); + if (item) { + item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : 1; + } else { + showToast(translate("Product not found")); + } + commit(types.RETURN_CURRENT_UPDATED, state); }, async setCurrent ({ commit, state }, payload) {