refactor:견적 converted 상태를 데이터 기반(order_id)으로 변경
- Quote 모델에 getStatusAttribute() accessor 추가: order_id 존재 시 자동으로 'converted' 반환
- scopeConverted() → whereNotNull('order_id') 변경
- QuoteService/OrderService에서 status='converted' 직접 세팅 제거, order_id만 세팅
- 상태 필터 쿼리: converted는 order_id IS NOT NULL 기반
- 통계 쿼리: status='converted' → order_id IS NOT NULL
- 수주 직접 등록 시에도 자동으로 수주전환 상태 반영
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -254,7 +254,7 @@ public function scopeFinalized($query)
|
||||
|
||||
public function scopeConverted($query)
|
||||
{
|
||||
return $query->where('status', self::STATUS_CONVERTED);
|
||||
return $query->whereNotNull('order_id');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -339,12 +339,29 @@ public function isEditable(): bool
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 상태 접근자: order_id가 존재하면 자동으로 'converted' 반환
|
||||
* DB에 status='converted'를 저장하지 않고, 수주 존재 여부로 판별
|
||||
*/
|
||||
public function getStatusAttribute($value): string
|
||||
{
|
||||
if ($this->order_id) {
|
||||
return self::STATUS_CONVERTED;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 삭제 가능 여부 확인
|
||||
*/
|
||||
public function isDeletable(): bool
|
||||
{
|
||||
return ! in_array($this->status, [self::STATUS_FINALIZED, self::STATUS_CONVERTED]);
|
||||
if ($this->order_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->getRawOriginal('status') !== self::STATUS_FINALIZED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user