From a197800d2f89385433d8b9716cad78ac199e124c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Mon, 26 Jan 2026 14:13:41 +0900 Subject: [PATCH] =?UTF-8?q?fix(SAM/react):=20=ED=95=A0=EC=9D=B8=EC=95=A1/?= =?UTF-8?q?=ED=95=A0=EC=9D=B8=EC=9C=A8=20=ED=91=9C=EC=8B=9C=20=ED=8F=AC?= =?UTF-8?q?=EB=A7=B7=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 할인액 0원일 때 -0원 → 0원으로 표시 - 할인율 소수점 있을 시 반올림 처리 (0.00% → 0%) --- .../order-management-sales/[id]/page.tsx | 29 ++++++++++++++++--- .../orders/documents/ContractDocument.tsx | 4 +-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/app/[locale]/(protected)/sales/order-management-sales/[id]/page.tsx b/src/app/[locale]/(protected)/sales/order-management-sales/[id]/page.tsx index fa62a077..bac7c48a 100644 --- a/src/app/[locale]/(protected)/sales/order-management-sales/[id]/page.tsx +++ b/src/app/[locale]/(protected)/sales/order-management-sales/[id]/page.tsx @@ -72,6 +72,27 @@ import { } from "@/components/orders"; import { sendSalesOrderNotification } from "@/lib/actions/fcm"; +/** + * 수량 포맷 함수 + * - EA, SET, PCS 등 개수 단위: 정수로 표시 + * - M, M2, KG, L 등 측정 단위: 소수점 이하 불필요한 0 제거 + */ +function formatQuantity(quantity: number, unit?: string): string { + const countableUnits = ["EA", "SET", "PCS", "개", "세트", "BOX", "ROLL"]; + const upperUnit = (unit || "").toUpperCase(); + + if (countableUnits.includes(upperUnit)) { + // 개수 단위는 정수로 반올림 + return Math.round(quantity).toLocaleString(); + } + + // 측정 단위는 소수점 4자리까지 반올림 후 불필요한 0 제거 + const rounded = Math.round(quantity * 10000) / 10000; + return rounded.toLocaleString(undefined, { + minimumFractionDigits: 0, + maximumFractionDigits: 4 + }); +} // 상태 뱃지 헬퍼 function getOrderStatusBadge(status: OrderStatus) { @@ -598,7 +619,7 @@ export default function OrderDetailPage() { {item.itemName} {item.spec || "-"} - {item.quantity} + {formatQuantity(item.quantity, item.unit)} {item.unit || "-"} {formatAmount(item.unitPrice || 0)}원 @@ -659,7 +680,7 @@ export default function OrderDetailPage() { {item.itemName} {item.spec || "-"} - {item.quantity} + {formatQuantity(item.quantity, item.unit)} {item.unit || "-"} {formatAmount(item.unitPrice || 0)}원 @@ -704,7 +725,7 @@ export default function OrderDetailPage() { {item.itemName} {item.spec || "-"} - {item.quantity} + {formatQuantity(item.quantity, item.unit)} {item.unit || "-"} {formatAmount(item.unitPrice || 0)}원 @@ -736,7 +757,7 @@ export default function OrderDetailPage() {
할인율: - {order.discountRate || 0}% + {Number.isInteger(order.discountRate || 0) ? (order.discountRate || 0) : Math.round(order.discountRate || 0)}%
총금액: diff --git a/src/components/orders/documents/ContractDocument.tsx b/src/components/orders/documents/ContractDocument.tsx index 76814417..df2bb61d 100644 --- a/src/components/orders/documents/ContractDocument.tsx +++ b/src/components/orders/documents/ContractDocument.tsx @@ -207,11 +207,11 @@ export function ContractDocument({ 공급가액 {formatAmount(subtotal)} 할인율 - {discountRate}% + {Number.isInteger(discountRate) ? discountRate : Math.round(discountRate)}% 할인액 - -{formatAmount(discountAmount)} + {discountAmount > 0 ? `-${formatAmount(discountAmount)}` : formatAmount(discountAmount)} 할인 후 공급가액 {formatAmount(afterDiscount)}