- Client 관계: App\Models\Tenants\Client → App\Models\Orders\Client - Deposit, Withdrawal, Sale, Purchase 모델 수정 - User 관계: App\Models\User → App\Models\Members\User - Deposit, Withdrawal, Sale, Purchase, TaxInvoice, BarobillSetting, AiReport 모델 수정 Finance Deposits CRUD Test 통과 확인 (7/7 SUCCESS) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
111 lines
2.2 KiB
PHP
111 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Tenants;
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
class AiReport extends Model
|
|
{
|
|
use BelongsToTenant;
|
|
|
|
protected $fillable = [
|
|
'tenant_id',
|
|
'report_date',
|
|
'report_type',
|
|
'content',
|
|
'summary',
|
|
'input_data',
|
|
'status',
|
|
'error_message',
|
|
'created_by',
|
|
];
|
|
|
|
protected $casts = [
|
|
'report_date' => 'date',
|
|
'content' => 'array',
|
|
'input_data' => 'array',
|
|
];
|
|
|
|
/**
|
|
* 리포트 유형
|
|
*/
|
|
public const REPORT_TYPES = [
|
|
'daily' => '일일',
|
|
'weekly' => '주간',
|
|
'monthly' => '월간',
|
|
];
|
|
|
|
/**
|
|
* 리포트 상태
|
|
*/
|
|
public const STATUSES = [
|
|
'pending' => '생성중',
|
|
'completed' => '완료',
|
|
'failed' => '실패',
|
|
];
|
|
|
|
/**
|
|
* 분석 영역
|
|
*/
|
|
public const ANALYSIS_AREAS = [
|
|
'expense' => '지출분석',
|
|
'loan' => '가지급금',
|
|
'card_account' => '카드/계좌',
|
|
'receivable' => '미수금',
|
|
'sales' => '매출분석',
|
|
'purchase' => '매입분석',
|
|
];
|
|
|
|
/**
|
|
* 상태 코드
|
|
*/
|
|
public const STATUS_CODES = [
|
|
'critical' => '경고',
|
|
'warning' => '주의',
|
|
'positive' => '긍정',
|
|
'normal' => '양호',
|
|
];
|
|
|
|
/**
|
|
* 생성자 관계
|
|
*/
|
|
public function creator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(\App\Models\Members\User::class, 'created_by');
|
|
}
|
|
|
|
/**
|
|
* 리포트 유형 라벨
|
|
*/
|
|
public function getReportTypeLabelAttribute(): string
|
|
{
|
|
return self::REPORT_TYPES[$this->report_type] ?? $this->report_type;
|
|
}
|
|
|
|
/**
|
|
* 상태 라벨
|
|
*/
|
|
public function getStatusLabelAttribute(): string
|
|
{
|
|
return self::STATUSES[$this->status] ?? $this->status;
|
|
}
|
|
|
|
/**
|
|
* 완료 여부
|
|
*/
|
|
public function isCompleted(): bool
|
|
{
|
|
return $this->status === 'completed';
|
|
}
|
|
|
|
/**
|
|
* 실패 여부
|
|
*/
|
|
public function isFailed(): bool
|
|
{
|
|
return $this->status === 'failed';
|
|
}
|
|
}
|