diff --git a/LOGICAL_RELATIONSHIPS.md b/LOGICAL_RELATIONSHIPS.md index 12cf164..973dd58 100644 --- a/LOGICAL_RELATIONSHIPS.md +++ b/LOGICAL_RELATIONSHIPS.md @@ -1,6 +1,6 @@ # 논리적 데이터베이스 관계 문서 -> **자동 생성**: 2026-01-29 00:51:16 +> **자동 생성**: 2026-01-29 19:41:35 > **소스**: Eloquent 모델 관계 분석 ## 📊 모델별 관계 현황 @@ -907,6 +907,7 @@ ### stocks - **item()**: belongsTo → `items` - **creator()**: belongsTo → `users` - **lots()**: hasMany → `stock_lots` +- **transactions()**: hasMany → `stock_transactions` ### stock_lots **모델**: `App\Models\Tenants\StockLot` @@ -915,6 +916,13 @@ ### stock_lots - **receiving()**: belongsTo → `receivings` - **creator()**: belongsTo → `users` +### stock_transactions +**모델**: `App\Models\Tenants\StockTransaction` + +- **stock()**: belongsTo → `stocks` +- **stockLot()**: belongsTo → `stock_lots` +- **creator()**: belongsTo → `users` + ### subscriptions **모델**: `App\Models\Tenants\Subscription` diff --git a/app/Services/Quote/FormulaEvaluatorService.php b/app/Services/Quote/FormulaEvaluatorService.php index d3942d8..e679490 100644 --- a/app/Services/Quote/FormulaEvaluatorService.php +++ b/app/Services/Quote/FormulaEvaluatorService.php @@ -1596,31 +1596,34 @@ private function calculateKyungdongBom( ['var' => 'QTY', 'desc' => '수량', 'value' => $QTY, 'unit' => 'EA'], ['var' => 'bracket_inch', 'desc' => '브라켓 인치', 'value' => $bracketInch, 'unit' => '인치'], ['var' => 'product_type', 'desc' => '제품 타입', 'value' => $productType, 'unit' => ''], + ['var' => 'product_model', 'desc' => '모델코드', 'value' => $inputVariables['product_model'] ?? 'KSS01', 'unit' => ''], + ['var' => 'finishing_type', 'desc' => '마감타입', 'value' => $inputVariables['finishing_type'] ?? 'SUS', 'unit' => ''], + ['var' => 'installation_type', 'desc' => '설치타입', 'value' => $inputVariables['installation_type'] ?? '벽면형', 'unit' => ''], ], ]); - // Step 2: 완제품 조회 + // Step 2: 완제품 조회 (경동 전용 계산은 완제품 없이도 동작) $finishedGoods = $this->getItemDetails($finishedGoodsCode, $tenantId); - if (! $finishedGoods) { + if ($finishedGoods) { + $this->addDebugStep(2, '완제품선택', [ + 'code' => $finishedGoods['code'], + 'name' => $finishedGoods['name'], + 'item_category' => $finishedGoods['item_category'] ?? 'N/A', + ]); + } else { + // 경동 전용: 완제품 미등록 상태에서도 견적 계산 진행 + $finishedGoods = [ + 'code' => $finishedGoodsCode, + 'name' => $finishedGoodsCode, + 'item_category' => 'estimate', + ]; $this->addDebugStep(2, '완제품선택', [ 'code' => $finishedGoodsCode, - 'error' => '완제품을 찾을 수 없습니다.', + 'note' => '경동 전용 계산 - 완제품 미등록 상태로 진행', ]); - - return [ - 'success' => false, - 'error' => __('error.finished_goods_not_found', ['code' => $finishedGoodsCode]), - 'debug_steps' => $this->debugSteps, - ]; } - $this->addDebugStep(2, '완제품선택', [ - 'code' => $finishedGoods['code'], - 'name' => $finishedGoods['name'], - 'item_category' => $finishedGoods['item_category'] ?? 'N/A', - ]); - // KyungdongFormulaHandler 인스턴스 생성 $handler = new KyungdongFormulaHandler; @@ -1646,6 +1649,11 @@ private function calculateKyungdongBom( // 브라켓 크기 결정 $bracketSize = $handler->calculateBracketSize($weight, $bracketInch); + // 핸들러가 필요한 키 보장 (inputVariables에서 전달되지 않으면 기본값) + $productModel = $inputVariables['product_model'] ?? 'KSS01'; + $finishingType = $inputVariables['finishing_type'] ?? 'SUS'; + $installationType = $inputVariables['installation_type'] ?? '벽면형'; + $calculatedVariables = array_merge($inputVariables, [ 'W0' => $W0, 'H0' => $H0, @@ -1658,6 +1666,9 @@ private function calculateKyungdongBom( 'BRACKET_SIZE' => $bracketSize, 'bracket_inch' => $bracketInch, 'product_type' => $productType, + 'product_model' => $productModel, + 'finishing_type' => $finishingType, + 'installation_type' => $installationType, ]); $this->addDebugStep(3, '변수계산', [