<?php

namespace App\Models;

use App\Traits\BelongsToBranch;
use App\Traits\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;

class JournalEntry extends Model
{
    use BelongsToBranch, BelongsToTenant;

    protected $fillable = [
        'tenant_id',
        'branch_id',
        'entry_number',
        'entry_date',
        'source_type',
        'reference',
        'narration',
        'total_debit',
        'total_credit',
        'created_by',
    ];

    protected $casts = [
        'entry_date' => 'date',
        'total_debit' => 'decimal:2',
        'total_credit' => 'decimal:2',
    ];

    public function items()
    {
        return $this->hasMany(JournalItem::class);
    }
}
