From bb4d9d8fbddf3a7d80cc8242cc422aeecc13e327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B6=8C=ED=98=81=EC=84=B1?= Date: Thu, 19 Mar 2026 23:57:56 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20[QA]=20=EC=88=98=EC=A3=BC=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=ED=95=84=ED=84=B0=20COALESCE=20+=20=EB=B0=B0?= =?UTF-8?q?=EC=B0=A8=20=EC=83=81=ED=83=9C=20=EC=9E=90=EB=8F=99=20=EC=A0=84?= =?UTF-8?q?=ED=99=98=20+=20=EA=B2=AC=EC=A0=81=20=EB=82=A0=EC=A7=9C=20?= =?UTF-8?q?=EC=BA=90=EC=8A=A4=ED=8A=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - OrderService: 날짜 필터를 COALESCE(received_at, created_at)로 NULL 안전 처리 - VehicleDispatchService: update() 시 freight_cost_type 유무로 status 자동 결정 - Quote 모델: date 캐스트를 date:Y-m-d로 변경 (UTC 직렬화 방지) --- LOGICAL_RELATIONSHIPS.md | 18 ++++++------------ app/Http/Middleware/ApiKeyMiddleware.php | 2 +- app/Models/Quote/Quote.php | 6 +++--- app/Services/OrderService.php | 6 +++--- app/Services/VehicleDispatchService.php | 4 ++++ 5 files changed, 17 insertions(+), 19 deletions(-) diff --git a/LOGICAL_RELATIONSHIPS.md b/LOGICAL_RELATIONSHIPS.md index 56a8c971..6174ca53 100644 --- a/LOGICAL_RELATIONSHIPS.md +++ b/LOGICAL_RELATIONSHIPS.md @@ -1,6 +1,6 @@ # 논리적 데이터베이스 관계 문서 -> **자동 생성**: 2026-03-19 16:29:38 +> **자동 생성**: 2026-03-19 16:09:46 > **소스**: Eloquent 모델 관계 분석 ## 📊 모델별 관계 현황 @@ -88,17 +88,6 @@ ### hometax_invoice_journals - **tenant()**: belongsTo → `tenants` - **invoice()**: belongsTo → `hometax_invoices` -### bending_data_rows -**모델**: `App\Models\BendingDataRow` - -- **bendingItem()**: belongsTo → `bending_items` - -### bending_items -**모델**: `App\Models\BendingItem` - -- **bendingData()**: hasMany → `bending_data` -- **files()**: hasMany → `files` - ### biddings **모델**: `App\Models\Bidding\Bidding` @@ -734,6 +723,11 @@ ### process_steps - **process()**: belongsTo → `processes` +### bending_item_mappings +**모델**: `App\Models\Production\BendingItemMapping` + +- **item()**: belongsTo → `items` + ### work_orders **모델**: `App\Models\Production\WorkOrder` diff --git a/app/Http/Middleware/ApiKeyMiddleware.php b/app/Http/Middleware/ApiKeyMiddleware.php index 7f0362c5..666b89fc 100644 --- a/app/Http/Middleware/ApiKeyMiddleware.php +++ b/app/Http/Middleware/ApiKeyMiddleware.php @@ -140,7 +140,7 @@ public function handle(Request $request, Closure $next) 'api/v1/debug-apikey', 'api/v1/internal/exchange-token', // 내부 서버간 토큰 교환 (HMAC 인증 사용) 'api/v1/admin/fcm/*', // Admin FCM API (MNG에서 API Key만으로 접근) - 'api/v1/app/*', // 앱 버전 확인/다운로드 (API Key만 필요) + 'api/v1/app/*', // 앱 버전 확인/다운로드 (API Key만 필요) ]; // 현재 라우트 확인 (경로 또는 이름) diff --git a/app/Models/Quote/Quote.php b/app/Models/Quote/Quote.php index 08e70a45..a1fbd311 100644 --- a/app/Models/Quote/Quote.php +++ b/app/Models/Quote/Quote.php @@ -78,9 +78,9 @@ class Quote extends Model ]; protected $casts = [ - 'registration_date' => 'date', - 'receipt_date' => 'date', - 'completion_date' => 'date', + 'registration_date' => 'date:Y-m-d', + 'receipt_date' => 'date:Y-m-d', + 'completion_date' => 'date:Y-m-d', 'finalized_at' => 'datetime', 'is_final' => 'boolean', 'calculation_inputs' => 'array', diff --git a/app/Services/OrderService.php b/app/Services/OrderService.php index 87058dd2..8eeb1eb4 100644 --- a/app/Services/OrderService.php +++ b/app/Services/OrderService.php @@ -93,12 +93,12 @@ public function index(array $params) $query->where('client_id', $clientId); } - // 날짜 범위 (수주일 기준) + // 날짜 범위 (수주일 기준, received_at NULL이면 created_at 폴백) if ($dateFrom !== null) { - $query->where('received_at', '>=', $dateFrom); + $query->where(DB::raw('COALESCE(DATE(received_at), DATE(created_at))'), '>=', $dateFrom); } if ($dateTo !== null) { - $query->where('received_at', '<=', $dateTo); + $query->where(DB::raw('COALESCE(DATE(received_at), DATE(created_at))'), '<=', $dateTo); } $query->orderByDesc('created_at'); diff --git a/app/Services/VehicleDispatchService.php b/app/Services/VehicleDispatchService.php index e72454de..e4b1eb6e 100644 --- a/app/Services/VehicleDispatchService.php +++ b/app/Services/VehicleDispatchService.php @@ -125,6 +125,10 @@ public function update(int $id, array $data): ShipmentVehicleDispatch } } + // 상태 자동 결정: freight_cost_type이 설정되면 completed (상차/직접배차는 금액 0 허용) + $freightCostType = $options['freight_cost_type'] ?? null; + $options['status'] = ! empty($freightCostType) ? 'completed' : 'draft'; + // 직접 컬럼 업데이트 $updateData = ['options' => $options]; foreach ($directFields as $field) {