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;