diff --git a/src/components/OrderAdjustmentModal.vue b/src/components/OrderAdjustmentModal.vue new file mode 100644 index 00000000..743b23d8 --- /dev/null +++ b/src/components/OrderAdjustmentModal.vue @@ -0,0 +1,195 @@ + + + \ No newline at end of file diff --git a/src/locales/en.json b/src/locales/en.json index 70dfc831..f636c904 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -79,6 +79,7 @@ "Carriers & Shipment Methods": "Carriers & Shipment Methods", "Cash": "Cash", "Cash On Delivery": "Cash On Delivery", + "Cash on delivery order": "Cash on delivery order", "Clear all": "Clear all", "Click the backdrop to dismiss.": "Click the backdrop to dismiss.", "Change": "Change", @@ -91,6 +92,8 @@ "Created": "Created", "Created in Shopify": "Created in Shopify", "Credit Card": "Credit Card", + "COD Calculation": "COD Calculation", + "COD calculation": "COD calculation", "COD Fee": "COD Fee", "COD Fee Tax": "COD Fee Tax", "Collateral rejections": "Collateral rejections", @@ -102,6 +105,7 @@ "Copied": "Copied { value }", "Copied to clipboard": "Copied to clipboard", "Copy ID": "Copy ID", + "Copy tracking code": "Copy tracking code", "Country Code": "Country Code", "Create": "Create", "Create a new carrier": "Create a new carrier", @@ -362,24 +366,29 @@ "Options": "Options", "Ordered": "Ordered", "Ordered on": "Ordered on", + "Order adjustments": "Order adjustments", "Order completed": "Order completed", "Order ID": "Order ID", "Order Identifications": "Order Identifications", "Order Invoicing Status": "Order Invoicing Status", "Order item sequence ID": "Order item sequence ID", "Order Lookup": "Order Lookup", + "Order level charges like shipping fees and taxes are being credited on this label becuase it is the first shipment of this order.": "Order level charges like shipping fees and taxes are being credited on this label becuase it is the first shipment of this order.", + "Order level charges like shipping fees and taxes were already charged to the customer on the first label generated for this order.Label was generated by facility with tracking code": "Order level charges like shipping fees and taxes were already charged to the customer on the first label generated for this order.{space}Label was generated by facility {facilityName} with tracking code {trackingCode}", "Order Name": "Order Name", "Order packed successfully": "Order packed successfully", "Order packed successfully. Document generation in process": "Order packed successfully. Document generation in process", "Other shipments in this order": "Other shipments in this order", "Order shipped successfully": "Order shipped successfully", "Order Shipment ID": "Order Shipment ID", + "Order total": "Order total", "Order unpacked successfully": "Order unpacked successfully", "Order updated successfully": "Order updated successfully", "Orders": "Orders", "ordered": "ordered", "orders": "orders", "Organization": "Organization", + "Other shipment totals": "Other shipment totals", "Out of stock": "Out of stock", "out of cannot be shipped due to missing tracking codes.": "{remainingOrders} out of {totalOrders} cannot be shipped due to missing tracking codes.", "package": "package", @@ -547,6 +556,8 @@ "Shipment method renamed.": "Shipment method renamed.", "Shipment methods order has been changed. Click save button to update them.": "Shipment methods order has been changed. Click save button to update them.", "Shipment shipped successfully.": "Shipment shipped successfully.", + "Shipment subtotal": "Shipment subtotal", + "Shipment total": "Shipment total", "shipped": "shipped", "Shipped": "Shipped", "Shipped orders": "Shipped orders", @@ -599,6 +610,8 @@ "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.", + "This shipping label will include order level charges because it is the first label.": "This shipping label will include order level charges because it is the first label.", + "This shipping label will not include order level charges.": "This shipping label will not include order level charges.", "Timeline": "Timeline", "Timezone": "Timezone", "Time zone updated successfully": "Time zone updated successfully", diff --git a/src/locales/es.json b/src/locales/es.json index d87af146..598b8be1 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -78,6 +78,7 @@ "Carriers & Shipment Methods": "trasnportadoras y metodo de envios", "Cash": "Efectivo", "Cash On Delivery": "Pago Contra Entrega", + "Cash on delivery order": "Cash on delivery order", "Click the backdrop to dismiss.": "Haz clic en el fondo para cerrar.", "Change": "Cambiar", "Changes to the CSV mapping has been saved.": "Los cambios en el mapeo CSV se han guardado.", @@ -87,6 +88,8 @@ "City": "Ciudad", "Create permission": "Crear permisos", "Credit Card": "Tarjeta de Credito", + "COD Calculation": "COD Calculation", + "COD calculation": "COD calculation", "COD Fee": "Tarifa COD", "COD Fee Tax": "Impuesto de Tarifa COD", "Collateral rejections": "Rechazo colateral", @@ -98,6 +101,7 @@ "Copied": "Copiado { value }", "Copied to clipboard": "Copiado al portapapeles", "Copy ID": "Copiar ID", + "Copy tracking code": "Copy tracking code", "Country Code": "Código de pais", "Create": "crear", "Create a new carrier": "Crear una nueva transportadora", @@ -356,6 +360,7 @@ "Options": "Opciones", "Ordered": "Ordenado", "Ordered on": "Ordenado en", + "Order adjustments": "Order adjustments", "Order completed": "Pedido completado", "Order detail": "Detalles de la orden", "Order fulfillment capacity": "Capacidad de cumplimiento del pedido", @@ -365,18 +370,22 @@ "Order Invoicing Status": "Estado de facturación de la orden ", "Order item sequence ID": "Order item sequence ID", "Order Lookup": "Búsqueda de pedidos", + "Order level charges like shipping fees and taxes are being credited on this label becuase it is the first shipment of this order.": "Order level charges like shipping fees and taxes are being credited on this label becuase it is the first shipment of this order.", + "Order level charges like shipping fees and taxes were already charged to the customer on the first label generated for this order.Label was generated by facility with tracking code": "Order level charges like shipping fees and taxes were already charged to the customer on the first label generated for this order.{space}Label was generated by facility {facilityName} with tracking code {trackingCode}", "Order Name": "ID de pedido", "Order packed successfully": "Pedido empacado exitosamente", "Order packed successfully. Document generation in process": "Pedido empacado con éxito. Proceso de generación de documentos en curso", "Other shipments in this order": "Otros envíos en este pedido", "Order shipped successfully": "Pedido enviado exitosamente", "Order Shipment ID": "ID de Envío del Pedido", + "Order total": "Order total", "Order unpacked successfully": "Pedido desempacado exitosamente", "Order updated successfully": "Pedido actualizado exitosamente", "Orders": "Pedidos", "ordered": "ordenado", "orders": "pedidos", "Organization": "Organización", + "Other shipment totals": "Other shipment totals", "Out of stock": "Agotado", "out of cannot be shipped due to missing tracking codes.": "{remainingOrders} de {totalOrders} no se pueden enviar debido a que faltan códigos de seguimiento.", "package": "paquete", @@ -549,6 +558,8 @@ "Shipment method detail updated successfully.": "Detalles del metodo de envio actualizado exitosamente.", "Shipment method renamed.": "metodo de envio renombrado.", "Shipment methods order has been changed. Click save button to update them.": "Metodo de envio en la orden ha sido cambiado. Click en boton guardar para actualisarlos.", + "Shipment subtotal": "Shipment subtotal", + "Shipment total": "Shipment total", "Shipping label": "Etiqueta de Envío", "Shipping label voided successfully.": "Shipping label voided successfully.", "Shipping label error": "Etiqueta de Envio con Error", @@ -596,6 +607,8 @@ "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.": "Este código de tarjeta de regao sera activado. El cliente podria recibir una notificacion sobre esta activacio. Por favor veridicar toda la informacion ingresada correctamente.{space} Esta no podra ser editada despues de la activación.", "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.", + "This shipping label will include order level charges because it is the first label.": "This shipping label will include order level charges because it is the first label.", + "This shipping label will not include order level charges.": "This shipping label will not include order level charges.", "Timeline": "Línea de tiempo", "Timezone": "Zona horaria", "Time zone updated successfully": "Zona horaria actualizada exitosamente", diff --git a/src/locales/ja.json b/src/locales/ja.json index e4d0435c..ee3ab93e 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -79,6 +79,7 @@ "Carriers & Shipment Methods": "配送者と出荷方法", "Cash": "現金", "Cash On Delivery": "代金引換", + "Cash on delivery order": "Cash on delivery order", "Clear all": "すべてクリア", "Click the backdrop to dismiss.": "バックドロップをクリックして閉じる。", "Change": "変更", @@ -91,6 +92,8 @@ "Created": "作成済み", "Created in Shopify": "Shopifyで作成", "Credit Card": "クレジットカード", + "COD Calculation": "COD Calculation", + "COD calculation": "COD calculation", "COD Fee": "代金引換手数料", "COD Fee Tax": "代金引換手数料の税金", "Collateral rejections": "Collateral rejections", @@ -102,6 +105,7 @@ "Copied": "{ value }をコピーしました", "Copied to clipboard": "クリップボードにコピーしました", "Copy ID": "IDをコピー", + "Copy tracking code": "Copy tracking code", "Country Code": "国コード", "Create": "作成", "Create a new carrier": "新しいキャリアを作成", @@ -351,6 +355,7 @@ "Only numeric values are allowed.": "数値のみ使用できます。", "Open": "オープン", "ORDER_APPROVED": "注文承認済み", + "Order adjustments": "Order adjustments", "Order details": "注文詳細", "orders allocated today": "本日割り当てられた注文数: {orderCount}", "orders in fulfillment queue": "フルフィルメントキュー内の注文数: {orderCount}", @@ -366,18 +371,22 @@ "Order Invoicing Status": "Order Invoicing Status", "Order item sequence ID": "Order item sequence ID", "Order Lookup": "注文検索", + "Order level charges like shipping fees and taxes are being credited on this label becuase it is the first shipment of this order.": "Order level charges like shipping fees and taxes are being credited on this label becuase it is the first shipment of this order.", + "Order level charges like shipping fees and taxes were already charged to the customer on the first label generated for this order.Label was generated by facility with tracking code": "Order level charges like shipping fees and taxes were already charged to the customer on the first label generated for this order.{space}Label was generated by facility {facilityName} with tracking code {trackingCode}", "Order Name": "注文名", "Order packed successfully": "注文が正常に梱包されました", "Order packed successfully. Document generation in process": "注文が正常に梱包されました。ドキュメント生成中", "Other shipments in this order": "この注文の他の出荷", "Order shipped successfully": "注文が正常に出荷されました", "Order Shipment ID": "注文出荷ID", + "Order total": "Order total", "Order unpacked successfully": "注文の梱包解除が正常に行われました", "Order updated successfully": "注文が正常に更新されました", "Orders": "注文", "ordered": "注文済み", "orders": "注文", "Organization": "組織", + "Other shipment totals": "Other shipment totals", "Out of stock": "在庫切れ", "out of cannot be shipped due to missing tracking codes.": "{totalOrders} のうち {remainingOrders} は、トラッキング コードがないため発送できません。", "package": "パッケージ", @@ -544,6 +553,8 @@ "Shipment method renamed.": "配送方法の名前が変更されました。", "Shipment methods order has been changed. Click save button to update them.": "出荷方法の順序が変更されました。更新するには保存ボタンをクリックしてください。", "Shipment shipped successfully.": "出荷が正常に発送されました。", + "Shipment subtotal": "Shipment subtotal", + "Shipment total": "Shipment total", "shipped": "発送済み", "Shipped": "発送済み", "Shipped orders": "発送済み注文", @@ -596,6 +607,8 @@ "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の名前です。続行する前に、正しいインスタンスに接続していることを確認してください。", + "This shipping label will include order level charges because it is the first label.": "This shipping label will include order level charges because it is the first label.", + "This shipping label will not include order level charges.": "This shipping label will not include order level charges.", "Timeline": "タイムライン", "Timezone": "タイムゾーン", "Time zone updated successfully": "タイムゾーンが正常に更新されました", diff --git a/src/services/UtilService.ts b/src/services/UtilService.ts index f0ca34d8..717c2b17 100644 --- a/src/services/UtilService.ts +++ b/src/services/UtilService.ts @@ -635,6 +635,46 @@ const isEnumExists = async (enumId: string): Promise => { } } +const getCODOrderRemainingTotal = async(payload: any): Promise => { + return api({ + url: "service/getCODOrderRemainingTotal", + method: "post", + data: payload + }) +} + +const fetchOrderAdjustments = async(payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + +const fetchOrderPayment = async(payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + +const fetchAdjustmentTypeDescription = async(payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + +const fetchOrderShipGroupInfo = async(payload: any): Promise => { + return api({ + url: "performFind", + method: "post", + data: payload + }) +} + export const UtilService = { activateGiftCard, createBarcodeIdentificationPref, @@ -642,6 +682,7 @@ export const UtilService = { createForceScanSetting, createPicklist, createEnumeration, + fetchAdjustmentTypeDescription, fetchCarrierPartyIds, fetchDefaultShipmentBox, fetchEnumeration, @@ -650,6 +691,8 @@ export const UtilService = { fetchFulfillmentRejectReasons, fetchGiftCardFulfillmentInfo, fetchGiftCardItemPriceInfo, + fetchOrderAdjustments, + fetchOrderShipGroupInfo, fetchPartyInformation, fetchPicklistInformation, fetchProductStores, @@ -664,6 +707,7 @@ export const UtilService = { fetchShipmentRouteSegmentInformation, findCarrierPartyIdsForShipment, findCarrierShipmentBoxType, + fetchOrderPayment, findProductStoreShipmentMethCount, findShipmentIdsForOrders, findShipmentItemInformation, @@ -671,6 +715,7 @@ export const UtilService = { findShipmentPackageContents, fetchTransferOrderFacets, getAvailablePickers, + getCODOrderRemainingTotal, getProductStoreSetting, isEnumExists, resetPicker, diff --git a/src/views/OrderDetail.vue b/src/views/OrderDetail.vue index 36932d09..978812a1 100644 --- a/src/views/OrderDetail.vue +++ b/src/views/OrderDetail.vue @@ -238,6 +238,18 @@ {{ translate('Shipment method') }} + + {{ translate("Cash on delivery order") }} + + + + {{ translate("This shipping label will include order level charges because it is the first label.") }} + + + + {{ translate("This shipping label will not include order level charges.") }} + + {{ translate(carrier.groupName) }} @@ -415,7 +427,8 @@ import { personAddOutline, pricetagOutline, trashBinOutline, - ribbonOutline + ribbonOutline, + checkmarkCircleOutline } from 'ionicons/icons'; import { getProductIdentificationValue, translate, DxpShopifyImg, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components'; import { copyToClipboard, formatUtcDate, getFeature, showToast } from '@/utils' @@ -441,6 +454,7 @@ import GenerateTrackingCodeModal from '@/components/GenerateTrackingCodeModal.vu import TrackingCodeModal from '@/components/TrackingCodeModal.vue'; import GiftCardActivationModal from '@/components/GiftCardActivationModal.vue'; import { useDynamicImport } from "@/utils/moduleFederation"; +import OrderAdjustmentModal from "@/components/OrderAdjustmentModal.vue"; export default defineComponent({ name: "OrderDetail", @@ -525,7 +539,13 @@ export default defineComponent({ carrierMethods:[] as any, isUpdatingCarrierDetail: false, orderInvoicingInfo: {} as any, - orderInvoiceExt: "" as any + orderInvoiceExt: "" as any, + isCODPaymentPending: false, + isOrderAdjustmentPending: false, + orderAdjustments: [], + orderHeaderAdjustmentTotal: 0, + adjustmentsByGroup: {} as any, + orderAdjustmentShipmentId: "" } }, async ionViewDidEnter() { @@ -545,6 +565,15 @@ export default defineComponent({ // Fetching shipment label errors await this.fetchShipmentLabelError() + + this.isCODPaymentPending = false + this.isOrderAdjustmentPending = false + + const isCODPayment = this.order?.orderPaymentPreferences?.some((paymentPref: any) => paymentPref.paymentMethodTypeId === "EXT_SHOP_CASH_ON_DEL") + + if(isCODPayment) { + this.fetchCODPaymentInfo(); + } }, async mounted() { const instance = this.instanceUrl.split("-")[0] @@ -1685,7 +1714,101 @@ export default defineComponent({ }) modal.present(); - } + }, + async fetchCODPaymentInfo() { + try { + const resp = await UtilService.getCODOrderRemainingTotal({ + orderId: this.orderId + }) + + if(!hasError(resp) && resp.data?.total) { + this.isCODPaymentPending = true + this.fetchOrderAdjustments(); + } + } catch(err) { + logger.error(err); + } + }, + async fetchOrderAdjustments() { + try { + const resp = await UtilService.fetchOrderAdjustments({ + inputFields: { + orderId: this.orderId + }, + entityName: "OrderAdjustment", + fieldList: ["orderAdjustmentId", "orderAdjustmentTypeId", "orderId", "orderItemSeqId", "shipGroupSeqId", "amount", "billingShipmentId"], + viewSize: 50 + }) + if(!hasError(resp) && resp.data?.count) { + this.orderHeaderAdjustmentTotal = 0 + this.orderAdjustments = resp.data.docs.filter((adjustment: any) => { + // Considered that the adjustment will not be made at shipGroup level + if((adjustment.orderItemSeqId === "_NA_" || !adjustment.orderItemSeqId) && !adjustment.billingShipmentId) { + this.orderHeaderAdjustmentTotal += adjustment.amount + return true; + } else { + this.adjustmentsByGroup[adjustment.shipGroupSeqId] ? (this.adjustmentsByGroup[adjustment.shipGroupSeqId].push(adjustment)) : (this.adjustmentsByGroup[adjustment.shipGroupSeqId] = [adjustment]) + return false; + } + }) + this.isOrderAdjustmentPending = resp.data.docs.some((adjustment: any) => !adjustment.billingShipmentId) + + if(!this.isOrderAdjustmentPending) { + const adjustment = resp.data.docs.find((adjustment: any) => adjustment.billingShipmentId) + this.orderAdjustmentShipmentId = adjustment.billingShipmentId + } + } + } catch(err) { + logger.error(err); + } + }, + async openOrderAdjustmentInfo() { + if(this.isCODPaymentPending && !this.isOrderAdjustmentPending) { + let message = "Order level charges like shipping fees and taxes were already charged to the customer on the first label generated for this order." + let facilityName = "" + let trackingCode = "" + let buttons = [ + { + text: translate("Dismiss"), + role: "cancel" + } + ] as any + + if(this.orderAdjustmentShipmentId) { + const shipGroup = this.order.shipGroups.find((group: any) => group.shipmentId == this.orderAdjustmentShipmentId) + facilityName = shipGroup.facilityName || shipGroup.facilityId + trackingCode = shipGroup.trackingCode + message += "Label was generated by facility with tracking code" + buttons.push({ + text: translate("Copy tracking code"), + handler: () => { + copyToClipboard(trackingCode, "Copied to clipboard") + } + }) + } + + const alert = await alertController.create({ + message: translate(message, { space: "

", facilityName, trackingCode }), + header: translate("COD calculation"), + buttons + }) + + return alert.present(); + } else { + const modal = await modalController.create({ + component: OrderAdjustmentModal, + componentProps: { + order: this.order, + orderId: this.orderId, + orderAdjustments: this.orderAdjustments, + orderHeaderAdjustmentTotal: this.orderHeaderAdjustmentTotal, + adjustmentsByGroup: this.adjustmentsByGroup + } + }) + + return modal.present(); + } + }, }, setup() { const store = useStore(); @@ -1703,6 +1826,7 @@ export default defineComponent({ bagCheckOutline, cashOutline, caretDownOutline, + checkmarkCircleOutline, chevronUpOutline, closeCircleOutline, copyToClipboard,