Skip to content

Commit

Permalink
Merge pull request #607 from amansinghbais/#606
Browse files Browse the repository at this point in the history
Improved: support for matching of products for the identifiers not in goodIdentifications (#606)
  • Loading branch information
ravilodhi authored Jan 15, 2025
2 parents 73ab732 + 1e7f995 commit 84aa3c4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 3 additions & 1 deletion src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ const actions: ActionTree<ProductState, RootState> = {
async fetchProductByIdentification ( { commit, state }, payload) {
const cachedProductIds = Object.keys(state.cached);
if(cachedProductIds.includes(payload.scannedValue)) return;
const productIdentifications = process.env.VUE_APP_PRDT_IDENT ? JSON.parse(JSON.stringify(process.env.VUE_APP_PRDT_IDENT)) : []

const productStoreSettings = store.getters["user/getProductStoreSettings"];
const barcodeIdentification = productStoreSettings["barcodeIdentificationPref"]
let resp;

try {
resp = await ProductService.fetchProducts({
"filters": [`goodIdentifications: ${productStoreSettings["barcodeIdentificationPref"]}/${payload.scannedValue}`],
"filters": [productIdentifications.includes(barcodeIdentification) ? `${barcodeIdentification}: ${payload.scannedValue}` : `goodIdentifications: ${barcodeIdentification}/${payload.scannedValue}`],
"viewSize": 1
})
if(resp.status === 200 && !hasError(resp)) {
Expand Down
8 changes: 4 additions & 4 deletions src/views/CountDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ const scrollingContainerRef = ref();
onIonViewDidEnter(async() => {
emitter.emit("presentLoader");
await Promise.allSettled([await fetchCycleCount(), store.dispatch("count/fetchCycleCountItems", { inventoryCountImportId : props?.id, isSortingRequired: true })])
await Promise.allSettled([await fetchCycleCount(), store.dispatch("count/fetchCycleCountItems", { inventoryCountImportId : props?.id, isSortingRequired: true }), store.dispatch("user/getProductStoreSetting")])
selectedSegment.value = 'all';
queryString.value = '';
previousItem = itemsList.value[0]
Expand Down Expand Up @@ -376,7 +376,7 @@ function selectSearchBarText(event) {
}
async function scanProduct() {
if(!queryString.value) {
if(!queryString.value.trim()) {
showToast(translate("Please provide a valid barcode identifier."))
return;
}
Expand All @@ -389,14 +389,14 @@ async function scanProduct() {
if(cycleCount.value.statusId === 'INV_COUNT_ASSIGNED') {
selectedItem = itemsList.value.find((item) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, cachedProducts[item.productId]) : item.internalName;
return itemVal === queryString.value && item.itemStatusId === "INV_COUNT_CREATED";
return itemVal === queryString.value.trim() && item.itemStatusId === "INV_COUNT_CREATED";
});
}
if(!selectedItem || !Object.keys(selectedItem).length) {
selectedItem = itemsList.value.find((item) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, cachedProducts[item.productId]) : item.internalName;
return itemVal === queryString.value;
return itemVal === queryString.value.trim();
});
}
Expand Down
14 changes: 7 additions & 7 deletions src/views/HardCountDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ const scrollingContainerRef = ref();
onIonViewDidEnter(async() => {
emitter.emit("presentLoader");
await Promise.allSettled([fetchCycleCount(), await store.dispatch("count/fetchCycleCountItems", { inventoryCountImportId : props?.id, isSortingRequired: false })])
await Promise.allSettled([fetchCycleCount(), await store.dispatch("count/fetchCycleCountItems", { inventoryCountImportId : props?.id, isSortingRequired: false }), store.dispatch("user/getProductStoreSetting")])
previousItem = itemsList.value[0];
await store.dispatch("product/currentProduct", itemsList.value?.length ? itemsList.value[0] : {})
barcodeInputRef.value?.$el?.setFocus();
Expand Down Expand Up @@ -357,7 +357,7 @@ function removeCountItem(current: any) {
async function scanProduct() {
let isNewlyAdded = false;
if(!queryString.value) {
if(!queryString.value.trim()) {
showToast(translate("Please provide a valid barcode identifier."))
return;
}
Expand All @@ -367,18 +367,18 @@ async function scanProduct() {
selectedItem = itemsList.value.find((item: any) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, getProduct.value(item.productId)) : item.internalName;
return itemVal === queryString.value && item.itemStatusId === "INV_COUNT_CREATED";
return itemVal === queryString.value.trim() && item.itemStatusId === "INV_COUNT_CREATED";
});
if(!selectedItem || !Object.keys(selectedItem).length) {
selectedItem = itemsList.value.find((item: any) => {
const itemVal = barcodeIdentifier ? getProductIdentificationValue(barcodeIdentifier, getProduct.value(item.productId)) : item.internalName;
return itemVal === queryString.value;
return itemVal === queryString.value.trim();
});
}
if(!selectedItem || !Object.keys(selectedItem).length) {
selectedItem = itemsList.value.find((item: any) => item.scannedId === queryString.value)
selectedItem = itemsList.value.find((item: any) => item.scannedId === queryString.value.trim())
}
if(!selectedItem || !Object.keys(selectedItem).length) {
Expand Down Expand Up @@ -417,7 +417,7 @@ function scrollToProduct(product: any) {
async function addProductToItemsList() {
const newItem = {
scannedId: queryString.value,
scannedId: queryString.value.trim(),
isMatching: true,
itemStatusId: "INV_COUNT_CREATED",
statusId: "INV_COUNT_ASSIGNED",
Expand All @@ -428,7 +428,7 @@ async function addProductToItemsList() {
items.push(newItem);
await store.dispatch("count/updateCycleCountItems", items);
initializeObserver()
findProductFromIdentifier(queryString.value);
findProductFromIdentifier(queryString.value.trim());
return newItem;
}
Expand Down

0 comments on commit 84aa3c4

Please sign in to comment.