diff --git a/src/views/CountDetail.vue b/src/views/CountDetail.vue index 2736526d..58c57714 100644 --- a/src/views/CountDetail.vue +++ b/src/views/CountDetail.vue @@ -106,14 +106,14 @@ {{ translate("Variance") }} - {{ getVariance(product) }} + {{ getVariance(product, false) }} @@ -167,7 +167,7 @@ - + @@ -255,9 +255,9 @@ const itemsList = computed(() => { if (selectedSegment.value === 'all') { return cycleCountItems.value.itemList; } else if (selectedSegment.value === 'pending') { - return cycleCountItems.value.itemList.filter(item =>!item.quantity); + return cycleCountItems.value.itemList.filter(item =>(item.quantity === undefined || item.quantity === null)); } else if (selectedSegment.value === 'counted') { - return cycleCountItems.value.itemList.filter(item => item.quantity); + return cycleCountItems.value.itemList.filter(item => item.quantity >= 0); } else if (selectedSegment.value === 'notCounted') { return cycleCountItems.value.itemList.filter(item => !item.quantity && item.statusId === "INV_COUNT_REVIEW"); } else if (selectedSegment.value === 'rejected') { @@ -275,7 +275,6 @@ let cycleCount = ref([]); const queryString = ref(''); const inputCount = ref(''); -const variance = ref(0); const isFirstItem = ref(true); const isLastItem = ref(false); const isScrolling = ref(false); @@ -284,7 +283,6 @@ let hasUnsavedChanges = ref(false); // Update variance value when component is updated, ensuring it's prefilled with correct value when page loads. onUpdated(() => { - calculateVariance(); isFirstItem.value = true isLastItem.value = false }) @@ -511,22 +509,16 @@ async function changeProduct(direction) { isScrolling.value = false; } -async function calculateVariance() { - if (!product.value || !inputCount.value) { - variance.value = 0; - } else { - variance.value = parseInt(inputCount.value) - parseInt(product.value.qoh) || 0; - } -} -function getVariance(item , count) { +function getVariance(item , isRecounting) { const qty = item.quantity - if(!qty) { + if(isRecounting && inputCount.value === "") return 0; + if(!isRecounting && !qty && qty !== 0) { return 0; } // As the item is rejected there is no meaning of displaying variance hence added check for REJECTED item status - return item.itemStatusId === "INV_COUNT_REJECTED" ? 0 : parseInt(count ? count : qty) - parseInt(item.qoh) + return item.itemStatusId === "INV_COUNT_REJECTED" ? 0 : parseInt(isRecounting ? inputCount.value : qty) - parseInt(item.qoh) } async function saveCount(currentProduct) {