feat: 견적 단가 자동 적용 기능 추가

- 고객 그룹별 단가 조정 지원
- 견적 생성 시 자동 단가 조회
- 매출단가만 사용 (매입단가는 경고)
This commit is contained in:
2025-10-13 21:52:34 +09:00
parent be36073282
commit a6b06be61d
17 changed files with 3794 additions and 47 deletions

View File

@@ -0,0 +1,51 @@
<?php
namespace App\Models\Orders;
use App\Traits\BelongsToTenant;
use App\Traits\ModelTrait;
use Illuminate\Database\Eloquent\Model;
class Client extends Model
{
use BelongsToTenant, ModelTrait;
protected $fillable = [
'tenant_id',
'client_group_id',
'client_code',
'name',
'contact_person',
'phone',
'email',
'address',
'is_active',
];
protected $casts = [
'is_active' => 'boolean',
];
// ClientGroup 관계
public function clientGroup()
{
return $this->belongsTo(ClientGroup::class, 'client_group_id');
}
// Orders 관계
public function orders()
{
return $this->hasMany(Order::class, 'client_id');
}
// 스코프
public function scopeActive($query)
{
return $query->where('is_active', 'Y');
}
public function scopeCode($query, string $code)
{
return $query->where('client_code', $code);
}
}