<?php

namespace App\Models;

use App\Models\Concerns\HasPublicId;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;

final class BankReconciliation extends Model
{
    use HasPublicId;

    protected $table = 'bank_reconciliations';

    protected $fillable = [
        'public_id',
        'bank_account_id',
        'statement_date',
        'statement_ending_balance',
        'book_ending_balance',
        'difference',
        'status',
        'closed_by',
        'closed_at',
    ];

    protected function casts(): array { return ['statement_date'=>'date', 'statement_ending_balance'=>'decimal:4', 'book_ending_balance'=>'decimal:4', 'difference'=>'decimal:4', 'closed_at'=>'datetime']; }
    public function bankAccount(): BelongsTo { return $this->belongsTo(BankAccount::class); }
    public function items(): HasMany { return $this->hasMany(BankReconciliationItem::class); }
}
