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, }, });