Skip to content

Commit

Permalink
Merge pull request #899 from ymaheshwari1/#862
Browse files Browse the repository at this point in the history
Implemented: support to display the remaining amount to be collected on the order based on COD payment and the related adjustments(#862)
  • Loading branch information
ymaheshwari1 authored Jan 9, 2025
2 parents 09b99e7 + 87dd739 commit 8fa8ed2
Show file tree
Hide file tree
Showing 6 changed files with 406 additions and 3 deletions.
195 changes: 195 additions & 0 deletions src/components/OrderAdjustmentModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
<template>
<ion-header>
<ion-toolbar>
<ion-buttons slot="start">
<ion-button @click="closeModal">
<ion-icon :icon="close" />
</ion-button>
</ion-buttons>
<ion-title>{{ translate("COD Calculation") }}</ion-title>
</ion-toolbar>
</ion-header>

<ion-content>
<ion-item class="ion-margin-top" lines="none">
<ion-label>{{ translate("Order level charges like shipping fees and taxes are being credited on this label becuase it is the first shipment of this order.") }}</ion-label>
</ion-item>
<ion-list>
<ion-item v-if="shipmentSubtotal">
<ion-label>{{ translate("Shipment subtotal") }}</ion-label>
<ion-note slot="end">{{ currency }} {{ shipmentSubtotal }}</ion-note>
</ion-item>
<ion-accordion-group v-if="orderAdjustments.length">
<ion-accordion value="adjustment">
<ion-item slot="header" color="light" lines="full">
<ion-label>{{ translate("Order adjustments") }}</ion-label>
<ion-note slot="end">{{ currency }} {{ orderHeaderAdjustmentTotal }}</ion-note>
</ion-item>
<div slot="content">
<ion-item v-for="adjustment in orderAdjustments" :key="adjustment">
<ion-label>{{ orderAdjustmentTypeDesc[adjustment.orderAdjustmentTypeId] ?? adjustment.orderAdjustmentTypeId }}</ion-label>
<ion-note slot="end">{{ currency }} {{ adjustment.amount }}</ion-note>
</ion-item>
</div>
</ion-accordion>
</ion-accordion-group>
<ion-item v-if="shipmentTotal">
<ion-label>{{ translate("Shipment total") }}</ion-label>
<ion-note slot="end">{{ currency }} {{ shipmentTotal }}</ion-note>
</ion-item>
<ion-item v-if="otherShipmentTotal">
<ion-label>{{ translate("Other shipment totals") }}</ion-label>
<ion-note slot="end">{{ currency }} {{ otherShipmentTotal }}</ion-note>
</ion-item>
<ion-item v-if="grandTotal">
<ion-label>{{ translate("Order total") }}</ion-label>
<ion-note slot="end">{{ currency }} {{ grandTotal }}</ion-note>
</ion-item>
</ion-list>
</ion-content>
</template>

<script lang="ts">
import {
IonAccordion,
IonAccordionGroup,
IonButtons,
IonButton,
IonContent,
IonHeader,
IonNote,
IonIcon,
IonTitle,
IonToolbar,
IonItem,
IonLabel,
IonList,
modalController
} from "@ionic/vue";
import { defineComponent } from "vue";
import { close } from "ionicons/icons";
import { translate } from '@hotwax/dxp-components'
import logger from "@/logger";
import { UtilService } from "@/services/UtilService";
import { hasError } from "@/adapter";
export default defineComponent({
name: "OrderAdjustmentModal",
components: {
IonAccordion,
IonAccordionGroup,
IonButtons,
IonButton,
IonContent,
IonHeader,
IonNote,
IonIcon,
IonItem,
IonLabel,
IonList,
IonTitle,
IonToolbar
},
data() {
return {
grandTotal: "",
currency: "",
orderAdjustmentTypeIds: [] as any,
orderAdjustmentTypeDesc: {} as any,
otherShipmentTotal: 0,
shipmentSubtotal: 0,
shipmentTotal: 0,
orderItemSeqIds: [] as Array<string>
}
},
props: ["order", "orderId", "orderAdjustments", "orderHeaderAdjustmentTotal", "adjustmentsByGroup"],
async mounted() {
// When calculating total we are not honoring the adjustments added directly on shipGroup level
// as in the currently flow its assumed that there is no way to add adjustment at shipGroup level
// If in the future we have such a support then the logic to calculate subtotal and total needs to be updated
this.orderAdjustments.map((adjustment: any) => {
this.orderAdjustmentTypeIds.push(adjustment.orderAdjustmentTypeId)
})
// Getting seqIds as need to add item level adjustment to specific shipment total
this.orderItemSeqIds = this.order.items.map((item: any) => item.orderItemSeqId)
await this.fetchOrderShipGroupInfo();
await this.fetchAdjustmentTypeDescription();
this.shipmentTotal = this.shipmentSubtotal + this.orderHeaderAdjustmentTotal
},
methods: {
async fetchOrderShipGroupInfo() {
try {
const resp = await UtilService.fetchOrderShipGroupInfo({
inputFields: {
orderId: this.orderId
},
entityName: "OrderHeaderItemAndShipGroup",
viewSize: 50,
fieldList: ["orderId", "grandTotal", "currencyUom", "unitPrice", "shipGroupSeqId"]
})
if(!hasError(resp) && resp.data?.count) {
this.grandTotal = resp.data.docs[0].grandTotal
this.currency = resp.data.docs[0].currencyUom
resp.data.docs.map((group: any) => {
if (group.shipGroupSeqId != this.order.shipGroupSeqId) {
this.otherShipmentTotal += group.unitPrice
} else {
this.shipmentSubtotal += group.unitPrice
}
})
Object.entries(this.adjustmentsByGroup).map(([seqId, adjustments]: any) => {
adjustments.map((adjustment: any) => {
if(seqId === this.order.shipGroupSeqId) {
this.shipmentSubtotal += adjustment.amount
} else if(seqId && seqId !== "_NA_") {
this.otherShipmentTotal += adjustment.amount
} else if(this.orderItemSeqIds.includes(adjustment.orderItemSeqId)) {
this.shipmentSubtotal += adjustment.amount
} else {
this.otherShipmentTotal += adjustment.amount
}
})
})
}
} catch(err) {
logger.error("Failed to fetch ship group info for order", err)
}
},
async fetchAdjustmentTypeDescription() {
try {
const resp = await UtilService.fetchAdjustmentTypeDescription({
inputFields: {
orderAdjustmentTypeId: this.orderAdjustmentTypeIds,
orderAdjustmentTypeId_op: "in"
},
entityName: "OrderAdjustmentType",
viewSize: this.orderAdjustmentTypeIds.length,
fieldList: ["orderAdjustmentTypeId", "description"]
})
if(!hasError(resp) && resp.data?.count) {
this.orderAdjustmentTypeDesc = resp.data.docs.reduce((adjustments: any, adjustment: any) => {
adjustments[adjustment.orderAdjustmentTypeId] = adjustment.description
return adjustments
}, {})
}
} catch(err) {
logger.error("Failed to fetch adjustment type descriptions", err)
}
},
closeModal() {
modalController.dismiss();
},
},
setup() {
return {
close,
translate
};
}
});
</script>
13 changes: 13 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
13 changes: 13 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Loading

0 comments on commit 8fa8ed2

Please sign in to comment.