Files
sam-docs/dev/changes/20260126_quote_v2_transform_functions.md

86 lines
2.7 KiB
Markdown
Raw Permalink Normal View History

# 변경 내용 요약
**날짜:** 2026-01-26
**작업자:** Claude Code
**관련 계획:** docs/dev_plans/quote-management-url-migration-plan.md (Step 1.1)
## 📋 변경 개요
V2 견적 컴포넌트(QuoteRegistrationV2)에서 사용할 데이터 변환 함수 구현
- `transformV2ToApi`: V2 폼 데이터 → API 요청 형식
- `transformApiToV2`: API 응답 → V2 폼 데이터
## 📁 수정된 파일
- `react/src/components/quotes/types.ts` - V2 타입 정의 및 변환 함수 추가
## 🔧 상세 변경 사항
### 1. LocationItem 인터페이스 추가
발주 개소 항목의 데이터 구조 정의
```typescript
export interface LocationItem {
id: string;
floor: string; // 층
code: string; // 부호
openWidth: number; // 가로 (오픈사이즈 W)
openHeight: number; // 세로 (오픈사이즈 H)
productCode: string; // 제품코드
productName: string; // 제품명
quantity: number; // 수량
guideRailType: string; // 가이드레일 설치 유형
motorPower: string; // 모터 전원
controller: string; // 연동제어기
wingSize: number; // 마구리 날개치수
inspectionFee: number; // 검사비
// 계산 결과 (선택)
unitPrice?: number;
totalPrice?: number;
bomResult?: BomCalculationResult;
}
```
### 2. QuoteFormDataV2 인터페이스 추가
V2 컴포넌트용 폼 데이터 구조
```typescript
export interface QuoteFormDataV2 {
id?: string;
registrationDate: string;
writer: string;
clientId: string;
clientName: string;
siteName: string;
manager: string;
contact: string;
dueDate: string;
remarks: string;
status: 'draft' | 'temporary' | 'final';
locations: LocationItem[]; // V1의 items[] 대신 locations[] 사용
}
```
### 3. transformV2ToApi 함수 구현
V2 폼 데이터를 API 요청 형식으로 변환
**핵심 로직:**
1. `locations[]``calculation_inputs.items[]` (폼 복원용)
2. BOM 결과가 있으면 자재 상세를 `items[]`에 포함
3. 없으면 완제품 기준으로 `items[]` 생성
4. status 매핑: `final``finalized`, 나머지 → `draft`
### 4. transformApiToV2 함수 구현
API 응답을 V2 폼 데이터로 변환
**핵심 로직:**
1. `calculation_inputs.items[]``locations[]` 복원
2. 관련 BOM 자재에서 금액 계산
3. status 매핑: `finalized/converted``final`, 나머지 → `draft`
## ✅ 다음 작업 (Phase 1.2~1.4)
- [ ] test-new 페이지 API 연동 (createQuote)
- [ ] test/[id] 상세 페이지 API 연동 (getQuoteById)
- [ ] test/[id] 수정 API 연동 (updateQuote)
## 🔗 관련 문서
- 계획 문서: `docs/dev_plans/quote-management-url-migration-plan.md`
- V2 컴포넌트: `react/src/components/quotes/QuoteRegistrationV2.tsx`