diff --git a/app/Services/FlowTester/ApiLogCapturer.php b/app/Services/FlowTester/ApiLogCapturer.php index 6335cc30..0161b2ae 100644 --- a/app/Services/FlowTester/ApiLogCapturer.php +++ b/app/Services/FlowTester/ApiLogCapturer.php @@ -192,4 +192,4 @@ private function decodeUnicodeEscapes(string $str): string return $str; } -} \ No newline at end of file +} diff --git a/docs/QUOTE_FORMULA_SEED_PLAN.md b/docs/QUOTE_FORMULA_SEED_PLAN.md new file mode 100644 index 00000000..578d98da --- /dev/null +++ b/docs/QUOTE_FORMULA_SEED_PLAN.md @@ -0,0 +1,253 @@ +# 견적수식 시드 데이터 구현 계획 + +## 📋 개요 + +`design/src/components/utils/formulaSampleData.ts`에 정의된 샘플 데이터를 +MNG의 `quote_formulas` 테이블에 시드(Seed)하여 관리할 수 있도록 구현합니다. + +--- + +## 🔍 분석 결과 + +### 소스 데이터 구조 (formulaSampleData.ts) + +| 데이터 종류 | 개수 | 설명 | +|------------|------|------| +| **itemMasters** | 21개 | 품목 마스터 (제품, 가이드레일, 케이스, 모터, 제어기 등) | +| **pricings** | 20개 | 품목별 판매/구매 단가 | +| **formulaRules** | 26개 | 수식 규칙 (계산식, 범위, 매핑) | +| **categoryGroups** | 11개 | 수식 카테고리 | + +### 수식 규칙 상세 (26개) + +| 카테고리 | 규칙 수 | 유형 | 설명 | +|----------|---------|------|------| +| 오픈사이즈 | 2 | formula | W0, H0 입력값 | +| 제작사이즈 | 4 | formula | W1, H1 (스크린/철재별) | +| 면적 | 1 | formula | W1 * H1 / 1000000 | +| 중량 | 2 | formula | 스크린/철재별 중량 계산 | +| 가이드레일 | 5 | formula/range | 길이, 자재선택, 설치유형별 수량 | +| 케이스 | 3 | formula/range | 사이즈, 자재 자동선택 | +| 모터 | 1 | range | 중량 기반 자동선택 | +| 제어기 | 1 | mapping | 유형별 자동선택 | +| 마구리 | 1 | formula | 날개 수량 계산 | +| 검사 | 1 | formula | 검사비 고정 | +| 단가수식 | 5 | formula | 품목별 단가 계산 | + +### 카테고리 그룹 (11개) + +``` +1. 오픈사이즈 6. 케이스 +2. 제작사이즈 7. 모터 +3. 면적 8. 제어기 +4. 중량 9. 마구리 +5. 가이드레일 10. 검사 + 11. 단가수식 +``` + +--- + +## 📊 데이터 매핑 + +### formulaSampleData → quote_formula_categories + +``` +categoryGroups → quote_formula_categories +├── id → id +├── name → name +├── name (uppercase) → code +├── description → description +├── order → sort_order +└── is_active: true +``` + +### formulaSampleData → quote_formulas + +``` +formulaRules → quote_formulas +├── ruleCode → variable +├── ruleName → name +├── category → category_id (FK) +├── ruleType → type (input/calculation/range/mapping) +├── inputVariable → (참조용 description에 포함) +├── formula/outputFormula → formula +├── unit → (metadata JSON) +├── description → description +├── status → is_active +└── ranges[] → quote_formula_ranges +``` + +### formulaSampleData → quote_formula_ranges + +``` +ranges[] → quote_formula_ranges +├── minValue → min_value +├── maxValue → max_value +├── result → result_value +├── itemCode → item_code +├── quantity → quantity +└── description → description +``` + +--- + +## 🛠️ 구현 계획 + +### Phase 1: Seeder 생성 (api/) + +**⚠️ 중요: MNG_CRITICAL_RULES에 따라 api/에서 Seeder 생성** + +| 순서 | 작업 | 예상 시간 | +|------|------|----------| +| 1.1 | QuoteFormulaCategorySeeder 생성 | 10분 | +| 1.2 | QuoteFormulaSeeder 생성 | 30분 | +| 1.3 | QuoteFormulaRangeSeeder 생성 | 15분 | +| 1.4 | DatabaseSeeder에 등록 | 5분 | + +### Phase 2: MNG에서 Seeder 참조 및 실행 + +| 순서 | 작업 | 예상 시간 | +|------|------|----------| +| 2.1 | mng에서 api Seeder 실행 방법 구현 | 15분 | +| 2.2 | 데이터 검증 및 테스트 | 10분 | + +### Phase 3: MNG 관리 UI 개선 (선택) + +| 순서 | 작업 | 예상 시간 | +|------|------|----------| +| 3.1 | 범위(Range) 관리 UI 추가 | 40분 | +| 3.2 | 매핑(Mapping) 관리 UI 추가 | 40분 | +| 3.3 | 시뮬레이터 연동 테스트 | 20분 | + +--- + +## 📝 상세 구현 + +### 1.1 QuoteFormulaCategorySeeder + +```php +// api/database/seeders/QuoteFormulaCategorySeeder.php + +$categories = [ + ['code' => 'OPEN_SIZE', 'name' => '오픈사이즈', 'description' => '제품의 설치 오픈 사이즈 (W0, H0)', 'sort_order' => 1], + ['code' => 'MAKE_SIZE', 'name' => '제작사이즈', 'description' => '실제 제작 사이즈 (W1, H1)', 'sort_order' => 2], + ['code' => 'AREA', 'name' => '면적', 'description' => '제품 면적 계산 (㎡)', 'sort_order' => 3], + ['code' => 'WEIGHT', 'name' => '중량', 'description' => '제품 중량 계산 (kg)', 'sort_order' => 4], + ['code' => 'GUIDE_RAIL', 'name' => '가이드레일', 'description' => '가이드레일 자동 선택 및 수량 계산', 'sort_order' => 5], + ['code' => 'CASE', 'name' => '케이스', 'description' => '케이스(셔터박스) 자동 선택', 'sort_order' => 6], + ['code' => 'MOTOR', 'name' => '모터', 'description' => '개폐전동기 자동 선택', 'sort_order' => 7], + ['code' => 'CONTROLLER', 'name' => '제어기', 'description' => '연동제어기 자동 선택', 'sort_order' => 8], + ['code' => 'EDGE_WING', 'name' => '마구리', 'description' => '마구리 날개 수량 계산', 'sort_order' => 9], + ['code' => 'INSPECTION', 'name' => '검사', 'description' => '제품 검사비', 'sort_order' => 10], + ['code' => 'PRICE_FORMULA', 'name' => '단가수식', 'description' => '품목별 단가 계산 수식', 'sort_order' => 11], +]; +``` + +### 1.2 QuoteFormulaSeeder (일부 예시) + +```php +// api/database/seeders/QuoteFormulaSeeder.php + +$formulas = [ + // 오픈사이즈 + [ + 'category_code' => 'OPEN_SIZE', + 'variable' => 'W0', + 'name' => '오픈사이즈 W0 (가로)', + 'type' => 'input', + 'formula' => null, + 'description' => '자동 견적 산출 섹션의 오픈사이즈 W0 입력값', + 'metadata' => ['unit' => 'mm'], + ], + [ + 'category_code' => 'OPEN_SIZE', + 'variable' => 'H0', + 'name' => '오픈사이즈 H0 (세로)', + 'type' => 'input', + 'formula' => null, + 'description' => '자동 견적 산출 섹션의 오픈사이즈 H0 입력값', + 'metadata' => ['unit' => 'mm'], + ], + + // 제작사이즈 + [ + 'category_code' => 'MAKE_SIZE', + 'variable' => 'W1_SCREEN', + 'name' => '제작사이즈 W1 (스크린)', + 'type' => 'calculation', + 'formula' => 'W0 + 140', + 'description' => '스크린 제작 가로 = 오픈 가로 + 140', + 'metadata' => ['unit' => 'mm', 'product_type' => 'screen'], + ], + + // 범위 타입 예시 + [ + 'category_code' => 'GUIDE_RAIL', + 'variable' => 'GR_AUTO_SELECT', + 'name' => '가이드레일 자재 자동 선택', + 'type' => 'range', + 'formula' => null, + 'description' => '가이드레일 길이 및 수량 자동 산출 (기본 2개)', + 'metadata' => ['unit' => 'EA'], + 'ranges' => [ + ['min' => 1219, 'max' => 2438, 'result' => '2438 2개', 'quantity' => 2], + ['min' => 2438, 'max' => 3000, 'result' => '3000 2개', 'quantity' => 2], + ], + ], +]; +``` + +--- + +## 📋 실행 순서 + +```bash +# 1. api/ 디렉토리에서 Seeder 생성 +cd ../api +php artisan make:seeder QuoteFormulaCategorySeeder +php artisan make:seeder QuoteFormulaSeeder + +# 2. Seeder 코드 작성 후 실행 +php artisan db:seed --class=QuoteFormulaCategorySeeder +php artisan db:seed --class=QuoteFormulaSeeder + +# 3. mng/에서 데이터 확인 +cd ../mng +php artisan tinker +>>> \App\Models\Quote\QuoteFormulaCategory::count() +>>> \App\Models\Quote\QuoteFormula::count() +``` + +--- + +## ⚠️ 주의사항 + +1. **tenant_id**: Seeder 실행 시 기본 tenant_id 설정 필요 +2. **중복 방지**: 이미 데이터가 있으면 건너뛰도록 처리 +3. **외래키**: category_id는 카테고리 먼저 생성 후 참조 +4. **트랜잭션**: 전체 Seeder를 트랜잭션으로 감싸기 + +--- + +## 📊 예상 결과 + +| 테이블 | 레코드 수 | +|--------|----------| +| quote_formula_categories | 11 | +| quote_formulas | 26 | +| quote_formula_ranges | ~10 | +| quote_formula_mappings | ~5 | + +--- + +## 🔄 향후 확장 + +1. **Excel Import**: 사용자가 Excel로 수식 일괄 등록 +2. **버전 관리**: 수식 변경 이력 추적 +3. **테스트 케이스**: 시뮬레이터에서 자동 테스트 +4. **API 연동**: React 프론트엔드에서 수식 사용 + +--- + +**작성일**: 2025-12-04 +**예상 소요 시간**: 2-3시간 (Phase 1-2) diff --git a/resources/views/archived-records/restore-check.blade.php b/resources/views/archived-records/restore-check.blade.php index 3a654461..d4927979 100644 --- a/resources/views/archived-records/restore-check.blade.php +++ b/resources/views/archived-records/restore-check.blade.php @@ -156,10 +156,10 @@ class="inline-flex items-center px-4 py-2 border border-gray-300 bg-white text-g 취소 @if($restoreCheck['can_restore']) -
+ @csrf -