fix: 단가관리 item_type_code 타입 정의 수정
- PriceApiItem.item_type_code를 'PRODUCT'|'MATERIAL'에서 string으로 변경 - 백엔드 통합된 item_type(FG, PT, SM, RM, CS) 값과 일치하도록 수정 - 사용되지 않는 mapItemTypeCode 함수 제거
This commit is contained in:
@@ -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<PriceApiItem[]> {
|
||||
* 품목 목록 + 단가 목록 병합
|
||||
*
|
||||
* - 품목 목록을 기준으로 순회
|
||||
* - 각 품목에 해당하는 단가 정보를 매핑
|
||||
* - 각 품목에 해당하는 단가 정보를 매핑 (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<string, PriceApiItem>();
|
||||
|
||||
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 (단가 등록 시 필요)
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ interface ApiResponse<T> {
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user