<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class TaxSetting extends Model
{
    protected $fillable = [
        'name',
        'rate',
        'is_active',
        'npwp',
        'pkp_name',
        'pkp_address',
        'notes',
    ];

    protected $casts = [
        'rate' => 'decimal:2',
        'is_active' => 'boolean',
    ];

    public static function current(): self
    {
        return static::query()->firstOrCreate(
            ['name' => 'PPN'],
            [
                'rate' => 11.00,
                'is_active' => false,
                'notes' => 'Aktifkan jika invoice ingin otomatis menggunakan PPN.',
            ]
        );
    }
}
