fix(WEB): 수주관리 - 이달 수주 금액 계산 오류 수정
- formatAmountManwon: null/NaN 처리 추가 (0만원 반환) - 이달 수주 필터: 취소/수주등록 제외, 수주확정 이후만 포함 - amount 합산 시 Number() 변환 추가 (문자열 연결 → 숫자 덧셈)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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")}만원`;
|
||||
}
|
||||
Reference in New Issue
Block a user