<?php

declare(strict_types=1);

namespace Maestro\Core\Modules\Invoices\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

class VatRate extends Model
{
    protected $table = 'maestro_vat_rates';

    /**
     * @var list<string>
     */
    protected $fillable = [
        'label',
        'rate_percent',
        'is_active',
        'sort_order',
    ];

    /**
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'rate_percent' => 'decimal:4',
            'is_active' => 'boolean',
        ];
    }

    /**
     * @return HasMany<InvoiceLine, VatRate>
     */
    public function invoiceLines(): HasMany
    {
        return $this->hasMany(InvoiceLine::class, 'vat_rate_id');
    }
}
