<?php

namespace App\Models;

use App\Enums\AccountFeeType;
use App\Enums\Currency;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class Account extends Model
{
    use HasFactory;

    protected $fillable = [
        'name',
        'currency',
        'fee_type',
        'fee_percent',
        'fee_fixed',
    ];

    protected function casts(): array
    {
        return [
            'currency'    => Currency::class,
            'fee_type'    => AccountFeeType::class,
            'fee_percent' => 'decimal:2',
            'fee_fixed'   => 'decimal:2',
        ];
    }

    public function payments(): HasMany
    {
        return $this->hasMany(Payment::class);
    }

    public function isTakenos(): bool
    {
        return $this->fee_type === AccountFeeType::Takenos;
    }
}
