- ExpectedExpense 모델 및 마이그레이션 생성 - ExpectedExpenseService 구현 (CRUD, 일괄삭제, 지급일 변경, 요약) - ExpectedExpenseController REST API 구현 - FormRequest 검증 클래스 3개 생성 - Swagger API 문서 작성 - 라우트 추가 (8개 엔드포인트) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
135 lines
3.0 KiB
PHP
135 lines
3.0 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 ExpectedExpense extends Model
|
|
{
|
|
use BelongsToTenant, SoftDeletes;
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'expected_payment_date',
|
|
'settlement_date',
|
|
'transaction_type',
|
|
'amount',
|
|
'client_id',
|
|
'client_name',
|
|
'bank_account_id',
|
|
'account_code',
|
|
'payment_status',
|
|
'approval_status',
|
|
'description',
|
|
'created_by',
|
|
'updated_by',
|
|
'deleted_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'expected_payment_date' => 'date',
|
|
'settlement_date' => 'date',
|
|
'amount' => 'decimal:2',
|
|
'client_id' => 'integer',
|
|
'bank_account_id' => 'integer',
|
|
];
|
|
|
|
/**
|
|
* 거래유형 목록
|
|
*/
|
|
public const TRANSACTION_TYPES = [
|
|
'purchase' => '매입',
|
|
'advance' => '선급금',
|
|
'suspense' => '가지급금',
|
|
'rent' => '임대료',
|
|
'salary' => '급여',
|
|
'insurance' => '보험료',
|
|
'tax' => '세금',
|
|
'utilities' => '공과금',
|
|
'other' => '기타',
|
|
];
|
|
|
|
/**
|
|
* 지급상태 목록
|
|
*/
|
|
public const PAYMENT_STATUSES = [
|
|
'pending' => '미지급',
|
|
'partial' => '부분지급',
|
|
'paid' => '지급완료',
|
|
'overdue' => '연체',
|
|
];
|
|
|
|
/**
|
|
* 결재상태 목록
|
|
*/
|
|
public const APPROVAL_STATUSES = [
|
|
'none' => '미신청',
|
|
'pending' => '결재대기',
|
|
'approved' => '결재완료',
|
|
'rejected' => '반려',
|
|
];
|
|
|
|
/**
|
|
* 거래처 관계
|
|
*/
|
|
public function client(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Orders\Client::class);
|
|
}
|
|
|
|
/**
|
|
* 계좌 관계
|
|
*/
|
|
public function bankAccount(): BelongsTo
|
|
{
|
|
return $this->belongsTo(BankAccount::class);
|
|
}
|
|
|
|
/**
|
|
* 생성자 관계
|
|
*/
|
|
public function creator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Members\User::class, 'created_by');
|
|
}
|
|
|
|
/**
|
|
* 거래처명 조회 (회원/비회원 통합)
|
|
*/
|
|
public function getDisplayClientNameAttribute(): string
|
|
{
|
|
if ($this->client) {
|
|
return $this->client->name;
|
|
}
|
|
|
|
return $this->client_name ?? '';
|
|
}
|
|
|
|
/**
|
|
* 거래유형 라벨
|
|
*/
|
|
public function getTransactionTypeLabelAttribute(): string
|
|
{
|
|
return self::TRANSACTION_TYPES[$this->transaction_type] ?? $this->transaction_type;
|
|
}
|
|
|
|
/**
|
|
* 지급상태 라벨
|
|
*/
|
|
public function getPaymentStatusLabelAttribute(): string
|
|
{
|
|
return self::PAYMENT_STATUSES[$this->payment_status] ?? $this->payment_status;
|
|
}
|
|
|
|
/**
|
|
* 결재상태 라벨
|
|
*/
|
|
public function getApprovalStatusLabelAttribute(): string
|
|
{
|
|
return self::APPROVAL_STATUSES[$this->approval_status] ?? $this->approval_status;
|
|
}
|
|
}
|