From f4fe50fd3bb5d544e97195b00782b4219fa56d04 Mon Sep 17 00:00:00 2001 From: kent Date: Sun, 21 Dec 2025 17:23:00 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=8B=A8=EA=B0=80=EA=B4=80=EB=A6=AC=20i?= =?UTF-8?q?tem=5Ftype=5Fcode=20=ED=83=80=EC=9E=85=20=EC=A0=95=EC=9D=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 - PriceApiItem.item_type_code를 'PRODUCT'|'MATERIAL'에서 string으로 변경 - 백엔드 통합된 item_type(FG, PT, SM, RM, CS) 값과 일치하도록 수정 - 사용되지 않는 mapItemTypeCode 함수 제거 --- .../sales/pricing-management/page.tsx | 16 +++++----------- src/components/pricing/actions.ts | 2 +- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/app/[locale]/(protected)/sales/pricing-management/page.tsx b/src/app/[locale]/(protected)/sales/pricing-management/page.tsx index edecd877..84e98b8a 100644 --- a/src/app/[locale]/(protected)/sales/pricing-management/page.tsx +++ b/src/app/[locale]/(protected)/sales/pricing-management/page.tsx @@ -46,7 +46,7 @@ interface ItemsApiResponse { interface PriceApiItem { id: number; tenant_id: number; - item_type_code: 'PRODUCT' | 'MATERIAL'; + item_type_code: string; // FG, PT, SM, RM, CS (items.item_type과 동일) item_id: number; client_group_id: number | null; purchase_price: string | null; @@ -140,12 +140,6 @@ function mapStatus(apiStatus: string, isFinal: boolean): PricingStatus | 'not_re } } -// 품목 유형 → API item_type_code 매핑 (백엔드 pricing API용) -function mapItemTypeCode(itemType?: string): 'PRODUCT' | 'MATERIAL' { - // FG(제품)만 PRODUCT, 나머지는 모두 MATERIAL - return itemType === 'FG' ? 'PRODUCT' : 'MATERIAL'; -} - // ============================================ // API 호출 함수 // ============================================ @@ -225,7 +219,7 @@ async function getPricingList(): Promise { * 품목 목록 + 단가 목록 병합 * * - 품목 목록을 기준으로 순회 - * - 각 품목에 해당하는 단가 정보를 매핑 + * - 각 품목에 해당하는 단가 정보를 매핑 (item_type + item_id로 매칭) * - 단가 미등록 품목은 'not_registered' 상태로 표시 */ function mergeItemsWithPricing( @@ -233,7 +227,7 @@ function mergeItemsWithPricing( pricings: PriceApiItem[] ): PricingListItem[] { // 단가 정보를 빠르게 찾기 위한 Map 생성 - // key: "PRODUCT_123" 또는 "MATERIAL_456" + // key: "{item_type}_{item_id}" (예: "FG_123", "PT_456") const pricingMap = new Map(); for (const pricing of pricings) { @@ -267,7 +261,7 @@ function mergeItemsWithPricing( status: mapStatus(pricing.status, pricing.is_final), currentRevision: 0, isFinal: pricing.is_final, - itemTypeCode: item.item_type, // PRODUCT 또는 MATERIAL (등록 시 필요) + itemTypeCode: item.item_type, // FG, PT, SM, RM, CS (단가 등록 시 필요) }; } else { // 단가 미등록 품목 @@ -287,7 +281,7 @@ function mergeItemsWithPricing( status: 'not_registered' as const, currentRevision: 0, isFinal: false, - itemTypeCode: item.item_type, // PRODUCT 또는 MATERIAL (등록 시 필요) + itemTypeCode: item.item_type, // FG, PT, SM, RM, CS (단가 등록 시 필요) }; } }); diff --git a/src/components/pricing/actions.ts b/src/components/pricing/actions.ts index 1ca4bfea..23d1d4de 100644 --- a/src/components/pricing/actions.ts +++ b/src/components/pricing/actions.ts @@ -27,7 +27,7 @@ interface ApiResponse { interface PriceApiData { id: number; tenant_id: number; - item_type_code: 'PRODUCT' | 'MATERIAL'; + item_type_code: string; // FG, PT, SM, RM, CS (items.item_type과 동일) item_id: number; client_group_id: number | null; purchase_price: string | null;