From 82d21e9fe91641b739cd38d28d6933cc0725b26c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Fri, 23 Jan 2026 12:41:26 +0900 Subject: [PATCH] =?UTF-8?q?fix(WEB):=20=EC=88=98=EC=A3=BC=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=20-=20=EC=9D=B4=EB=8B=AC=20=EC=88=98=EC=A3=BC=20?= =?UTF-8?q?=EA=B8=88=EC=95=A1=20=EA=B3=84=EC=82=B0=20=EC=98=A4=EB=A5=98=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - formatAmountManwon: null/NaN 처리 추가 (0만원 반환) - 이달 수주 필터: 취소/수주등록 제외, 수주확정 이후만 포함 - amount 합산 시 Number() 변환 추가 (문자열 연결 → 숫자 덧셈) --- .../(protected)/sales/order-management-sales/page.tsx | 10 +++++++--- src/utils/formatAmount.ts | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/[locale]/(protected)/sales/order-management-sales/page.tsx b/src/app/[locale]/(protected)/sales/order-management-sales/page.tsx index 93fb6876..f23e4567 100644 --- a/src/app/[locale]/(protected)/sales/order-management-sales/page.tsx +++ b/src/app/[locale]/(protected)/sales/order-management-sales/page.tsx @@ -215,11 +215,15 @@ export default function OrderManagementSalesPage() { const now = new Date(); const startOfMonth = new Date(now.getFullYear(), now.getMonth(), 1); - // 이번 달 수주 금액 + // 이번 달 수주 금액 (수주확정 이후 건만 - 취소, 수주등록 제외) const thisMonthOrders = orders.filter( - (o) => new Date(o.orderDate) >= startOfMonth + (o) => + new Date(o.orderDate) >= startOfMonth && + o.status !== "cancelled" && + o.status !== "order_registered" ); - const thisMonthAmount = apiStats?.thisMonthAmount ?? thisMonthOrders.reduce((sum, o) => sum + o.amount, 0); + const thisMonthAmount = apiStats?.thisMonthAmount ?? thisMonthOrders.reduce((sum, o) => sum + (Number(o.amount) || 0), 0); + // 분할 대기 (예시: 수주확정 상태) const splitPendingCount = apiStats?.splitPending ?? orders.filter((o) => o.status === "order_confirmed").length; diff --git a/src/utils/formatAmount.ts b/src/utils/formatAmount.ts index dcc845a4..3f1f4950 100644 --- a/src/utils/formatAmount.ts +++ b/src/utils/formatAmount.ts @@ -34,6 +34,10 @@ export function formatAmountWon(amount: number): string { * 금액을 만원 단위로 포맷 (항상 "만원" 단위) */ export function formatAmountManwon(amount: number): string { + // NaN, undefined, null 처리 + if (amount == null || isNaN(amount)) { + return "0만원"; + } const manwon = Math.round(amount / 10000); return `${manwon.toLocaleString("ko-KR")}만원`; } \ No newline at end of file