feat: 견적 단가 자동 적용 기능 추가
- 고객 그룹별 단가 조정 지원 - 견적 생성 시 자동 단가 조회 - 매출단가만 사용 (매입단가는 경고)
This commit is contained in:
46
app/Models/Orders/ClientGroup.php
Normal file
46
app/Models/Orders/ClientGroup.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Orders;
|
||||
|
||||
use App\Traits\BelongsToTenant;
|
||||
use App\Traits\ModelTrait;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||
|
||||
class ClientGroup extends Model
|
||||
{
|
||||
use BelongsToTenant, ModelTrait, SoftDeletes;
|
||||
|
||||
protected $fillable = [
|
||||
'tenant_id',
|
||||
'group_code',
|
||||
'group_name',
|
||||
'price_rate',
|
||||
'is_active',
|
||||
'created_by',
|
||||
'updated_by',
|
||||
'deleted_by',
|
||||
];
|
||||
|
||||
protected $casts = [
|
||||
'price_rate' => 'decimal:4',
|
||||
'is_active' => 'boolean',
|
||||
];
|
||||
|
||||
// Clients 관계
|
||||
public function clients()
|
||||
{
|
||||
return $this->hasMany(Client::class, 'client_group_id');
|
||||
}
|
||||
|
||||
// 스코프
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('is_active', 1);
|
||||
}
|
||||
|
||||
public function scopeCode($query, string $code)
|
||||
{
|
||||
return $query->where('group_code', $code);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user