From 9df9dfce4f5fbd40609f4290ce558d1803fc27e7 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Tue, 29 Aug 2023 12:21:35 +0530 Subject: [PATCH 01/13] Implemented: functionality which allows users to manually close purchase order items when they receive them (#212) --- src/locales/en.json | 6 + src/services/OrderService.ts | 10 +- src/views/PurchaseOrderDetail.vue | 33 +++-- src/views/closePurchaseOrderModal.vue | 171 ++++++++++++++++++++++++++ 4 files changed, 209 insertions(+), 11 deletions(-) create mode 100644 src/views/closePurchaseOrderModal.vue diff --git a/src/locales/en.json b/src/locales/en.json index ddf1fb7e..2419e066 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -6,6 +6,7 @@ "App": "App", "Authenticating": "Authenticating", "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 have received the purchase order for the selected items? Once closed, the shipments for the selected items wont be available for receiving later.": "Are you sure you have received the purchase order for the selected items? { space } Once closed, the shipments for the selected items won't be available for receiving later.", "Arrival date": "Arrival date", "Cancel": "Cancel", "Change": "Change", @@ -14,6 +15,7 @@ "Complete": "Complete", "Confirm": "Confirm", "Copied": "Copied { value }", + "Close purchase order items": "Close purchase order items", "eCom Store": "eCom Store", "Enter a custom date time format that you want to use when uploading documents to HotWax Commerce.": "Enter a custom date time format that you want to use when uploading documents to HotWax Commerce.", "External ID": "External ID", @@ -59,8 +61,10 @@ "Purchase Order Details": "Purchase Order Details", "Purchase Orders": "Purchase Orders", "Qty": "Qty", + "Receive": "Receive", "Receive All": "Receive All", "Receive inventory": "Receive inventory", + "Receive And Close": "Receive And Close", "received": "received", "Receive Shipment": "Receive Shipment", "Receiving": "Receiving", @@ -82,6 +86,7 @@ "Search time zones": "Search time zones", "Search SKU or product name": "Search SKU or product name", "Secondary Product Identifier": "Secondary Product Identifier", + "Select all": "Select all", "Select facility": "Select facility", "Select store": "Select store", "Select time zone": "Select time zone", @@ -107,6 +112,7 @@ "This return has been and cannot be edited.": "This return has been {status} and cannot be edited.", "Timezone": "Timezone", "Time zone updated successfully": "Time zone updated successfully", + "To close the purchase order, select all.": "To close the purchase order, select all.", "Unable to update product identifier preference": "Unable to update product identifier preference", "Update time zone": "Update time zone", "Username": "Username", diff --git a/src/services/OrderService.ts b/src/services/OrderService.ts index 676cbd23..1d0b4e18 100644 --- a/src/services/OrderService.ts +++ b/src/services/OrderService.ts @@ -32,10 +32,18 @@ const fetchPOHistory = async (payload: any): Promise => { }) } +const updatePOItemStatus = async (payload: any): Promise => { + return api({ + url: "/changeOrderItemStatus", + method: "POST", + data: payload + }) +} export const OrderService = { fetchPurchaseOrders, fetchPODetail, createPurchaseShipment, - fetchPOHistory + fetchPOHistory, + updatePOItemStatus } \ No newline at end of file diff --git a/src/views/PurchaseOrderDetail.vue b/src/views/PurchaseOrderDetail.vue index aca514f6..41af5dac 100644 --- a/src/views/PurchaseOrderDetail.vue +++ b/src/views/PurchaseOrderDetail.vue @@ -91,13 +91,16 @@ - - - - - - + + + + + {{ $t("Receive And Close") }} + {{ $t("Receive") }} + + + @@ -111,8 +114,7 @@ import { IonChip, IonContent, IonHeader, - IonFab, - IonFabButton, + IonFooter, IonIcon, IonItem, IonInput, @@ -133,6 +135,7 @@ import { useStore, mapGetters } from 'vuex'; import { useRouter } from 'vue-router'; import Scanner from "@/components/Scanner.vue" import AddProductToPOModal from '@/views/AddProductToPOModal.vue' +import closePurchaseOrderModal from '@/views/closePurchaseOrderModal.vue' import LocationPopover from '@/components/LocationPopover.vue' import ImageModal from '@/components/ImageModal.vue'; import { copyToClipboard, hasError, productHelpers } from '@/utils'; @@ -150,8 +153,7 @@ export default defineComponent({ IonChip, IonContent, IonHeader, - IonFab, - IonFabButton, + IonFooter, IonIcon, IonItem, IonInput, @@ -241,6 +243,17 @@ export default defineComponent({ }); return alert.present(); }, + async saveAndClosePODetails() { + const modal = await modalController.create({ + component: closePurchaseOrderModal, + componentProps: { + createShipment: this.createShipment, + isEligibleForCreatingShipment: this.isEligibileForCreatingShipment + } + }) + + return modal.present(); + }, async createShipment() { const eligibleItems = this.order.items.filter((item: any) => item.quantityAccepted > 0) const resp = await this.store.dispatch('order/createPurchaseShipment', { items: eligibleItems, orderId: this.order.orderId }) diff --git a/src/views/closePurchaseOrderModal.vue b/src/views/closePurchaseOrderModal.vue new file mode 100644 index 00000000..d181d5ab --- /dev/null +++ b/src/views/closePurchaseOrderModal.vue @@ -0,0 +1,171 @@ + + + \ No newline at end of file From 50a42214eb65440a9269eac438d9c8bd82ef1e38 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 11 Sep 2023 10:33:02 +0530 Subject: [PATCH 02/13] Improved: code for closePO's modal (#212) --- src/locales/en.json | 1 + src/services/OrderService.ts | 2 +- ...rModal.vue => ClosePurchaseOrderModal.vue} | 19 +++++++++++-------- src/views/PurchaseOrderDetail.vue | 10 +++++----- 4 files changed, 18 insertions(+), 14 deletions(-) rename src/views/{closePurchaseOrderModal.vue => ClosePurchaseOrderModal.vue} (88%) diff --git a/src/locales/en.json b/src/locales/en.json index 2419e066..9c794dd6 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -60,6 +60,7 @@ "Purchase Order": "Purchase Order", "Purchase Order Details": "Purchase Order Details", "Purchase Orders": "Purchase Orders", + "Purchase order update failed. Verify your internet connection and retry.": "Purchase order update failed. Verify your internet connection and retry.", "Qty": "Qty", "Receive": "Receive", "Receive All": "Receive All", diff --git a/src/services/OrderService.ts b/src/services/OrderService.ts index 1d0b4e18..a10e0bc1 100644 --- a/src/services/OrderService.ts +++ b/src/services/OrderService.ts @@ -34,7 +34,7 @@ const fetchPOHistory = async (payload: any): Promise => { const updatePOItemStatus = async (payload: any): Promise => { return api({ - url: "/changeOrderItemStatus", + url: "service/changeOrderItemStatus", method: "POST", data: payload }) diff --git a/src/views/closePurchaseOrderModal.vue b/src/views/ClosePurchaseOrderModal.vue similarity index 88% rename from src/views/closePurchaseOrderModal.vue rename to src/views/ClosePurchaseOrderModal.vue index d181d5ab..05f5663c 100644 --- a/src/views/closePurchaseOrderModal.vue +++ b/src/views/ClosePurchaseOrderModal.vue @@ -20,7 +20,7 @@ - +

{{ productHelpers.getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.productId)) }}

