Skip to content

Commit

Permalink
Merge pull request #377 from amansinghbais/#325
Browse files Browse the repository at this point in the history
Implemented: force scan functionality and barcode identification pref while receiving orders (#325)
  • Loading branch information
ymaheshwari1 authored Jul 18, 2024
2 parents 3ca5f63 + dc7bac1 commit c702aee
Show file tree
Hide file tree
Showing 17 changed files with 452 additions and 28 deletions.
15 changes: 14 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"Authenticating": "Authenticating",
"Are you sure you have received the purchase order for the selected items? Once closed, the shipments for the selected items wont be available for receiving later.": "Are you sure you have received the purchase order for the selected items? { space } Once closed, the shipments for the selected items won't be available for receiving later.",
"Arrival date": "Arrival date",
"Barcode Identifier": "Barcode Identifier",
"Barcode identification preference updated successfully.": "Barcode identification preference updated successfully.",
"Browser TimeZone": "Browser TimeZone",
"Browser time zone": "Browser time zone",
"Built: ": "Built: {builtDateTime}",
Expand All @@ -29,10 +31,14 @@
"Location": "Location",
"Failed to receive shipment": "Failed to receive shipment",
"Failed to receive some of the items": "Failed to receive some of the items",
"Failed to update force scan preference.": "Failed to update force scan preference.",
"Failed to update product identifier preference": "Failed to update product identifier preference",
"facility location": "facility location",
"Facility locations were not found corresponding to destination facility of return shipment. Please add facility locations to avoid receive return shipment failure.": "Facility locations were not found corresponding to destination facility of return shipment. Please add facility locations to avoid receive return shipment failure.",
"Failed to update barcode identification preference.": "Failed to update barcode identification preference.",
"Fetching time zones": "Fetching time zones",
"Force scan": "Force scan",
"Force scan preference updated successfully.": "Force scan preference updated successfully.",
"Go to Launchpad": "Go to Launchpad",
"Go to OMS": "Go to OMS",
"History": "History",
Expand All @@ -57,13 +63,15 @@
"No shipments have been received against this purchase order yet": "No shipments have been received against {lineBreak} this purchase order yet",
"OMS": "OMS",
"OMS instance": "OMS instance",
"Only allow received quantity to be incremented by scanning the barcode of products. If the identifier is not found, the scan will default to using the internal name.": "Only allow received quantity to be incremented by scanning the barcode of products. {space} If the identifier is not found, the scan will default to using the internal name.",
"ordered": "ordered",
"Orders not found": "Orders not found",
"Password": "Password",
"Pending: item": "Pending: {itemsCount} item",
"Pending: items": "Pending: {itemsCount} items",
"Please provide a valid SKU.": "Please provide a valid SKU.",
"Please provide a valid valid barcode identifier.": "Please provide a valid valid barcode identifier.",
"primary identifier": "primary identifier",
"Primary identifier": "Primary identifier",
"Primary Product Identifier": "Primary Product Identifier",
"Proceed": "Proceed",
"Product Identifier": "Product Identifier",
Expand All @@ -81,6 +89,7 @@
"Receive Shipment": "Receive Shipment",
"Receiving": "Receiving",
"Refresh": "Refresh",
"Require scanning": "Require scanning",
"Reset password": "Reset password",
"Return Details": "Return Details",
"Return received successfully": "Return received successfully {shipmentId}",
Expand All @@ -96,12 +105,14 @@
"Scanned item is not present within the shipment:": "Scanned item is not present within the shipment: {itemName}",
"Scanned successfully.": "Scanned {itemName} successfully.",
"secondary identifier": "secondary identifier",
"Secondary identifier": "Secondary identifier",
"Search": "Search",
"Search purchase orders": "Search purchase orders",
"Search returns": "Search returns",
"Search time zones": "Search time zones",
"Search SKU or product name": "Search SKU or product name",
"Secondary Product Identifier": "Secondary Product Identifier",
"Select": "Select",
"Select all": "Select all",
"Select facility": "Select facility",
"Selected TimeZone": "Selected TimeZone",
Expand Down Expand Up @@ -129,6 +140,8 @@
"Timezone": "Timezone",
"Time zone updated successfully": "Time zone updated successfully",
"To close the purchase order, select all.": "To close the purchase order, select all.",
"Unable to update barcode identification preference.": "Unable to update barcode identification preference.",
"Unable to update force scan preference.": "Unable to update force scan preference.",
"Unable to update product identifier preference": "Unable to update product identifier preference",
"Username": "Username",
"Version: ": "Version: {appVersion}",
Expand Down
84 changes: 82 additions & 2 deletions src/services/UtilService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { api } from '@/adapter';
import { api, hasError } from '@/adapter';

const fetchStatus = async (payload: any): Promise<any> => {
return api({
Expand All @@ -8,6 +8,86 @@ const fetchStatus = async (payload: any): Promise<any> => {
})
}

const updateForceScanSetting = async (payload: any): Promise<any> => {
return api({
url: "service/updateProductStoreSetting",
method: "post",
data: payload
});
}

const createForceScanSetting = async (payload: any): Promise<any> => {
return api({
url: "service/createProductStoreSetting",
method: "post",
data: payload
});
}

const updateBarcodeIdentificationPref = async (payload: any): Promise<any> => {
return api({
url: "service/updateProductStoreSetting",
method: "post",
data: payload
});
}

const createBarcodeIdentificationPref = async (payload: any): Promise<any> => {
return api({
url: "service/createProductStoreSetting",
method: "post",
data: payload
});
}

const getProductStoreSetting = async (payload: any): Promise<any> => {
return api({
url: "performFind",
method: "post",
data: payload
});
}

const isEnumExists = async (enumId: string): Promise<any> => {
try {
const resp = await api({
url: 'performFind',
method: 'POST',
data: {
entityName: "Enumeration",
inputFields: {
enumId
},
viewSize: 1,
fieldList: ["enumId"],
noConditionFind: 'Y'
}
}) as any

if (!hasError(resp) && resp.data.docs.length) {
return true
}
return false
} catch (err) {
return false
}
}

const createEnumeration = async (payload: any): Promise<any> => {
return api({
url: "service/createEnumeration",
method: "post",
data: payload
})
}

export const UtilService = {
fetchStatus
createBarcodeIdentificationPref,
createEnumeration,
createForceScanSetting,
fetchStatus,
getProductStoreSetting,
isEnumExists,
updateBarcodeIdentificationPref,
updateForceScanSetting
}
2 changes: 1 addition & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const state: any = {
}

const persistState = createPersistedState({
paths: ['user', 'return.validStatusChange', 'util.productIdentifications'],
paths: ['user', 'return.validStatusChange', 'util.productIdentifications', 'util.isForceScanEnabled', 'util.barcodeIdentificationPref'],
fetchBeforeUse: true
})

Expand Down
11 changes: 9 additions & 2 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import RootState from '@/store/RootState'
import OrderState from './OrderState'
import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { translate } from '@hotwax/dxp-components'
import { getProductIdentificationValue, translate } from '@hotwax/dxp-components'
import emitter from "@/event-bus";
import store from "@/store";


const actions: ActionTree<OrderState, RootState> = {
Expand Down Expand Up @@ -41,7 +42,13 @@ const actions: ActionTree<OrderState, RootState> = {
return resp;
},
async updateProductCount({ commit, state }, payload ) {
const item = state.current.items.find((item: any) => item.internalName === payload);
const barcodeIdentifier = store.getters['util/getBarcodeIdentificationValue'];
const getProduct = store.getters['product/getProduct'];

const item = state.current.items.find((item: any) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, getProduct(item.productId)) : item.internalName;
return itemVal === payload;
});

if (item) {
if(item.orderItemStatusId === 'ITEM_COMPLETED') return { isCompleted: true }
Expand Down
11 changes: 9 additions & 2 deletions src/store/modules/return/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import RootState from '@/store/RootState'
import ReturnState from './ReturnState'
import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { translate } from '@hotwax/dxp-components'
import { getProductIdentificationValue, translate } from '@hotwax/dxp-components'
import emitter from '@/event-bus'
import store from "@/store";

const actions: ActionTree<ReturnState, RootState> = {
async findReturn ({ commit, state }, payload) {
Expand Down Expand Up @@ -33,7 +34,13 @@ const actions: ActionTree<ReturnState, RootState> = {
return resp;
},
async updateReturnProductCount ({ commit, state }, payload) {
const item = state.current.items.find((item: any) => item.sku === payload);
const barcodeIdentifier = store.getters['util/getBarcodeIdentificationValue'];
const getProduct = store.getters['product/getProduct'];

const item = state.current.items.find((item: any) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, getProduct(item.productId)) : item.internalName;
return itemVal === payload;
});

if (item) {
item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : 1;
Expand Down
11 changes: 9 additions & 2 deletions src/store/modules/shipment/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import RootState from '@/store/RootState'
import ShipmentState from './ShipmentState'
import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { translate } from '@hotwax/dxp-components'
import { getProductIdentificationValue, translate } from '@hotwax/dxp-components'
import emitter from '@/event-bus'
import store from "@/store";

const actions: ActionTree<ShipmentState, RootState> = {
async findShipment ({ commit, state }, payload) {
Expand Down Expand Up @@ -43,7 +44,13 @@ const actions: ActionTree<ShipmentState, RootState> = {
},

async updateShipmentProductCount ({ commit, state }, payload) {
const item = state.current.items.find((item: any) => item.sku === payload);
const barcodeIdentifier = store.getters['util/getBarcodeIdentificationValue'];
const getProduct = store.getters['product/getProduct'];

const item = state.current.items.find((item: any) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, getProduct(item.productId)) : item.internalName;
return itemVal === payload;
});

if (item) {
item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : 1;
Expand Down
7 changes: 6 additions & 1 deletion src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ const actions: ActionTree<UserState, RootState> = {
// TODO: fetch product identifications from enumeration instead of storing it in env
this.dispatch('util/setProductIdentifications', process.env.VUE_APP_PRDT_IDENT ? JSON.parse(process.env.VUE_APP_PRDT_IDENT) : [])
dispatch('getProductIdentificationPref', currentEComStore?.productStoreId);

this.dispatch('util/getForceScanSetting', currentEComStore?.productStoreId);
this.dispatch('util/getBarcodeIdentificationPref', currentEComStore?.productStoreId);
} catch (err: any) {
// If any of the API call in try block has status code other than 2xx it will be handled in common catch block.
// TODO Check if handling of specific status codes is required.
Expand Down Expand Up @@ -136,6 +137,8 @@ const actions: ActionTree<UserState, RootState> = {
commit(types.USER_END_SESSION)
this.dispatch('util/setProductIdentifications', [])
this.dispatch('order/clearPurchaseOrders');
this.dispatch('util/updateForceScanStatus', false)
this.dispatch('util/updateBarcodeIdentificationPref', "")
resetPermissions();
resetConfig();

Expand All @@ -161,6 +164,8 @@ const actions: ActionTree<UserState, RootState> = {
'userPrefValue': payload.eComStore.productStoreId
});
await dispatch('getProductIdentificationPref', payload.eComStore.productStoreId);
this.dispatch('util/getForceScanSetting', payload.ecomStore.productStoreId)
this.dispatch('util/getBarcodeIdentificationPref', payload.ecomStore.productStoreId)
},

/**
Expand Down
2 changes: 2 additions & 0 deletions src/store/modules/util/UtilState.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export default interface UtilState {
status: any;
productIdentifications: Array<string>;
isForceScanEnabled: boolean;
barcodeIdentificationPref: any;
}
Loading

0 comments on commit c702aee

Please sign in to comment.