<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class AccountStatement extends Model
{
    use HasFactory;

    protected $fillable = [
        'statement_account_id',
        'date_from',
        'date_to',
        'total_amount',
        'begin_balance',
        'end_balance',
        'total_rows',
        'mapped_rows',
    ];

    /**
     * Get the attributes that should be cast.
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'date_from' => 'date',
            'date_to' => 'date',
        ];
    }

    public function account()
    {
        return $this->belongsTo(StatementAccount::class, 'statement_account_id', 'id');
    }

    public function transactions()
    {
        return $this->hasMany(StatementTransaction::class);
    }
}