@@ -36,7 +36,7 @@ - + @@ -68,8 +68,9 @@ import { closeOutline, checkmarkCircle, arrowBackOutline, saveOutline } from 'io import { mapGetters } from 'vuex' import { ShopifyImg } from '@hotwax/dxp-components'; import { Actions, hasPermission } from '@/authorization' -import { productHelpers } from '@/utils'; +import { productHelpers, showToast } from '@/utils'; import { OrderService } from "@/services/OrderService"; +import { translate } from '@/i18n' export default defineComponent({ name: "closePurchaseOrder", @@ -116,7 +117,7 @@ export default defineComponent({ closeModal() { modalController.dismiss({ dismissed: true }); }, - async saveAndClosePODetails() { + async confirmSave() { const alert = await alertController.create({ header: this.$t('Close purchase order items'), message: this.$t('Are you sure you have received the purchase order for the selected items? Once closed, the shipments for the selected items wont be available for receiving later.', { space: '

' }), @@ -128,7 +129,7 @@ export default defineComponent({ text: this.$t('Proceed'), role: 'proceed', handler: async () => { - if(this.isEligibileForCreatingShipment){ + if(this.isEligibileForCreatingShipment()){ await this.createShipment() } await this.updatePOItemStatus() @@ -139,23 +140,25 @@ export default defineComponent({ }, async updatePOItemStatus() { const eligibleItems = this.order.items.filter((item: any) => item.isChecked == true) - const isAllSelected = this.isAllItemSelected(eligibleItems) + const areAllSelected = this.areAllItemSelected(eligibleItems) eligibleItems.forEach(async (item:any) => { - if(isAllSelected){ + if(areAllSelected){ await OrderService.updatePOItemStatus({orderId: item.orderId, orderItemSeqId: item.orderItemSeqId}) .catch((err)=>{ console.error(err); + showToast(translate("Purchase order update failed. Verify your internet connection and retry.")) }) }else { await OrderService.updatePOItemStatus({orderId: item.orderId, statusId: "ITEM_COMPLETED", orderItemSeqId: item.orderItemSeqId}) .catch((err)=>{ console.error(err); + showToast(translate("Purchase order update failed. Verify your internet connection and retry.")) }) } }); }, - isAllItemSelected(eligibleItems:any) { + areAllItemSelected(eligibleItems:any) { return eligibleItems.length === this.order.items.filter((item:any) => item.orderItemStatusId != "ITEM_COMPLETED" || item.orderItemStatusId != "ITEM_REJECTED").length }, isEligibleToClosePOItems() { diff --git a/src/views/PurchaseOrderDetail.vue b/src/views/PurchaseOrderDetail.vue index 41af5dac..2c4604a1 100644 --- a/src/views/PurchaseOrderDetail.vue +++ b/src/views/PurchaseOrderDetail.vue @@ -96,7 +96,7 @@ - {{ $t("Receive And Close") }} + {{ $t("Receive And Close") }} {{ $t("Receive") }} @@ -135,7 +135,7 @@ import { useStore, mapGetters } from 'vuex'; import { useRouter } from 'vue-router'; import Scanner from "@/components/Scanner.vue" import AddProductToPOModal from '@/views/AddProductToPOModal.vue' -import closePurchaseOrderModal from '@/views/closePurchaseOrderModal.vue' +import ClosePurchaseOrderModal from '@/views/ClosePurchaseOrderModal.vue' import LocationPopover from '@/components/LocationPopover.vue' import ImageModal from '@/components/ImageModal.vue'; import { copyToClipboard, hasError, productHelpers } from '@/utils'; @@ -243,12 +243,12 @@ export default defineComponent({ }); return alert.present(); }, - async saveAndClosePODetails() { + async closePO() { const modal = await modalController.create({ - component: closePurchaseOrderModal, + component: ClosePurchaseOrderModal, componentProps: { createShipment: this.createShipment, - isEligibleForCreatingShipment: this.isEligibileForCreatingShipment + isEligibileForCreatingShipment: this.isEligibileForCreatingShipment } }) From 556f7d1a4a44883116d4f7a4d2785a608ed83f3b Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 11 Sep 2023 10:43:01 +0530 Subject: [PATCH 03/13] Improved: code for close PO items (#212) --- src/locales/en.json | 4 +-- src/views/ClosePurchaseOrderModal.vue | 52 +++++++++++++-------------- src/views/PurchaseOrderDetail.vue | 4 +-- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 9c794dd6..4df7dc43 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -5,8 +5,8 @@ "Add to Shipment": "Add to Shipment", "App": "App", "Authenticating": "Authenticating", - "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 have received the purchase order for the selected items? Once closed, the shipments for the selected items wont be available for receiving later.": "Are you sure you have received the purchase order for the selected items? { space } Once closed, the shipments for the selected items won't be available for receiving later.", + "Are you sure you want to change the time zone to?": "Are you sure you want to change the time zone to {timeZoneId}?", "Arrival date": "Arrival date", "Cancel": "Cancel", "Change": "Change", @@ -64,8 +64,8 @@ "Qty": "Qty", "Receive": "Receive", "Receive All": "Receive All", - "Receive inventory": "Receive inventory", "Receive And Close": "Receive And Close", + "Receive inventory": "Receive inventory", "received": "received", "Receive Shipment": "Receive Shipment", "Receiving": "Receiving", diff --git a/src/views/ClosePurchaseOrderModal.vue b/src/views/ClosePurchaseOrderModal.vue index 05f5663c..639d8d91 100644 --- a/src/views/ClosePurchaseOrderModal.vue +++ b/src/views/ClosePurchaseOrderModal.vue @@ -44,72 +44,72 @@ \ No newline at end of file diff --git a/src/views/PurchaseOrderDetail.vue b/src/views/PurchaseOrderDetail.vue index 7a7d24ff..8e0204a9 100644 --- a/src/views/PurchaseOrderDetail.vue +++ b/src/views/PurchaseOrderDetail.vue @@ -106,7 +106,6 @@