Skip to content

Commit

Permalink
Improved: fetching qoh based on the product store settings
Browse files Browse the repository at this point in the history
  • Loading branch information
amansinghbais committed Jan 20, 2025
1 parent 90e45a3 commit 59befca
Showing 1 changed file with 35 additions and 15 deletions.
50 changes: 35 additions & 15 deletions src/views/HardCountDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,23 @@ async function addProductToItemsList() {
async function findProductFromIdentifier(scannedValue: string, newItem: any ) {
const product = await store.dispatch("product/fetchProductByIdentification", { scannedValue })
let importItemSeqId = "" as any;
if(product?.productId) importItemSeqId = await addProductToCount(product.productId)
if(productStoreSettings.value['showQoh']) {
let updatedItem = {} as any;
if(product?.productId) updatedItem = await addProductToCount(product.productId)
setTimeout(() => {
updateCurrentItemInList(updatedItem, scannedValue);
}, 1000)
} else {
let importItemSeqId = "" as any;
if(product?.productId) importItemSeqId = await addProductToCount(product.productId)
setTimeout(() => {
updateCurrentItemInList({...newItem, importItemSeqId, ...product}, scannedValue);
}, 1000)
}
setTimeout(() => {
updateCurrentItemInList({...newItem, importItemSeqId, ...product}, scannedValue);
}, 1000)
}
async function addProductToCount(productId: any) {
Expand All @@ -501,14 +511,19 @@ async function addProductToCount(productId: any) {
if(!hasError(resp) && resp.data?.itemList?.length) {
const importItemSeqId = resp.data.itemList[0].importItemSeqId
return importItemSeqId
// resp = await CountService.fetchCycleCountItems({ inventoryCountImportId: cycleCount.value.inventoryCountImportId, importItemSeqId, pageSize: 1 })
// if(!hasError(resp)) {
// newProduct = resp.data.itemList[0];
// } else {
// throw resp;
// }
if(productStoreSettings.value['showQoh']) {
resp = await CountService.fetchCycleCountItems({ inventoryCountImportId: cycleCount.value.inventoryCountImportId, importItemSeqId, pageSize: 1 })
if(!hasError(resp)) {
newProduct = resp.data.itemList[0];
return newProduct
} else {
throw resp;
}
} else {
return importItemSeqId
}
} else {
throw resp;
}
Expand Down Expand Up @@ -702,8 +717,13 @@ async function matchProduct(currentProduct: any) {
addProductModal.onDidDismiss().then(async (result) => {
if(result.data?.selectedProduct) {
const product = result.data.selectedProduct
const importItemSeqId = await addProductToCount(product.productId)
await updateCurrentItemInList({ ...currentProduct, ...product, importItemSeqId }, currentProduct.scannedId);
if(productStoreSettings.value['showQoh']) {
const newItem = await addProductToCount(product.productId)
await updateCurrentItemInList(newItem, currentProduct.scannedId);
} else {
const importItemSeqId = await addProductToCount(product.productId)
await updateCurrentItemInList({ ...currentProduct, ...product, importItemSeqId }, currentProduct.scannedId);
}
}
})
Expand Down

0 comments on commit 59befca

Please sign in to comment.