From 78305e1670c9939770e5e1f61b1299a9b0f0efa6 Mon Sep 17 00:00:00 2001
From: shafi54 <108669266+shafi-aviz@users.noreply.github.com>
Date: Sun, 22 Mar 2026 21:28:32 +0530
Subject: [PATCH] enh
---
apps/backend/src/lib/post-order-handler.ts | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/apps/backend/src/lib/post-order-handler.ts b/apps/backend/src/lib/post-order-handler.ts
index 62953fa..f29f940 100644
--- a/apps/backend/src/lib/post-order-handler.ts
+++ b/apps/backend/src/lib/post-order-handler.ts
@@ -35,7 +35,10 @@ const formatOrderMessageWithFullData = (ordersData: any[]): string => {
message += 'š¦ Items:\n';
order.orderItems?.forEach((item: any) => {
- message += ` ⢠${item.product?.name || 'Unknown'} x${item.quantity}\n`;
+ const productQuantity = item.product?.productQuantity ?? 1
+ const unitNotation = item.product?.unit?.shortNotation || ''
+ const quantityWithUnit = unitNotation ? `${productQuantity}${unitNotation}` : `${productQuantity}`
+ message += ` ⢠${item.product?.name || 'Unknown'} ${quantityWithUnit} x${item.quantity}\n`;
});
message += `\nš° Total: ā¹${order.totalAmount}\n`;
@@ -72,7 +75,12 @@ const formatCancellationMessage = (orderData: any, cancellationData: Cancellatio
š Phone: ${orderData.address?.phone || 'N/A'}
š¦ Items:
-${orderData.orderItems?.map((item: any) => ` ⢠${item.product?.name || 'Unknown'} x${item.quantity}`).join('\n') || ' N/A'}
+${orderData.orderItems?.map((item: any) => {
+ const productQuantity = item.product?.productQuantity ?? 1
+ const unitNotation = item.product?.unit?.shortNotation || ''
+ const quantityWithUnit = unitNotation ? `${productQuantity}${unitNotation}` : `${productQuantity}`
+ return ` ⢠${item.product?.name || 'Unknown'} ${quantityWithUnit} x${item.quantity}`
+}).join('\n') || ' N/A'}
š° Total: ā¹${orderData.totalAmount}
š³ Refund: ${orderData.refundStatus === 'na' ? 'N/A (COD)' : orderData.refundStatus || 'Pending'}
@@ -102,7 +110,7 @@ export const startOrderHandler = async (): Promise => {
where: inArray(orders.id, orderIds),
with: {
address: true,
- orderItems: { with: { product: true } },
+ orderItems: { with: { product: { with: { unit: true } } } },
slot: true,
},
});
@@ -147,7 +155,7 @@ export const startCancellationHandler = async (): Promise => {
where: eq(orders.id, cancellationData.orderId),
with: {
address: true,
- orderItems: { with: { product: true } },
+ orderItems: { with: { product: { with: { unit: true } } } },
refunds: true,
},
});