From d4d4580e2523d21289531c2989c02b89ae16f2d4 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 29 Aug 2024 15:12:25 +0530 Subject: [PATCH 1/7] Implemented: support for the gift card activation (#716) --- src/components/GiftCardActivationModal.vue | 206 +++++++++++++++++++++ src/locales/en.json | 11 ++ src/locales/es.json | 11 ++ src/locales/ja.json | 11 ++ src/services/UtilService.ts | 73 ++++++++ src/utils/order.ts | 1 + src/views/InProgress.vue | 14 ++ 7 files changed, 327 insertions(+) create mode 100644 src/components/GiftCardActivationModal.vue diff --git a/src/components/GiftCardActivationModal.vue b/src/components/GiftCardActivationModal.vue new file mode 100644 index 00000000..1adcb2c3 --- /dev/null +++ b/src/components/GiftCardActivationModal.vue @@ -0,0 +1,206 @@ + + + \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index d220eb05..0c6812ea 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -1,4 +1,7 @@ { + "Activate": "Activate", + "Activate gift card": "Activate gift card", + "Activation code": "Activation code", "Add": "Add", "All": "All", "App": "App", @@ -165,6 +168,7 @@ "Facility ID": "Facility ID", "Facility updated successfully": "Facility updated successfully", "Facilities": "Facilities", + "Failed to activate gift card.": "Failed to activate gift card.", "Failed to add box": "Failed to add box", "Failed to create picklist for orders": "Failed to create picklist for orders", "Failed to create rejection reason.": "Failed to create rejection reason.", @@ -197,6 +201,7 @@ "Failed to update shipment method detail.": "Failed to update shipment method detail.", "Failed to update tracking code settings.": "Failed to update tracking code settings.", "Failed to update variance type.": "Failed to update variance type.", + "Fetching gift card info.": "Fetching gift card info.", "Fetching time zones": "Fetching time zones", "Fetching order information...": "Fetching order information...", "Fetching pickers": "Fetching pickers", @@ -218,6 +223,8 @@ "Generate packing slip": "Generate packing slip", "Generate QR code": "Generate QR code", "Generate shipping label": "Generate shipping label", + "Gift card activated successfully.": "Gift card activated successfully.", + "Gift card activation": "Gift card activation", "Go to OMS": "Go to OMS", "Go to Launchpad": "Go to Launchpad", "Ground": "Ground", @@ -372,6 +379,7 @@ "Picklist Size": "Picklist Size", "Pick All": "Pick All", "pieces in stock": "pieces in stock", + "Please enter a activation code.": "Please enter a activation code.", "Please enter a unique key": "Please enter a unique key", "Please enter a valid key": "Please enter a valid key", "Please provide a value": "Please provide a value", @@ -440,6 +448,7 @@ "Scan barcodes to receive them": "Scan barcodes to receive them", "Scan items": "Scan items", "Scan order items": "Scan order items", + "Scan or enter the unique code on the gift card": "Scan or enter the unique code on the gift card", "Scanned item is not present within the shipment:": "Scanned item is not present within the shipment: {itemName}", "Search": "Search", "Search orders": "Search orders", @@ -465,6 +474,7 @@ "Sequence for rejection reasons updated successfully.": "Sequence for rejection reasons updated successfully.", "Sequence for shipment methods updated successfully.": "Sequence for shipment methods updated successfully.", "Sequence methods": "Sequence methods", + "serial number": "serial number", "Settled": "Settled", "Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.": "Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.", "Settings": "Settings", @@ -535,6 +545,7 @@ "There are no saved CSV mappings to show. Create a new mapping from a file upload screen": "There are no saved CSV mappings to show. Create a new mapping from a file upload screen", "This CSV mapping has been deleted.": "This CSV mapping has been deleted.", "This CSV mapping has been saved.": "This CSV mapping has been saved.", + "This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly. This cannot be edited after activation.": "This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly.{space} This cannot be edited after activation.", "This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.": "This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.", "Timeline": "Timeline", "Timezone": "Timezone", diff --git a/src/locales/es.json b/src/locales/es.json index 57705431..2debce06 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -1,4 +1,7 @@ { + "Activate": "Activate", + "Activate gift card": "Activate gift card", + "Activation code": "Activation code", "Add": "Add", "All": "Todo", "App": "Aplicación", @@ -163,6 +166,7 @@ "Facility ID": "ID de la instalación", "Facility updated successfully": "Instalación actualizada exitosamente", "Facilities": "Facilities", + "Failed to activate gift card.": "Failed to activate gift card.", "Failed to add box": "Error al agregar la caja", "Failed to create picklist for orders": "Error al crear la lista de selección para los pedidos", "Failed to create rejection reason.": "Failed to create rejection reason.", @@ -194,6 +198,7 @@ "Failed to update shipment method detail.": "Failed to update shipment method detail.", "Failed to update tracking code settings.": "Failed to update tracking code settings.", "Failed to update variance type.": "Failed to update variance type.", + "Fetching gift card info.": "Fetching gift card info.", "Fetching order information...": "Obteniendo información del pedido...", "Fetching pickers": "Fetching pickers", "Field mapping name": "Nombre del mapeo de campos", @@ -214,6 +219,8 @@ "Generate packing slip": "Generar documento de embalaje", "Generate QR code": "Generar código QR", "Generate shipping label": "Generar etiqueta de envío", + "Gift card activated successfully.": "Gift card activated successfully.", + "Gift card activation": "Gift card activation", "Go to OMS": "Ir a OMS", "Go to Launchpad": "Ir a Launchpad", "Ground": "Suelo", @@ -369,6 +376,7 @@ "Picklist Size": "Tamaño de la Lista de Selección", "Pick All": "Escoger todo", "pieces in stock": "cantidad en stock", + "Please enter a activation code.": "Please enter a activation code.", "Please enter a unique key": "Por favor, introduce una clave única", "Please enter a valid key": "Por favor, introduce una clave válida", "Please provide a value": "Por favor, proporciona un valor", @@ -438,6 +446,7 @@ "Scan barcodes to receive them": "Scan barcodes to receive them", "Scan items": "Escanear artículos", "Scan order items": "Scan order items", + "Scan or enter the unique code on the gift card": "Scan or enter the unique code on the gift card", "Scanned item is not present within the shipment:": "Scanned item is not present within the shipment: {itemName}", "Search": "Buscar", "Search time zones": "Buscar zonas horarias", @@ -462,6 +471,7 @@ "Sequence methods": "Sequence methods", "Sequence for rejection reasons updated successfully.": "Sequence for rejection reasons updated successfully.", "Sequence for shipment methods updated successfully.": "Sequence for shipment methods updated successfully.", + "serial number": "serial number", "Settled": "Pagado", "Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.": "Establecer la capacidad de cumplimiento en 0 inhabilita la asignación de nuevos pedidos a esta instalación. Déjelo vacío si la capacidad de cumplimiento de esta instalación no tiene restricciones.", "Settings": "Configuraciones", @@ -532,6 +542,7 @@ "There are no saved CSV mappings to show. Create a new mapping from a file upload screen": "No hay asignaciones CSV guardadas para mostrar. Crear una nueva asignación desde una pantalla de carga de archivos", "This CSV mapping has been deleted.": "Esta asignación CSV ha sido eliminada.", "This CSV mapping has been saved.": "Esta asignación CSV se ha guardado.", + "This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly. This cannot be edited after activation.": "This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly.{space} This cannot be edited after activation.", "This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.": "Este es el nombre del OMS al que está conectado en este momento. Asegúrese de estar conectado a la instancia correcta antes de continuar.", "Timeline": "Línea de tiempo", "Timezone": "Zona horaria", diff --git a/src/locales/ja.json b/src/locales/ja.json index cde51443..654138de 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -1,4 +1,7 @@ { + "Activate": "Activate", + "Activate gift card": "Activate gift card", + "Activation code": "Activation code", "Add": "追加", "All": "すべて", "App": "アプリ", @@ -165,6 +168,7 @@ "Facility ID": "施設ID", "Facility updated successfully": "施設が正常に更新されました", "Facilities": "施設", + "Failed to activate gift card.": "Failed to activate gift card.", "Failed to add box": "ボックスの追加に失敗しました", "Failed to create picklist for orders": "注文のピックリスト作成に失敗しました", "Failed to create rejection reason.": "拒否理由の作成に失敗しました。", @@ -197,6 +201,7 @@ "Failed to update shipment method detail.": "Failed to update shipment method detail.", "Failed to update tracking code settings.": "追跡コード設定の更新に失敗しました。", "Failed to update variance type.": "変動タイプの更新に失敗しました。", + "Fetching gift card info.": "Fetching gift card info.", "Fetching time zones": "タイムゾーンの取得中", "Fetching order information...": "注文情報の取得中...", "Fetching pickers": "Fetching pickers", @@ -214,6 +219,8 @@ "Fulfillment capacity": "フルフィルメント容量", "Fulfillment Status": "フルフィルメントステータス", "gateway": "ゲートウェイ", + "Gift card activated successfully.": "Gift card activated successfully.", + "Gift card activation": "Gift card activation", "Generate Label": "Generate Label", "Generate packing slip": "梱包スリップを生成", "Generate QR code": "QRコードを生成", @@ -370,6 +377,7 @@ "Picklist Size": "ピックリストサイズ", "Pick All": "すべて選択", "pieces in stock": "在庫数", + "Please enter a activation code.": "Please enter a activation code.", "Please enter a unique key": "一意のキーを入力してください", "Please enter a valid key": "有効なキーを入力してください", "Please provide a value": "値を入力してください", @@ -437,6 +445,7 @@ "Scan barcodes to receive them": "バーコードをスキャンして受け取ります", "Scan items": "アイテムをスキャン", "Scan order items": "注文アイテムをスキャンする", + "Scan or enter the unique code on the gift card": "Scan or enter the unique code on the gift card", "Scanned item is not present within the shipment:": "Scanned item is not present within the shipment: {itemName}", "Search": "検索", "Search orders": "注文を検索", @@ -462,6 +471,7 @@ "Sequence for rejection reasons updated successfully.": "拒否理由の順序が正常に更新されました。", "Sequence for shipment methods updated successfully.": "出荷方法の順序が正常に更新されました。", "Sequence methods": "順序方法", + "serial number": "serial number", "Settled": "確定済み", "Setting fulfillment capacity to 0 disables new order from being allocated to this facility. Leave this empty if this facility's fulfillment capacity is unrestricted.": "フルフィルメント容量を0に設定すると、この施設に新しい注文が割り当てられるのを防ぎます。この施設のフルフィルメント容量が無制限の場合は、空白のままにしてください。", "Settings": "設定", @@ -532,6 +542,7 @@ "There are no saved CSV mappings to show. Create a new mapping from a file upload screen": "表示する保存されたCSVマッピングがありません。ファイルアップロード画面から新しいマッピングを作成してください", "This CSV mapping has been deleted.": "このCSVマッピングは削除されました。", "This CSV mapping has been saved.": "このCSVマッピングは保存されました。", + "This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly. This cannot be edited after activation.": "This gift card code will be activated. The customer may also receive a notification about this activation. Please verify all information is entered correctly.{space} This cannot be edited after activation.", "This is the name of the OMS you are connected to right now. Make sure that you are connected to the right instance before proceeding.": "これは、現在接続しているOMSの名前です。続行する前に、正しいインスタンスに接続していることを確認してください。", "Timeline": "タイムライン", "Timezone": "タイムゾーン", diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 8c4e0d3d..4f63faea 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -449,6 +449,76 @@ const getProductStoreSetting = async (payload: any): Promise => { }); } +const fetchGiftCardItemPriceInfo = async (payload: any): Promise => { + // Todo: find a better alternative for fetching unitPrice and currency together + let resp = {} as any; + const itemPriceInfo = {} as any; + + const params = { + "inputFields": { + "orderId": payload.orderId, + "orderItemSeqId": payload.orderItemSeqId + }, + "entityName": "OrderItem", + "fieldList": ["unitPrice"], + "viewSize": 1 + } + + try { + resp = await api({ + url: "performFind", + method: "post", + data: params + }); + + if(!hasError(resp)) { + itemPriceInfo.unitPrice = resp.data.docs[0].unitPrice + + resp = await api({ + url: "performFind", + method: "post", + data: { + "inputFields": { + "orderId": payload.orderId, + "orderItemSeqId": payload.orderItemSeqId + }, + "entityName": "OrderHeader", + "fieldList": ["currencyUom"], + "viewSize": 1 + } + }); + + if(!hasError(resp)) { + itemPriceInfo.currency = resp.data.docs[0].currencyUom + } else { + throw resp.data; + } + } else { + throw resp.data; + } + } catch(error: any) { + logger.error(error); + } + + return itemPriceInfo; +} + +const fetchGiftCardFulfillmentInfo = async (payload: any): Promise => { + return await api({ + url: 'performFind', + method: 'POST', + data: payload + }) as any +} + +const activateGiftCard = async (payload: any): Promise => { + return api({ + url: "service/createGcFulFillmentRecord", + method: "post", + data: payload + }); +} + const isEnumExists = async (enumId: string): Promise => { try { const resp = await api({ @@ -475,6 +545,7 @@ const isEnumExists = async (enumId: string): Promise => { } export const UtilService = { + activateGiftCard, createForceScanSetting, createPicklist, createEnumeration, @@ -483,6 +554,8 @@ export const UtilService = { fetchEnumeration, fetchFacilities, fetchFacilityTypeInformation, + fetchGiftCardFulfillmentInfo, + fetchGiftCardItemPriceInfo, fetchPartyInformation, fetchPicklistInformation, fetchProductStores, diff --git a/src/utils/order.ts b/src/utils/order.ts index 239146b6..8c4e2a02 100644 --- a/src/utils/order.ts +++ b/src/utils/order.ts @@ -102,6 +102,7 @@ const removeKitComponents = (order: any) => { order.items.forEach((item:any) => { const product = store.getters['product/getProduct'](item.productId); if ((product && product.productTypeId === "MARKETING_PKG_PICK") || !kitItemSeqIds.has(item.orderItemSeqId)) { + item["productTypeId"] = product.productTypeId itemsWithoutKitComponents.push(item) } }) diff --git a/src/views/InProgress.vue b/src/views/InProgress.vue index 6db11bc3..454b3863 100644 --- a/src/views/InProgress.vue +++ b/src/views/InProgress.vue @@ -139,6 +139,9 @@ + + + @@ -277,6 +280,7 @@ import { cubeOutline, ellipsisVerticalOutline, fileTrayOutline, + giftOutline, listOutline, pencilOutline, optionsOutline, @@ -310,6 +314,7 @@ import ShipmentBoxPopover from '@/components/ShipmentBoxPopover.vue' import QRCodeModal from '@/components/QRCodeModal.vue' import { useAuthStore } from '@hotwax/dxp-components' import ScanOrderItemModal from "@/components/ScanOrderItemModal.vue"; +import GiftCardActivationModal from "@/components/GiftCardActivationModal.vue"; export default defineComponent({ @@ -1234,6 +1239,14 @@ export default defineComponent({ } }) + modal.present(); + }, + async openGiftCardActivationModal(order: any, item: any) { + const modal = await modalController.create({ + component: GiftCardActivationModal, + componentProps: { item } + }) + modal.present(); } }, @@ -1267,6 +1280,7 @@ export default defineComponent({ formatUtcDate, getFeature, getProductIdentificationValue, + giftOutline, hasPermission, isKit, listOutline, From 18b6e6d9114adabb112298338bf570d5b76468fe Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 29 Aug 2024 15:50:40 +0530 Subject: [PATCH 2/7] Improved: added support for gift activation from order details page (#716) --- src/components/GiftCardActivationModal.vue | 4 ++-- src/locales/en.json | 1 + src/locales/es.json | 1 + src/locales/ja.json | 1 + src/services/UtilService.ts | 24 +++++++++++----------- src/views/InProgress.vue | 4 ++-- src/views/OrderDetail.vue | 15 ++++++++++++++ 7 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/components/GiftCardActivationModal.vue b/src/components/GiftCardActivationModal.vue index 1adcb2c3..6a459480 100644 --- a/src/components/GiftCardActivationModal.vue +++ b/src/components/GiftCardActivationModal.vue @@ -147,8 +147,8 @@ export default defineComponent({ orderId: this.item.orderId, orderItemSeqId: this.item.orderItemSeqId }, - fieldList: ["cardNumber", "createdDate"], - viewSize: 1, + fieldList: ["cardNumber", "fulfillmentDate"], + viewSize: 1 }) if(!hasError(resp)) { diff --git a/src/locales/en.json b/src/locales/en.json index 0c6812ea..efd875ee 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -223,6 +223,7 @@ "Generate packing slip": "Generate packing slip", "Generate QR code": "Generate QR code", "Generate shipping label": "Generate shipping label", + "Gift card": "Gift card", "Gift card activated successfully.": "Gift card activated successfully.", "Gift card activation": "Gift card activation", "Go to OMS": "Go to OMS", diff --git a/src/locales/es.json b/src/locales/es.json index 2debce06..86e8c8bd 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -219,6 +219,7 @@ "Generate packing slip": "Generar documento de embalaje", "Generate QR code": "Generar código QR", "Generate shipping label": "Generar etiqueta de envío", + "Gift card": "Gift card", "Gift card activated successfully.": "Gift card activated successfully.", "Gift card activation": "Gift card activation", "Go to OMS": "Ir a OMS", diff --git a/src/locales/ja.json b/src/locales/ja.json index 654138de..6fba82ef 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -219,6 +219,7 @@ "Fulfillment capacity": "フルフィルメント容量", "Fulfillment Status": "フルフィルメントステータス", "gateway": "ゲートウェイ", + "Gift card": "Gift card", "Gift card activated successfully.": "Gift card activated successfully.", "Gift card activation": "Gift card activation", "Generate Label": "Generate Label", diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index 4f63faea..da5b1165 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -455,13 +455,13 @@ const fetchGiftCardItemPriceInfo = async (payload: any): Promise => { const itemPriceInfo = {} as any; const params = { - "inputFields": { - "orderId": payload.orderId, - "orderItemSeqId": payload.orderItemSeqId + inputFields: { + orderId: payload.orderId, + orderItemSeqId: payload.orderItemSeqId }, - "entityName": "OrderItem", - "fieldList": ["unitPrice"], - "viewSize": 1 + entityName: "OrderItem", + fieldList: ["unitPrice"], + viewSize: 1 } try { @@ -478,13 +478,13 @@ const fetchGiftCardItemPriceInfo = async (payload: any): Promise => { url: "performFind", method: "post", data: { - "inputFields": { - "orderId": payload.orderId, - "orderItemSeqId": payload.orderItemSeqId + inputFields: { + orderId: payload.orderId, + orderItemSeqId: payload.orderItemSeqId }, - "entityName": "OrderHeader", - "fieldList": ["currencyUom"], - "viewSize": 1 + entityName: "OrderHeader", + fieldList: ["currencyUom"], + viewSize: 1 } }); diff --git a/src/views/InProgress.vue b/src/views/InProgress.vue index 454b3863..fbfca9c2 100644 --- a/src/views/InProgress.vue +++ b/src/views/InProgress.vue @@ -139,7 +139,7 @@ - + @@ -1241,7 +1241,7 @@ export default defineComponent({ modal.present(); }, - async openGiftCardActivationModal(order: any, item: any) { + async openGiftCardActivationModal(item: any) { const modal = await modalController.create({ component: GiftCardActivationModal, componentProps: { item } diff --git a/src/views/OrderDetail.vue b/src/views/OrderDetail.vue index 755e8ef2..3df3a80e 100644 --- a/src/views/OrderDetail.vue +++ b/src/views/OrderDetail.vue @@ -129,6 +129,10 @@ + + {{ translate('Gift card') }} + +
@@ -397,6 +401,7 @@ import { documentTextOutline, ellipsisVerticalOutline, fileTrayOutline, + giftOutline, informationCircleOutline, listOutline, locateOutline, @@ -426,6 +431,7 @@ import { isKit } from '@/utils/order' import ScanOrderItemModal from "@/components/ScanOrderItemModal.vue"; import ShippingLabelActionPopover from '@/components/ShippingLabelActionPopover.vue'; import TrackingCodeModal from '@/components/TrackingCodeModal.vue'; +import GiftCardActivationModal from '@/components/GiftCardActivationModal.vue'; export default defineComponent({ name: "OrderDetail", @@ -1484,6 +1490,14 @@ export default defineComponent({ return addTrackingCodeModal.present(); }, + async openGiftCardActivationModal(item: any) { + const modal = await modalController.create({ + component: GiftCardActivationModal, + componentProps: { item } + }) + + modal.present(); + } }, setup() { const store = useStore(); @@ -1508,6 +1522,7 @@ export default defineComponent({ formatUtcDate, getFeature, getProductIdentificationValue, + giftOutline, hasPermission, isKit, informationCircleOutline, From aa130966833523813a3ca15965b8eef227f943ad Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Thu, 29 Aug 2024 16:03:37 +0530 Subject: [PATCH 3/7] Improved: updated the enumId to be used for gift card activation (#716) --- src/components/GiftCardActivationModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/GiftCardActivationModal.vue b/src/components/GiftCardActivationModal.vue index 6a459480..1951dce9 100644 --- a/src/components/GiftCardActivationModal.vue +++ b/src/components/GiftCardActivationModal.vue @@ -166,7 +166,7 @@ export default defineComponent({ orderId: this.item.orderId, orderItemSeqId: this.item.orderItemSeqId, amount: this.itemPriceInfo.unitPrice, - typeEnumId: "GIFT_CARD_ITEM", + typeEnumId: "GC_ACTIVATE", cardNumber: this.activationCode.trim() }) From eadaf5ada0676436fcebf6df1fca52cd524dc651 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Fri, 30 Aug 2024 11:41:08 +0530 Subject: [PATCH 4/7] Improved: logic for gift card activation details fetching logic (#716) --- src/components/GiftCardActivationModal.vue | 37 +---- src/store/modules/order/actions.ts | 167 ++++++++++++++++++++- src/views/Completed.vue | 22 ++- src/views/InProgress.vue | 10 +- src/views/OrderDetail.vue | 10 +- 5 files changed, 211 insertions(+), 35 deletions(-) diff --git a/src/components/GiftCardActivationModal.vue b/src/components/GiftCardActivationModal.vue index 1951dce9..245fa060 100644 --- a/src/components/GiftCardActivationModal.vue +++ b/src/components/GiftCardActivationModal.vue @@ -16,13 +16,13 @@ {{ translate("Fetching gift card info.") }}
- + - {{ cardInfo.cardNumber }} + {{ item.gcInfo.cardNumber }} {{ getCreatedDateTime() }} @@ -37,7 +37,7 @@ - + @@ -101,20 +101,18 @@ export default defineComponent({ return { isLoading: false, itemPriceInfo: {} as any, - cardInfo: {} as any, activationCode: "" } }, props: ["item"], async mounted() { this.isLoading = true; - await this.fetchGiftCardInfo(); this.itemPriceInfo = await UtilService.fetchGiftCardItemPriceInfo({ orderId: this.item.orderId, orderItemSeqId: this.item.orderItemSeqId }) this.isLoading = false; }, methods: { - closeModal() { - modalController.dismiss() + closeModal(payload = {}) { + modalController.dismiss({ dismissed: true, ...payload }) }, async confirmSave() { if(!this.activationCode.trim()) { @@ -139,27 +137,6 @@ export default defineComponent({ }); return alert.present(); }, - async fetchGiftCardInfo() { - try { - const resp = await UtilService.fetchGiftCardFulfillmentInfo({ - entityName: "GiftCardFulfillment", - inputFields: { - orderId: this.item.orderId, - orderItemSeqId: this.item.orderItemSeqId - }, - fieldList: ["cardNumber", "fulfillmentDate"], - viewSize: 1 - }) - - if(!hasError(resp)) { - this.cardInfo = resp.data.docs[0] - } else { - throw resp.data - } - } catch(error) { - logger.error(error) - } - }, async activateGitCard() { try { const resp = await UtilService.activateGiftCard({ @@ -172,7 +149,7 @@ export default defineComponent({ if(!hasError(resp)) { showToast(translate("Gift card activated successfully.")) - this.closeModal() + this.closeModal({ isGCActivated: true, item: this.item }) } else { throw resp.data; } @@ -182,7 +159,7 @@ export default defineComponent({ } }, getCreatedDateTime() { - return DateTime.fromMillis(this.cardInfo.fulfillmentDate).toFormat("dd MMMM yyyy t a ZZZZ"); + return DateTime.fromMillis(this.item.gcInfo.fulfillmentDate).toFormat("dd MMMM yyyy t a ZZZZ"); } }, setup() { diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 47395110..3a2b7466 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -11,7 +11,7 @@ import logger from '@/logger' import { getOrderCategory, removeKitComponents } from '@/utils/order' const actions: ActionTree = { - async fetchInProgressOrdersAdditionalInformation({ commit, state }, payload = { viewIndex: 0 }) { + async fetchInProgressOrdersAdditionalInformation({ commit, dispatch, state }, payload = { viewIndex: 0 }) { // getting all the orders from state const cachedOrders = JSON.parse(JSON.stringify(state.inProgress.list)); // maintaining cachedOrders as to prepare the orders payload let inProgressOrders = JSON.parse(JSON.stringify(state.inProgress.list)); // maintaining inProgreesOrders as update the orders information once information in fetched @@ -141,11 +141,13 @@ const actions: ActionTree = { logger.error('Failed to fetch shipmentIds for orders', err) } + inProgressOrders = await dispatch("fetchOrdersCardActivationDetails", inProgressOrders) + // updating the state with the updated orders information commit(types.ORDER_INPROGRESS_UPDATED, { orders: inProgressOrders, total: state.inProgress.total }) }, - async fetchCompletedOrdersAdditionalInformation({ commit, state }) { + async fetchCompletedOrdersAdditionalInformation({ commit, dispatch, state }) { // getting all the orders from state const cachedOrders = JSON.parse(JSON.stringify(state.completed.list)); // maintaining cachedOrders as to prepare the orders payload let completedOrders = JSON.parse(JSON.stringify(state.completed.list)); // maintaining completedOrders as update the orders information once information in fetched @@ -232,10 +234,61 @@ const actions: ActionTree = { logger.error('Failed to fetch shipmentIds for orders', err) } + completedOrders = await dispatch("fetchOrdersCardActivationDetails", completedOrders) + // updating the state with the updated orders information commit(types.ORDER_COMPLETED_UPDATED, { list: completedOrders, total: state.completed.total }) }, + async fetchOrdersCardActivationDetails({ commit }, currentOrders: any) { + const orders = JSON.parse(JSON.stringify(currentOrders)); + const orderIds = [] as any; + let giftCardActivations = [] as any; + + orders.map((order: any) => { + order.items.map((item: any) => { + if(item.productTypeId === 'GIFT_CARD' && !orderIds.includes(item.orderId)) { + orderIds.push(item.orderId); + } + }) + }) + + if(!orderIds.length) return orders; + + try { + const resp = await UtilService.fetchGiftCardFulfillmentInfo({ + entityName: "GiftCardFulfillment", + inputFields: { + orderId: orderIds, + orderId_op: "in" + }, + fieldList: ["amount", "cardNumber", "fulfillmentDate", "orderId", "orderItemSeqId"] + }) + + if(!hasError(resp)) { + giftCardActivations = resp.data.docs + } else { + throw resp.data + } + } catch(error) { + logger.error(error) + } + + if(giftCardActivations.length) { + orders.map((order: any) => { + order.items.map((item: any) => { + const activationRecord = giftCardActivations.find((card: any) => card.orderId === item.orderId && card.orderItemSeqId === item.orderItemSeqId) + if(activationRecord?.cardNumber) { + item.isGCActivated = true; + item.gcInfo = activationRecord + } + }) + }) + } + + return orders + }, + // get in-progress orders async findInProgressOrders ({ commit, dispatch, state }, payload = {}) { emitter.emit('presentLoader'); @@ -993,6 +1046,8 @@ const actions: ActionTree = { logger.error('Something went wrong', err) } + current = await dispatch("fetchCurrentOrderCardActivationDetail", current); + dispatch('updateCurrent', current) }, @@ -1111,10 +1166,60 @@ const actions: ActionTree = { logger.error('Something went wrong', err) } + current = await dispatch("fetchCurrentOrderCardActivationDetail", current); + // updating the state with the updated orders information await dispatch('updateCurrent', current) }, + async fetchCurrentOrderCardActivationDetail({ commit }, currentOrder) { + const order = JSON.parse(JSON.stringify(currentOrder)); + + const itemIds = [] as any; + + order.items.map((item: any) => { + if(item.productTypeId === "GIFT_CARD" && !itemIds.includes(item.orderItemSeqId)) { + itemIds.push(item.orderItemSeqId) + } + }) + + if(!itemIds.length) return order; + + let giftCardActivations = [] as any; + + try { + const resp = await UtilService.fetchGiftCardFulfillmentInfo({ + entityName: "GiftCardFulfillment", + inputFields: { + orderId: order.orderId, + orderItemSeqId: itemIds, + orderItemSeqId_op: "in" + }, + fieldList: ["amount", "cardNumber", "fulfillmentDate", "orderId", "orderItemSeqId"] + }) + + if(!hasError(resp)) { + giftCardActivations = resp.data.docs + } else { + throw resp.data + } + } catch(error) { + logger.error(error) + } + + if(giftCardActivations.length) { + order.items.map((item: any) => { + const activationRecord = giftCardActivations.find((card: any) => card.orderId === item.orderId && card.orderItemSeqId === item.orderItemSeqId) + if(activationRecord?.cardNumber) { + item.isGCActivated = true; + item.gcInfo = activationRecord + } + }) + } + + return order + }, + async fetchAdditionalShipGroupForOrder({ commit, state }, payload) { const order = JSON.parse(JSON.stringify(state.current)) @@ -1198,6 +1303,64 @@ const actions: ActionTree = { return shipGroups; }, + async updateCurrentItemGCActivationDetails({ commit, state }, { item, category, isDetailsPage }) { + let gcInfo = {}; + let isGCActivated = false; + + try { + const resp = await UtilService.fetchGiftCardFulfillmentInfo({ + entityName: "GiftCardFulfillment", + inputFields: { + orderId: item.orderId, + orderItemSeqId: item.orderItemSeqId + }, + fieldList: ["amount", "cardNumber", "fulfillmentDate", "orderId", "orderItemSeqId"] + }) + + if(!hasError(resp)) { + isGCActivated = true; + gcInfo = resp.data.docs[0]; + } else { + throw resp.data + } + } catch(error) { + logger.error(error) + } + + if(!isGCActivated) return; + + if(isDetailsPage) { + const order = JSON.parse(JSON.stringify(state.current)); + + order.items?.map((currentItem: any) => { + if(currentItem.orderId === item.orderId && currentItem.orderItemSeqId === item.orderItemSeqId) { + currentItem.isGCActivated = true; + currentItem.gcInfo = gcInfo + } + }) + + commit(types.ORDER_CURRENT_UPDATED, order) + return; + } + + const orders = JSON.parse(JSON.stringify(category === "in-progress" ? state.inProgress.list : state.completed.list)); + + orders.map((order: any) => { + order.items.map((currentItem: any) => { + if(currentItem.orderId === item.orderId && currentItem.orderItemSeqId === item.orderItemSeqId) { + currentItem.isGCActivated = true; + currentItem.gcInfo = gcInfo; + } + }) + }) + + if(category === "in-progress") { + commit(types.ORDER_INPROGRESS_UPDATED, { orders, total: state.inProgress.total }) + } else { + commit(types.ORDER_COMPLETED_UPDATED, { list: orders, total: state.completed.total }) + } + }, + // TODO clear current on logout async updateCurrent({ commit, dispatch }, order) { commit(types.ORDER_CURRENT_UPDATED, order) diff --git a/src/views/Completed.vue b/src/views/Completed.vue index 48801555..e6c1fd71 100644 --- a/src/views/Completed.vue +++ b/src/views/Completed.vue @@ -90,6 +90,9 @@
+ + + {{ getProductStock(item.productId).quantityOnHandTotal }} {{ translate('pieces in stock') }} @@ -198,7 +201,7 @@ import { modalController } from '@ionic/vue'; import { computed, defineComponent } from 'vue'; -import { caretDownOutline, chevronUpOutline, cubeOutline, printOutline, downloadOutline, listOutline, pricetagOutline, ellipsisVerticalOutline, checkmarkDoneOutline, optionsOutline } from 'ionicons/icons' +import { caretDownOutline, chevronUpOutline, cubeOutline, printOutline, downloadOutline, gift, giftOutline, listOutline, pricetagOutline, ellipsisVerticalOutline, checkmarkDoneOutline, optionsOutline } from 'ionicons/icons' import Popover from '@/views/ShippingPopover.vue' import { useRouter } from 'vue-router'; import { mapGetters, useStore } from 'vuex' @@ -216,6 +219,7 @@ import ShippingLabelErrorModal from '@/components/ShippingLabelErrorModal.vue'; import { Actions, hasPermission } from '@/authorization' import OrderActionsPopover from '@/components/OrderActionsPopover.vue' import { isKit } from '@/utils/order' +import GiftCardActivationModal from "@/components/GiftCardActivationModal.vue"; export default defineComponent({ name: 'Completed', @@ -738,6 +742,20 @@ export default defineComponent({ }); return popover.present(); }, + async openGiftCardActivationModal(item: any) { + const modal = await modalController.create({ + component: GiftCardActivationModal, + componentProps: { item } + }) + + modal.onDidDismiss().then((result: any) => { + if(result.data?.isGCActivated) { + this.store.dispatch("order/updateCurrentItemGCActivationDetails", { item, category: "completed", isDetailsPage: false }) + } + }) + + modal.present(); + } }, setup() { const store = useStore(); @@ -757,6 +775,8 @@ export default defineComponent({ formatUtcDate, getFeature, getProductIdentificationValue, + gift, + giftOutline, hasPermission, isKit, listOutline, diff --git a/src/views/InProgress.vue b/src/views/InProgress.vue index fbfca9c2..6c68b477 100644 --- a/src/views/InProgress.vue +++ b/src/views/InProgress.vue @@ -140,7 +140,7 @@ - + @@ -280,6 +280,7 @@ import { cubeOutline, ellipsisVerticalOutline, fileTrayOutline, + gift, giftOutline, listOutline, pencilOutline, @@ -1247,6 +1248,12 @@ export default defineComponent({ componentProps: { item } }) + modal.onDidDismiss().then((result: any) => { + if(result.data?.isGCActivated) { + this.store.dispatch("order/updateCurrentItemGCActivationDetails", { item, category: "in-progress", isDetailsPage: false }) + } + }) + modal.present(); } }, @@ -1280,6 +1287,7 @@ export default defineComponent({ formatUtcDate, getFeature, getProductIdentificationValue, + gift, giftOutline, hasPermission, isKit, diff --git a/src/views/OrderDetail.vue b/src/views/OrderDetail.vue index 3df3a80e..e39b5238 100644 --- a/src/views/OrderDetail.vue +++ b/src/views/OrderDetail.vue @@ -131,7 +131,7 @@ {{ translate('Gift card') }} - + @@ -401,6 +401,7 @@ import { documentTextOutline, ellipsisVerticalOutline, fileTrayOutline, + gift, giftOutline, informationCircleOutline, listOutline, @@ -1496,6 +1497,12 @@ export default defineComponent({ componentProps: { item } }) + modal.onDidDismiss().then((result: any) => { + if(result.data?.isGCActivated) { + this.store.dispatch("order/updateCurrentItemGCActivationDetails", { item, category: this.category, isDetailsPage: true }) + } + }) + modal.present(); } }, @@ -1522,6 +1529,7 @@ export default defineComponent({ formatUtcDate, getFeature, getProductIdentificationValue, + gift, giftOutline, hasPermission, isKit, From b6db857d3c87433585adc67dace166b02785a600 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 2 Sep 2024 10:53:45 +0530 Subject: [PATCH 5/7] Improved: showing formated unit price of the item with currency symbol (#716) --- src/components/GiftCardActivationModal.vue | 5 +++-- src/services/UtilService.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/GiftCardActivationModal.vue b/src/components/GiftCardActivationModal.vue index 245fa060..dcc503c2 100644 --- a/src/components/GiftCardActivationModal.vue +++ b/src/components/GiftCardActivationModal.vue @@ -32,7 +32,7 @@ {{ getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.productId)) ? getProductIdentificationValue(productIdentificationPref.primaryId, getProduct(item.productId)) : item.productName }}

{{ getProductIdentificationValue(productIdentificationPref.secondaryId, getProduct(item.productId)) }}

- {{ itemPriceInfo.unitPrice }} {{ itemPriceInfo.currency }} + {{ formatCurrency(itemPriceInfo.unitPrice, itemPriceInfo.currencyUom) }} @@ -69,7 +69,7 @@ import { mapGetters, useStore } from "vuex"; import { cardOutline, closeOutline, giftOutline, saveOutline } from "ionicons/icons"; import { getProductIdentificationValue, translate, useProductIdentificationStore } from '@hotwax/dxp-components' import { UtilService } from "@/services/UtilService"; -import { formatUtcDate, hasError, showToast } from '@/utils'; +import { formatCurrency, formatUtcDate, hasError, showToast } from '@/utils'; import logger from "@/logger"; import { DateTime } from 'luxon'; @@ -170,6 +170,7 @@ export default defineComponent({ return { cardOutline, closeOutline, + formatCurrency, formatUtcDate, getProductIdentificationValue, giftOutline, diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index da5b1165..8c252431 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -489,7 +489,7 @@ const fetchGiftCardItemPriceInfo = async (payload: any): Promise => { }); if(!hasError(resp)) { - itemPriceInfo.currency = resp.data.docs[0].currencyUom + itemPriceInfo.currencyUom = resp.data.docs[0].currencyUom } else { throw resp.data; } From bf397062a70c783d1250bfcedbef9869e3cf1b08 Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 2 Sep 2024 16:05:19 +0530 Subject: [PATCH 6/7] Improved: created centralized action for fetching gift card activation details (#716) --- src/store/modules/order/actions.ts | 95 ++++++++++-------------------- 1 file changed, 31 insertions(+), 64 deletions(-) diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index 3a2b7466..c406f234 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -141,7 +141,7 @@ const actions: ActionTree = { logger.error('Failed to fetch shipmentIds for orders', err) } - inProgressOrders = await dispatch("fetchOrdersCardActivationDetails", inProgressOrders) + inProgressOrders = await dispatch("fetchGiftCardActivationDetails", { isDetailsPage: false, currentOrders: inProgressOrders }) // updating the state with the updated orders information commit(types.ORDER_INPROGRESS_UPDATED, { orders: inProgressOrders, total: state.inProgress.total }) @@ -234,24 +234,28 @@ const actions: ActionTree = { logger.error('Failed to fetch shipmentIds for orders', err) } - completedOrders = await dispatch("fetchOrdersCardActivationDetails", completedOrders) + completedOrders = await dispatch("fetchGiftCardActivationDetails", { isDetailsPage: false, currentOrders: completedOrders }) // updating the state with the updated orders information commit(types.ORDER_COMPLETED_UPDATED, { list: completedOrders, total: state.completed.total }) }, - async fetchOrdersCardActivationDetails({ commit }, currentOrders: any) { + async fetchGiftCardActivationDetails({ commit, state }, { isDetailsPage, currentOrders }) { const orders = JSON.parse(JSON.stringify(currentOrders)); const orderIds = [] as any; let giftCardActivations = [] as any; - orders.map((order: any) => { - order.items.map((item: any) => { - if(item.productTypeId === 'GIFT_CARD' && !orderIds.includes(item.orderId)) { - orderIds.push(item.orderId); - } + if(isDetailsPage) { + orderIds.push(orders[0].orderId); + } else { + orders.map((order: any) => { + order.items.map((item: any) => { + if(item.productTypeId === 'GIFT_CARD' && !orderIds.includes(item.orderId)) { + orderIds.push(item.orderId); + } + }) }) - }) + } if(!orderIds.length) return orders; @@ -262,7 +266,8 @@ const actions: ActionTree = { orderId: orderIds, orderId_op: "in" }, - fieldList: ["amount", "cardNumber", "fulfillmentDate", "orderId", "orderItemSeqId"] + fieldList: ["amount", "cardNumber", "fulfillmentDate", "orderId", "orderItemSeqId"], + viewSize: 250 }) if(!hasError(resp)) { @@ -275,18 +280,28 @@ const actions: ActionTree = { } if(giftCardActivations.length) { - orders.map((order: any) => { - order.items.map((item: any) => { + if(isDetailsPage) { + orders[0].items.map((item: any) => { const activationRecord = giftCardActivations.find((card: any) => card.orderId === item.orderId && card.orderItemSeqId === item.orderItemSeqId) if(activationRecord?.cardNumber) { item.isGCActivated = true; item.gcInfo = activationRecord } }) - }) + } else { + orders.map((order: any) => { + order.items.map((item: any) => { + const activationRecord = giftCardActivations.find((card: any) => card.orderId === item.orderId && card.orderItemSeqId === item.orderItemSeqId) + if(activationRecord?.cardNumber) { + item.isGCActivated = true; + item.gcInfo = activationRecord + } + }) + }) + } } - return orders + return isDetailsPage ? orders[0] : orders }, // get in-progress orders @@ -1046,7 +1061,7 @@ const actions: ActionTree = { logger.error('Something went wrong', err) } - current = await dispatch("fetchCurrentOrderCardActivationDetail", current); + current = await dispatch("fetchGiftCardActivationDetails", { isDetailsPage: true, currentOrders: [current] }); dispatch('updateCurrent', current) }, @@ -1166,60 +1181,12 @@ const actions: ActionTree = { logger.error('Something went wrong', err) } - current = await dispatch("fetchCurrentOrderCardActivationDetail", current); + current = await dispatch("fetchGiftCardActivationDetails", { isDetailsPage: true, currentOrders: [current]}); // updating the state with the updated orders information await dispatch('updateCurrent', current) }, - async fetchCurrentOrderCardActivationDetail({ commit }, currentOrder) { - const order = JSON.parse(JSON.stringify(currentOrder)); - - const itemIds = [] as any; - - order.items.map((item: any) => { - if(item.productTypeId === "GIFT_CARD" && !itemIds.includes(item.orderItemSeqId)) { - itemIds.push(item.orderItemSeqId) - } - }) - - if(!itemIds.length) return order; - - let giftCardActivations = [] as any; - - try { - const resp = await UtilService.fetchGiftCardFulfillmentInfo({ - entityName: "GiftCardFulfillment", - inputFields: { - orderId: order.orderId, - orderItemSeqId: itemIds, - orderItemSeqId_op: "in" - }, - fieldList: ["amount", "cardNumber", "fulfillmentDate", "orderId", "orderItemSeqId"] - }) - - if(!hasError(resp)) { - giftCardActivations = resp.data.docs - } else { - throw resp.data - } - } catch(error) { - logger.error(error) - } - - if(giftCardActivations.length) { - order.items.map((item: any) => { - const activationRecord = giftCardActivations.find((card: any) => card.orderId === item.orderId && card.orderItemSeqId === item.orderItemSeqId) - if(activationRecord?.cardNumber) { - item.isGCActivated = true; - item.gcInfo = activationRecord - } - }) - } - - return order - }, - async fetchAdditionalShipGroupForOrder({ commit, state }, payload) { const order = JSON.parse(JSON.stringify(state.current)) From 9dace4ed963860ce7aee0f45e8416a894a149eec Mon Sep 17 00:00:00 2001 From: amansinghbais Date: Mon, 2 Sep 2024 16:15:28 +0530 Subject: [PATCH 7/7] Fixed: gc fulfillment status not updating in list page on activating from details page (#716) --- src/store/modules/order/actions.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/store/modules/order/actions.ts b/src/store/modules/order/actions.ts index c406f234..81aabb53 100644 --- a/src/store/modules/order/actions.ts +++ b/src/store/modules/order/actions.ts @@ -1296,6 +1296,8 @@ const actions: ActionTree = { if(!isGCActivated) return; + const orders = JSON.parse(JSON.stringify(category === "in-progress" ? state.inProgress.list : state.completed.list)); + if(isDetailsPage) { const order = JSON.parse(JSON.stringify(state.current)); @@ -1306,12 +1308,20 @@ const actions: ActionTree = { } }) + orders.map((currentOrder: any) => { + if(currentOrder.orderId === order.orderId) currentOrder.items = order.items + }) + + if(category === "in-progress") { + commit(types.ORDER_INPROGRESS_UPDATED, { orders, total: state.inProgress.total }) + } else { + commit(types.ORDER_COMPLETED_UPDATED, { list: orders, total: state.completed.total }) + } + commit(types.ORDER_CURRENT_UPDATED, order) return; } - const orders = JSON.parse(JSON.stringify(category === "in-progress" ? state.inProgress.list : state.completed.list)); - orders.map((order: any) => { order.items.map((currentItem: any) => { if(currentItem.orderId === item.orderId && currentItem.orderItemSeqId === item.orderItemSeqId) {