Skip to content

Commit

Permalink
Merge pull request #851 from amansinghbais/#845-barcode
Browse files Browse the repository at this point in the history
Implemented: barcode identifier selector and scanning based on selected identifier (#845)
  • Loading branch information
ravilodhi authored Nov 13, 2024
2 parents d393959 + e0d92f4 commit e9e3503
Show file tree
Hide file tree
Showing 16 changed files with 190 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/components/ScanOrderItemModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default defineComponent({
computed: {
...mapGetters({
getProduct: 'product/getProduct',
barcodeIdentifier: 'util/getBarcodeIdentificationPref'
}),
},
data() {
Expand Down Expand Up @@ -133,7 +134,7 @@ export default defineComponent({
let currentItem = {} as any;
const item = this.orderItems.find((orderItem: any) => {
const itemVal = getProductIdentificationValue(this.productIdentificationPref.primaryId, this.getProduct(orderItem.productId)) ? getProductIdentificationValue(this.productIdentificationPref.primaryId, this.getProduct(orderItem.productId)) : orderItem.productSku
const itemVal = getProductIdentificationValue(this.barcodeIdentifier, this.getProduct(orderItem.productId)) ? getProductIdentificationValue(this.barcodeIdentifier, this.getProduct(orderItem.productId)) : this.getProduct(orderItem.productId)?.internalName
if(itemVal === payload) currentItem = orderItem;
return itemVal === payload && !orderItem.isChecked;
});
Expand Down
3 changes: 2 additions & 1 deletion src/components/TransferOrderItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div>
<div class="product-count">
<ion-item v-if="!item.shipmentId" lines="none">
<ion-input :label="translate('Qty')" label-placement="floating" ref="pickedQuantity" type="number" min="0" v-model="item.pickedQuantity" @ionInput="updatePickedQuantity($event, item); validatePickedQuantity($event, item); markPickedQuantityTouched()" :errorText="getErrorText(item)" />
<ion-input :label="translate('Qty')" label-placement="floating" ref="pickedQuantity" type="number" min="0" v-model="item.pickedQuantity" @ionInput="updatePickedQuantity($event, item); validatePickedQuantity($event, item); markPickedQuantityTouched()" :errorText="getErrorText(item)" :disabled="isForceScanEnabled" />
</ion-item>
<ion-item v-else lines="none">
<ion-label slot="end">{{ item.pickedQuantity }} {{ translate('packed') }}</ion-label>
Expand Down Expand Up @@ -97,6 +97,7 @@ export default defineComponent({
...mapGetters({
currentOrder: 'transferorder/getCurrent',
getProduct: 'product/getProduct',
isForceScanEnabled: 'util/isForceScanEnabled',
}),
},
methods: {
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"Auto reject related items": "Auto reject related items",
"Available to promise": "Available to promise",
"Back to Launchpad": "Back to Launchpad",
"Barcode Identifier": "Barcode Identifier",
"Billing Address 1": "Billing Address 1",
"Billing Address 2": "Billing Address 2",
"Billing City": "Billing City",
Expand Down Expand Up @@ -94,7 +95,6 @@
"Confirm": "Confirm",
"Configure the order fulfillment capacity of your facility.": "Configure the order fulfillment capacity of your facility.",
"Control whether the store's inventory should be made available for online sales or not.": "Control whether the store's inventory should be made available for online sales or not.",
"Control whether the store requires the force scan during order packing or not.": "Control whether the store requires the force scan during order packing or not.",
"Copied": "Copied { value }",
"Copied to clipboard": "Copied to clipboard",
"Copy ID": "Copy ID",
Expand Down Expand Up @@ -341,6 +341,7 @@
"On": "On",
"Online Order Fulfillment": "Online Order Fulfillment",
"Only alphanumeric characters are allowed.": "Only alphanumeric characters are allowed.",
"Only allow shipped 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 shipped 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.",
"Only methods for this carrier": "Only methods for this carrier",
"Only positive numbers are allowed.": "Only positive numbers are allowed.",
"Open": "Open",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"Auto reject related items": "Auto rechazar liberar items",
"Available to promise": "Available to promise",
"Back to Launchpad": "Volver a Launchpad",
"Barcode Identifier": "Barcode Identifier",
"Billing Address 1": "Dirección de Facturación 1",
"Billing Address 2": "Dirección de Facturación 2",
"Billing City": "Ciudad de Facturación",
Expand Down Expand Up @@ -90,7 +91,6 @@
"Confirm": "Confirmar",
"Configure the order fulfillment capacity of your facility.": "Configure la capacidad de cumplimiento de pedidos de tu instalación.",
"Control whether the store's inventory should be made available for online sales or not.": "Controle si el inventario de la tienda debe estar disponible para ventas en línea o no.",
"Control whether the store requires the force scan during order packing or not.": "Controle si la tienda requiere forzar el escaneo durante en embale de la orden o no.",
"Copied": "Copiado { value }",
"Copied to clipboard": "Copiado al portapapeles",
"Copy ID": "Copiar ID",
Expand Down Expand Up @@ -340,6 +340,7 @@
"On": "Encendido",
"Online Order Fulfillment": "Cumplimiento de pedidos en línea",
"Only alphanumeric characters are allowed.": "solo se permiten caracteres alfanuméricos.",
"Only allow shipped 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 shipped 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.",
"Only methods for this carrier": "Solo metodos para este operador ",
"Only positive numbers are allowed.": "Solo se permiten numeros positivos.",
"Open": "Abierto",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"Auto reject related items": "Auto reject related items",
"Available to promise": "Available to promise",
"Back to Launchpad": "ランチパッドに戻る",
"Barcode Identifier": "Barcode Identifier",
"Billing Address 1": "請求先住所 1",
"Billing Address 2": "請求先住所 2",
"Billing City": "請求先市",
Expand Down Expand Up @@ -94,7 +95,6 @@
"Confirm": "確認",
"Configure the order fulfillment capacity of your facility.": "施設の注文処理能力を設定します。",
"Control whether the store's inventory should be made available for online sales or not.": "店舗の在庫をオンライン販売で利用可能にするかどうかを制御します。",
"Control whether the store requires the force scan during order packing or not.": "ストアが注文の梱包中に強制スキャンを必要とするかどうかを制御します。",
"Copied": "{ value }をコピーしました",
"Copied to clipboard": "クリップボードにコピーしました",
"Copy ID": "IDをコピー",
Expand Down Expand Up @@ -339,6 +339,7 @@
"On": "オン",
"Online Order Fulfillment": "オンライン注文処理",
"Only alphanumeric characters are allowed.": "英数字のみ使用できます。",
"Only allow shipped 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 shipped 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.",
"Only methods for this carrier": "この配送者の方法のみ",
"Only numeric values are allowed.": "数値のみ使用できます。",
"Open": "オープン",
Expand Down
18 changes: 18 additions & 0 deletions src/services/UtilService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,22 @@ const createForceScanSetting = async (payload: any): Promise<any> => {
});
}

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",
Expand Down Expand Up @@ -597,6 +613,7 @@ const isEnumExists = async (enumId: string): Promise<any> => {

export const UtilService = {
activateGiftCard,
createBarcodeIdentificationPref,
createForceScanSetting,
createPicklist,
createEnumeration,
Expand Down Expand Up @@ -633,5 +650,6 @@ export const UtilService = {
resetPicker,
deleteEnumeration,
updateEnumeration,
updateBarcodeIdentificationPref,
updateForceScanSetting
}
2 changes: 1 addition & 1 deletion src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const state: any = {
}

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

Expand Down
7 changes: 3 additions & 4 deletions src/store/modules/transferorder/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { hasError } from '@/adapter'
import * as types from './mutation-types'
import { escapeSolrSpecialChars, prepareOrderQuery } from '@/utils/solrHelper'
import logger from '@/logger'
import { getProductIdentificationValue, useProductIdentificationStore, translate } from '@hotwax/dxp-components'
import { getProductIdentificationValue, translate } from '@hotwax/dxp-components'
import { showToast } from "@/utils";
import { UtilService } from '@/services/UtilService'
import store from "@/store";
Expand Down Expand Up @@ -280,11 +280,10 @@ const actions: ActionTree<TransferOrderState, RootState> = {
// When there exists multiple line item for a single product, then may arise discrepancy in scanning
// since some items might be completed and some pending. Hence searching is done with status check.
const getProduct = store.getters['product/getProduct'];
const productIdentificationStore = useProductIdentificationStore()
const productIdentificationPref = productIdentificationStore.getProductIdentificationPref.primaryId
const barcodeIdentifier = store.getters['util/getBarcodeIdentificationPref'];

const item = state.current.items.find((orderItem: any) => {
const itemVal = getProductIdentificationValue(productIdentificationPref, getProduct(orderItem.productId)) ? getProductIdentificationValue(productIdentificationPref, getProduct(orderItem.productId)) : orderItem.internalName;
const itemVal = getProductIdentificationValue(barcodeIdentifier, getProduct(orderItem.productId)) ? getProductIdentificationValue(barcodeIdentifier, getProduct(orderItem.productId)) : getProduct(orderItem.productId)?.internalName;
return itemVal === payload && orderItem.statusId !== 'ITEM_COMPLETED' && orderItem.statusId !== 'ITEM_REJECTED' && orderItem.statusId !== 'ITEM_CANCELLED';
})
if(item){
Expand Down
5 changes: 5 additions & 0 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const actions: ActionTree<UserState, RootState> = {
await dispatch("fetchAllNotificationPrefs");
this.dispatch('util/findProductStoreShipmentMethCount')
this.dispatch('util/getForceScanSetting', preferredStore.productStoreId);
this.dispatch('util/fetchBarcodeIdentificationPref', preferredStore.productStoreId);
await dispatch('getNewRejectionApiConfig')
await dispatch('getPartialOrderRejectionConfig')
await dispatch('getCollateralRejectionConfig')
Expand Down Expand Up @@ -157,6 +158,7 @@ const actions: ActionTree<UserState, RootState> = {
this.dispatch("orderLookup/clearOrderLookup")
this.dispatch('user/clearNotificationState')
this.dispatch('util/updateForceScanStatus', false)
this.dispatch('util/updateBarcodeIdentificationPref', "internalName")
this.dispatch('user/clearPartialOrderRejectionConfig')
this.dispatch('user/clearCollateralRejectionConfig')
this.dispatch('transferorder/clearTransferOrdersList')
Expand Down Expand Up @@ -205,6 +207,8 @@ const actions: ActionTree<UserState, RootState> = {
this.dispatch('order/clearOrders')
await dispatch('getDisableShipNowConfig')
await dispatch('getDisableUnpackConfig')
this.dispatch('util/getForceScanSetting', preferredStore.productStoreId)
this.dispatch('util/fetchBarcodeIdentificationPref', preferredStore.productStoreId);
} catch(error: any) {
logger.error(error);
showToast(error?.message ? error.message : translate("Something went wrong"))
Expand Down Expand Up @@ -246,6 +250,7 @@ const actions: ActionTree<UserState, RootState> = {
await dispatch('getDisableUnpackConfig')
this.dispatch('util/findProductStoreShipmentMethCount')
this.dispatch('util/getForceScanSetting', payload.eComStore.productStoreId)
this.dispatch('util/fetchBarcodeIdentificationPref', payload.eComStore.productStoreId);
},

setUserPreference({ commit }, payload){
Expand Down
1 change: 1 addition & 0 deletions src/store/modules/util/UtilState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export default interface UtilState {
facilities: any;
shipmentGatewayConfigs: any;
isForceScanEnabled: boolean;
barcodeIdentificationPref: string;
}
125 changes: 125 additions & 0 deletions src/store/modules/util/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -585,9 +585,134 @@ const actions: ActionTree<UtilState, RootState> = {
}
commit(types.UTIL_FORCE_SCAN_STATUS_UPDATED, prefValue)
},

async fetchBarcodeIdentificationPref({ commit, dispatch }, eComStoreId) {
const payload = {
"inputFields": {
"productStoreId": eComStoreId,
"settingTypeEnumId": "BARCODE_IDEN_PREF"
},
"filterByDate": 'Y',
"entityName": "ProductStoreSetting",
"fieldList": ["settingValue", "fromDate"],
"viewSize": 1
}

try {
const resp = await UtilService.getProductStoreSetting(payload) as any
if(!hasError(resp)) {
const respValue = resp.data.docs[0].settingValue
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, respValue)
} else {
dispatch("createBarcodeIdentificationPref");
}
} catch(err) {
console.error(err)
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, "internalName")
}
},

async createBarcodeIdentificationPref({ commit }) {
const ecomStore = store.getters['user/getCurrentEComStore'];
const fromDate = Date.now()

try {
if(!await UtilService.isEnumExists("BARCODE_IDEN_PREF")) {
const resp = await UtilService.createEnumeration({
"enumId": "BARCODE_IDEN_PREF",
"enumTypeId": "PROD_STR_STNG",
"description": "Identification preference to be used for scanning items.",
"enumName": "Barcode Identification Preference",
"enumCode": "BARCODE_IDEN_PREF"
})

if(hasError(resp)) {
throw resp.data;
}
}

const params = {
fromDate,
"productStoreId": ecomStore.productStoreId,
"settingTypeEnumId": "BARCODE_IDEN_PREF",
"settingValue": "internalName"
}

await UtilService.createBarcodeIdentificationPref(params) as any
} catch(err) {
console.error(err)
}

// not checking for resp success and fail case as every time we need to update the state with the
// default value when creating a store setting
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, "internalName")
return fromDate;
},

async setBarcodeIdentificationPref({ commit, dispatch, state }, value) {
let prefValue = state.barcodeIdentificationPref
const eComStoreId = store.getters['user/getCurrentEComStore'].productStoreId;

// when selecting none as ecom store, not updating the pref as it's not possible to save pref with empty productStoreId
if(!eComStoreId) {
showToast(translate("Unable to update barcode identification preference since no product store config found."))
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, prefValue)
return;
}

let fromDate;

try {
const resp = await UtilService.getProductStoreSetting({
"inputFields": {
"productStoreId": eComStoreId,
"settingTypeEnumId": "BARCODE_IDEN_PREF"
},
"filterByDate": 'Y',
"entityName": "ProductStoreSetting",
"fieldList": ["fromDate"],
"viewSize": 1
}) as any
if(!hasError(resp)) {
fromDate = resp.data.docs[0]?.fromDate
}
} catch(err) {
console.error(err)
}

if(!fromDate) {
fromDate = await dispatch("createBarcodeIdentificationPref");
}

const params = {
"fromDate": fromDate,
"productStoreId": eComStoreId,
"settingTypeEnumId": "BARCODE_IDEN_PREF",
"settingValue": value
}

try {
const resp = await UtilService.updateBarcodeIdentificationPref(params) as any

if((!hasError(resp))) {
showToast(translate("Barcode identification preference updated successfully."))
prefValue = value
} else {
throw resp.data;
}
} catch(err) {
showToast(translate("Failed to update barcode identification preference."))
console.error(err)
}
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, prefValue)
},

async updateForceScanStatus({ commit }, payload) {
commit(types.UTIL_FORCE_SCAN_STATUS_UPDATED, payload)
},

async updateBarcodeIdentificationPref({ commit }, payload) {
commit(types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED, payload)
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/store/modules/util/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const getters: GetterTree <UtilState, RootState> = {
},
isForceScanEnabled(state) {
return state.isForceScanEnabled
},
getBarcodeIdentificationPref(state) {
return state.barcodeIdentificationPref
}
}
export default getters;
3 changes: 2 additions & 1 deletion src/store/modules/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const utilModule: Module<UtilState, RootState> = {
productStores: [],
facilities: [],
shipmentGatewayConfigs: [],
isForceScanEnabled: false
isForceScanEnabled: false,
barcodeIdentificationPref: "internalName"
},
getters,
actions,
Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/util/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export const UTIL_FACILITIES_UPDATED = SN_UTIL + '/FACILITIES_UPDATED'
export const UTIL_PRODUCT_STORES_UPDATED = SN_UTIL + '/PRODUCT_STORES_UPDATED'
export const UTIL_SHIPMENT_GATEWAY_CONFIGS_UPDATED = SN_UTIL + '/SHIPMENT_GATEWAY_CONFIGS_UPDATED'
export const UTIL_FORCE_SCAN_STATUS_UPDATED = SN_UTIL + '/FORCE_SCAN_STATUS_UPDATED'

export const UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED = SN_UTIL + '/BARCODE_IDENTIFICATION_PREF_UPDATED'
3 changes: 3 additions & 0 deletions src/store/modules/util/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const mutations: MutationTree <UtilState> = {
},
[types.UTIL_FORCE_SCAN_STATUS_UPDATED](state, payload) {
state.isForceScanEnabled = payload
},
[types.UTIL_BARCODE_IDENTIFICATION_PREF_UPDATED](state, payload) {
state.barcodeIdentificationPref = payload
}
}
export default mutations;
Loading

0 comments on commit e9e3503

Please sign in to comment.