fix: 견적 선택 다이얼로그에서 수주 전환된 견적 제외

- QuoteIndexRequest: for_order 파라미터 추가
- Quote 모델: orders() HasMany 관계 추가 (Order.quote_id 기준)
- QuoteService: for_order 필터링 로직 추가
  - whereNull('order_id') - 빠른 체크
  - whereDoesntHave('orders') - 이중 체크
- OrderService: 수주 생성 시 견적 상태를 converted로 업데이트

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-15 16:13:17 +09:00
parent 566f34a4c9
commit f9fa7cfd1e
4 changed files with 45 additions and 3 deletions

View File

@@ -40,9 +40,18 @@ public function index(array $params): LengthAwarePaginator
$sortBy = $params['sort_by'] ?? 'registration_date';
$sortOrder = $params['sort_order'] ?? 'desc';
$withItems = filter_var($params['with_items'] ?? false, FILTER_VALIDATE_BOOLEAN);
$forOrder = filter_var($params['for_order'] ?? false, FILTER_VALIDATE_BOOLEAN);
$query = Quote::query()->where('tenant_id', $tenantId);
// 수주 전환용 조회: 아직 수주가 생성되지 않은 견적만
if ($forOrder) {
// 1. Quote.order_id가 null인 것 (빠른 체크)
$query->whereNull('order_id');
// 2. Orders 테이블에 해당 quote_id가 없는 것 (이중 체크, 인덱스 있음)
$query->whereDoesntHave('orders');
}
// items 포함 (수주 전환용)
if ($withItems) {
$query->with(['items', 'client:id,name,contact_person,phone']);