fix: [QA] 수주 날짜 필터 COALESCE + 배차 상태 자동 전환 + 견적 날짜 캐스트 수정
- OrderService: 날짜 필터를 COALESCE(received_at, created_at)로 NULL 안전 처리 - VehicleDispatchService: update() 시 freight_cost_type 유무로 status 자동 결정 - Quote 모델: date 캐스트를 date:Y-m-d로 변경 (UTC 직렬화 방지)
This commit is contained in:
@@ -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`
|
||||
|
||||
|
||||
@@ -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만 필요)
|
||||
];
|
||||
|
||||
// 현재 라우트 확인 (경로 또는 이름)
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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');
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user