<?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 BankAccount extends Model
{
    use HasPublicId;

    protected $table = 'bank_accounts';

    protected $fillable = [
        'public_id',
        'company_id',
        'branch_id',
        'account_id',
        'bank_name',
        'account_name',
        'account_number',
        'iban',
        'swift',
        'currency_code',
        'opening_balance',
        'is_active',
    ];

    protected function casts(): array { return ['opening_balance'=>'decimal:4', 'is_active'=>'boolean']; }
    public function company(): BelongsTo { return $this->belongsTo(Company::class); }
    public function branch(): BelongsTo { return $this->belongsTo(Branch::class); }
    public function account(): BelongsTo { return $this->belongsTo(Account::class); }
    public function transactions(): HasMany { return $this->hasMany(BankTransaction::class); }
    public function reconciliations(): HasMany { return $this->hasMany(BankReconciliation::class); }
}
