<?php

namespace App\Models;


use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphTo;

final class BankTransaction extends Model
{
    protected $table = 'bank_transactions';

    protected $fillable = [
        'bank_account_id',
        'transaction_date',
        'reference',
        'description',
        'debit',
        'credit',
        'running_balance',
        'source',
        'match_status',
        'matched_document_type',
        'matched_document_id',
    ];

    protected function casts(): array { return ['transaction_date'=>'date', 'debit'=>'decimal:4', 'credit'=>'decimal:4', 'running_balance'=>'decimal:4']; }
    public function bankAccount(): BelongsTo { return $this->belongsTo(BankAccount::class); }
    public function matchedDocument(): MorphTo { return $this->morphTo(); }
}
