- 작업지시 우선순위 필드 추가 (priority 마이그레이션) - 수주-작업지시 품목 연동 source_order_item_id 컬럼 추가 - 수주 테이블에 account_code 필드 추가 - 작업지시 StoreRequest/UpdateRequest 우선순위 검증 추가 - WorkOrder 모델 priority fillable 추가 - 출근부 StoreRequest/UpdateRequest 검증 규칙 개선 - Employee Request 검증 규칙 수정 - SaleService/ItemService 수정 - WorkResultService 결과 처리 개선 - BankTransactionService 수정 - routes/api.php 엔드포인트 업데이트 - error.php 에러 메시지 추가 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
111 lines
2.3 KiB
PHP
111 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Tenants;
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
class Sale extends Model
|
|
{
|
|
use BelongsToTenant, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'sale_number',
|
|
'sale_date',
|
|
'client_id',
|
|
'supply_amount',
|
|
'tax_amount',
|
|
'total_amount',
|
|
'description',
|
|
'status',
|
|
'account_code',
|
|
'tax_invoice_issued',
|
|
'transaction_statement_issued',
|
|
'tax_invoice_id',
|
|
'deposit_id',
|
|
'created_by',
|
|
'updated_by',
|
|
'deleted_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'sale_date' => 'date:Y-m-d',
|
|
'supply_amount' => 'decimal:2',
|
|
'tax_amount' => 'decimal:2',
|
|
'total_amount' => 'decimal:2',
|
|
'client_id' => 'integer',
|
|
'tax_invoice_issued' => 'boolean',
|
|
'transaction_statement_issued' => 'boolean',
|
|
'tax_invoice_id' => 'integer',
|
|
'deposit_id' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* 상태 목록
|
|
*/
|
|
public const STATUSES = [
|
|
'draft' => '임시저장',
|
|
'confirmed' => '확정',
|
|
'invoiced' => '세금계산서발행',
|
|
];
|
|
|
|
/**
|
|
* 거래처 관계
|
|
*/
|
|
public function client(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Orders\Client::class);
|
|
}
|
|
|
|
/**
|
|
* 입금 관계
|
|
*/
|
|
public function deposit(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Deposit::class);
|
|
}
|
|
|
|
/**
|
|
* 생성자 관계
|
|
*/
|
|
public function creator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Members\User::class, 'created_by');
|
|
}
|
|
|
|
/**
|
|
* 상태 라벨
|
|
*/
|
|
public function getStatusLabelAttribute(): string
|
|
{
|
|
return self::STATUSES[$this->status] ?? $this->status;
|
|
}
|
|
|
|
/**
|
|
* 확정 가능 여부
|
|
*/
|
|
public function canConfirm(): bool
|
|
{
|
|
return $this->status === 'draft';
|
|
}
|
|
|
|
/**
|
|
* 수정 가능 여부
|
|
*/
|
|
public function canEdit(): bool
|
|
{
|
|
return $this->status === 'draft';
|
|
}
|
|
|
|
/**
|
|
* 삭제 가능 여부
|
|
*/
|
|
public function canDelete(): bool
|
|
{
|
|
return $this->status === 'draft';
|
|
}
|
|
}
|