2026-03-06 13:10:45 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models\Tenants;
|
|
|
|
|
|
|
|
|
|
use App\Traits\BelongsToTenant;
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
|
|
|
|
|
|
class JournalEntry extends Model
|
|
|
|
|
{
|
|
|
|
|
use BelongsToTenant, SoftDeletes;
|
|
|
|
|
|
|
|
|
|
protected $fillable = [
|
|
|
|
|
'tenant_id',
|
|
|
|
|
'entry_no',
|
|
|
|
|
'entry_date',
|
|
|
|
|
'entry_type',
|
|
|
|
|
'description',
|
|
|
|
|
'total_debit',
|
|
|
|
|
'total_credit',
|
|
|
|
|
'status',
|
|
|
|
|
'source_type',
|
|
|
|
|
'source_key',
|
|
|
|
|
'created_by_name',
|
|
|
|
|
'attachment_note',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
protected $casts = [
|
|
|
|
|
'entry_date' => 'date',
|
|
|
|
|
'total_debit' => 'integer',
|
|
|
|
|
'total_credit' => 'integer',
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
// Status
|
|
|
|
|
public const STATUS_DRAFT = 'draft';
|
|
|
|
|
public const STATUS_CONFIRMED = 'confirmed';
|
|
|
|
|
|
|
|
|
|
// Source type
|
|
|
|
|
public const SOURCE_MANUAL = 'manual';
|
|
|
|
|
public const SOURCE_BANK_TRANSACTION = 'bank_transaction';
|
2026-03-08 10:32:20 +09:00
|
|
|
public const SOURCE_TAX_INVOICE = 'tax_invoice';
|
|
|
|
|
public const SOURCE_CARD_TRANSACTION = 'card_transaction';
|
2026-03-06 13:10:45 +09:00
|
|
|
|
|
|
|
|
// Entry type
|
|
|
|
|
public const TYPE_GENERAL = 'general';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 분개 행 관계
|
|
|
|
|
*/
|
|
|
|
|
public function lines(): HasMany
|
|
|
|
|
{
|
|
|
|
|
return $this->hasMany(JournalEntryLine::class)->orderBy('line_no');
|
|
|
|
|
}
|
|
|
|
|
}
|