From 63afa4fc9b85866cb7105fe3a4811b41f83fdc51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Fri, 30 Jan 2026 11:23:35 +0900 Subject: [PATCH] =?UTF-8?q?feat(API):=20=EA=B2=BD=EB=8F=99=20=EA=B2=AC?= =?UTF-8?q?=EC=A0=81=20=EA=B3=84=EC=82=B0=20=EA=B0=9C=EC=84=A0=20=EB=B0=8F?= =?UTF-8?q?=20stock=5Ftransactions=20=EA=B4=80=EA=B3=84=20=EB=AC=B8?= =?UTF-8?q?=EC=84=9C=20=EA=B0=B1=EC=8B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - FormulaEvaluatorService: 완제품 미등록 상태에서도 경동 전용 계산 진행, product_model/finishing_type/installation_type 변수 추가 - LOGICAL_RELATIONSHIPS.md: stock_transactions 모델 관계 반영 Co-Authored-By: Claude Opus 4.5 --- LOGICAL_RELATIONSHIPS.md | 10 ++++- .../Quote/FormulaEvaluatorService.php | 41 ++++++++++++------- 2 files changed, 35 insertions(+), 16 deletions(-) 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, '변수계산', [