From 9dbde75ce0fda18724f5156aaa28bb2580972f11 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 30 Dec 2024 10:55:50 +0530 Subject: [PATCH 1/2] Reverted: download count confirmation alert (#567) --- src/components/DownloadClosedCountModal.vue | 134 +++++++++----------- src/locales/en.json | 3 - 2 files changed, 60 insertions(+), 77 deletions(-) diff --git a/src/components/DownloadClosedCountModal.vue b/src/components/DownloadClosedCountModal.vue index 6adc0849..2e58c248 100644 --- a/src/components/DownloadClosedCountModal.vue +++ b/src/components/DownloadClosedCountModal.vue @@ -217,80 +217,66 @@ async function fetchProducts(productIds: any){ } async function downloadCSV() { - const alert = await alertController.create({ - header: translate("Download closed counts"), - message: translate("Are you sure you want to download the cycle counts?"), - buttons: [{ - text: translate("Cancel"), - role: 'cancel', - }, { - text: translate("Download"), - handler: async () => { - await modalController.dismiss({ dismissed: true }); - await alert.dismiss(); - emitter.emit("presentLoader", { message: "Preparing file to downlaod...", backdropDismiss: true }); - - const facilityDetails = getFacilityDetails(); - const selectedFieldMappings: any = { - countId: "inventoryCountImportId", - countName: "countImportName", - acceptedByUser: "acceptedByUserLoginId", - createdDate: "createdDate", - lastSubmittedDate: "lastSubmittedDate", - closedDate: "closedDate", - facility: "facilityId", - primaryProductId: "primaryProductId", - secondaryProductId: "secondaryProductId", - lineStatus: "statusId", - expectedQuantity: "qoh", - countedQuantity: "quantity", - variance: "varianceQuantityOnHand", - }; - - const selectedData = Object.keys(selectedFields.value).filter((field) => selectedFields.value[field]); - - const cycleCountItems = await fetchBulkCycleCountItems(); - await fetchProducts([... new Set(cycleCountItems.map((item: any) => item.productId))]); - - const downloadData = await Promise.all(cycleCountItems.map(async (item: any) => { - const facility = facilityDetails[item?.facilityId]; - const product = getProduct.value(item.productId) - - if(product.productId) { - const cycleCountDetails = selectedData.reduce((details: any, property: any) => { - if (property === 'createdDate') { - details[property] = getDateWithOrdinalSuffix(item.createdDate); - } else if (property === 'lastSubmittedDate') { - details[property] = getLastSubmittedDate(item); - } else if (property === 'closedDate') { - details[property] = getClosedDate(item); - } else if (property === 'facility') { - details[property] = facility[selectedFacilityField.value]; - } else if (property === 'primaryProductId') { - details[property] = getProductIdentificationValue(selectedPrimaryProductId.value, product); - } else if (property === 'secondaryProductId') { - details[property] = getProductIdentificationValue(selectedSecondaryProductId.value, product); - } else if (property === 'countName' && item.countImportName) { - details[property] = item.countImportName; - } else if (property === "lineStatus") { - details[property] = item.itemStatusId === 'INV_COUNT_COMPLETED' ? 'Completed' : item.itemStatusId === 'INV_COUNT_REJECTED' ? 'Rejected' : item.itemStatusId; - } else { - details[property] = item[selectedFieldMappings[property]]; - } - return details; - }, {}); - - return cycleCountDetails; - } - })); - - const fileName = `CycleCounts-${DateTime.now().toLocaleString(DateTime.DATETIME_MED_WITH_SECONDS)}.csv`; - await jsonToCsv(downloadData, { download: true, name: fileName }); - emitter.emit("dismissLoader") - } - }] - }); - return alert.present(); + await modalController.dismiss({ dismissed: true }); + emitter.emit("presentLoader", { message: "Preparing file to downlaod...", backdropDismiss: true }); + + const facilityDetails = getFacilityDetails(); + const selectedFieldMappings: any = { + countId: "inventoryCountImportId", + countName: "countImportName", + acceptedByUser: "acceptedByUserLoginId", + createdDate: "createdDate", + lastSubmittedDate: "lastSubmittedDate", + closedDate: "closedDate", + facility: "facilityId", + primaryProductId: "primaryProductId", + secondaryProductId: "secondaryProductId", + lineStatus: "statusId", + expectedQuantity: "qoh", + countedQuantity: "quantity", + variance: "varianceQuantityOnHand", + }; + + const selectedData = Object.keys(selectedFields.value).filter((field) => selectedFields.value[field]); + + const cycleCountItems = await fetchBulkCycleCountItems(); + await fetchProducts([... new Set(cycleCountItems.map((item: any) => item.productId))]); + + const downloadData = await Promise.all(cycleCountItems.map(async (item: any) => { + const facility = facilityDetails[item?.facilityId]; + const product = getProduct.value(item.productId) + + if(product.productId) { + const cycleCountDetails = selectedData.reduce((details: any, property: any) => { + if (property === 'createdDate') { + details[property] = getDateWithOrdinalSuffix(item.createdDate); + } else if (property === 'lastSubmittedDate') { + details[property] = getLastSubmittedDate(item); + } else if (property === 'closedDate') { + details[property] = getClosedDate(item); + } else if (property === 'facility') { + details[property] = facility[selectedFacilityField.value]; + } else if (property === 'primaryProductId') { + details[property] = getProductIdentificationValue(selectedPrimaryProductId.value, product); + } else if (property === 'secondaryProductId') { + details[property] = getProductIdentificationValue(selectedSecondaryProductId.value, product); + } else if (property === 'countName' && item.countImportName) { + details[property] = item.countImportName; + } else if (property === "lineStatus") { + details[property] = item.itemStatusId === 'INV_COUNT_COMPLETED' ? 'Completed' : item.itemStatusId === 'INV_COUNT_REJECTED' ? 'Rejected' : item.itemStatusId; + } else { + details[property] = item[selectedFieldMappings[property]]; + } + return details; + }, {}); + + return cycleCountDetails; + } + })); + + const fileName = `CycleCounts-${DateTime.now().toLocaleString(DateTime.DATETIME_MED_WITH_SECONDS)}.csv`; + await jsonToCsv(downloadData, { download: true, name: fileName }); + emitter.emit("dismissLoader") } diff --git a/src/locales/en.json b/src/locales/en.json index 22206690..0aabce58 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -19,7 +19,6 @@ "Auto assign to stores": "Auto assign to stores", "Average variance": "Average variance", "Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to {timeZoneId}?", - "Are you sure you want to download the cycle counts?": "Are you sure you want to download the cycle counts?", "Assigned": "Assigned", "Assign": "Assign", "Assign a facility to the cycle count": "Assign a facility to the cycle count", @@ -86,9 +85,7 @@ "count name": "count name", "eCom Store": "eCom Store", "due date": "due date", - "Download": "Download", "Download results": "Download results", - "Download closed counts": "Download closed counts", "Enter a SKU, or use the barcode scanner to search a product": "Enter a SKU, or use the barcode scanner to search a product", "Enter a valid cycle count name": "Enter a valid cycle count name", "Enter a valid product sku": "Enter a valid product sku", From 3dbab8744e2a2fb80a963040cb6fb98877d9845f Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 30 Dec 2024 16:02:44 +0530 Subject: [PATCH 2/2] Reverted: unwanted imports in the app (#567) --- src/components/DownloadClosedCountModal.vue | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/DownloadClosedCountModal.vue b/src/components/DownloadClosedCountModal.vue index 2e58c248..7c53912b 100644 --- a/src/components/DownloadClosedCountModal.vue +++ b/src/components/DownloadClosedCountModal.vue @@ -92,7 +92,6 @@ import { IonSelectOption, IonTitle, IonToolbar, - alertController, modalController } from "@ionic/vue"; import emitter from "@/event-bus" @@ -108,7 +107,6 @@ import store from "@/store"; const cycleCountStats = computed(() => (id: string) => store.getters["count/getCycleCountStats"](id)) const facilities = computed(() => store.getters["user/getFacilities"]) -const currentFacility = computed(() => store.getters["user/getCurrentFacility"]) const getProduct = computed(() => (id: string) => store.getters["product/getProduct"](id)) const query = computed(() => store.getters["count/getQuery"])