Skip to content

Commit

Permalink
Merge pull request #636 from R-Sourabh/#635-pending-count-complete-check
Browse files Browse the repository at this point in the history
 Improved: Added a check to allow completing the pending count only when no items are in the "created" state(#635)
  • Loading branch information
ravilodhi authored Jan 17, 2025
2 parents 37a0e2e + 65a1fca commit a4ba828
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@
"Total variance": "Total variance",
"total variance": "total variance",
"UNMATCHED": "UNMATCHED",
"Unable to complete the count as some items are still pending review. Please review the updated item list and try again": "Unable to complete the count as some items are still pending review. Please review the updated item list and try again",
"Update": "Update",
"Update count": "Update count",
"Upload count": "Upload count",
Expand Down
9 changes: 9 additions & 0 deletions src/services/CountService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ const fetchCycleCountItems = async (payload: any): Promise<any> => {
})
}

const fetchCycleCountItemsCount = async (payload: any): Promise<any> => {
return api({
url: `cycleCounts/${payload.inventoryCountImportId}/items/count`,
method: "GET",
params: payload
})
}

const fetchBulkCycleCountItems = async (payload: any): Promise<any> => {
return api({
url: "cycleCounts/items",
Expand Down Expand Up @@ -176,6 +184,7 @@ export const CountService = {
fetchCycleCountStats,
fetchCycleCounts,
fetchCycleCountItems,
fetchCycleCountItemsCount,
fetchCycleCountsTotal,
recountItems,
updateCount,
Expand Down
26 changes: 21 additions & 5 deletions src/views/PendingReviewDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,30 @@ async function recountItem(item?: any) {
async function completeCount() {
try {
await CountService.updateCycleCount({
inventoryCountImportId: currentCycleCount.value.countId,
statusId: "INV_COUNT_COMPLETED"
const resp = await CountService.fetchCycleCountItemsCount({
inventoryCountImportId: props?.inventoryCountImportId,
statusId: "INV_COUNT_CREATED",
})
router.push("/closed")
showToast(translate("Count has been marked as completed"))
if(!hasError(resp) && resp.data?.count > 0) {
await fetchCountItems();
showToast(translate("Unable to complete the count as some items are still pending review. Please review the updated item list and try again"))
return;
}
try {
await CountService.updateCycleCount({
inventoryCountImportId: currentCycleCount.value.countId,
statusId: "INV_COUNT_COMPLETED"
})
router.push("/closed")
showToast(translate("Count has been marked as completed"))
} catch(err) {
showToast(translate("Failed to complete cycle count"))
}
} catch(err) {
showToast(translate("Failed to complete cycle count"))
logger.error(err)
}
}
Expand Down

0 comments on commit a4ba828

Please sign in to comment.