<?php

namespace App\Modules\HR\Payroll\Models;

use App\Modules\PLATFORM\Settings\Models\Branch;
use App\Modules\PLATFORM\Settings\Models\BranchScoped;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;

class Addition extends Model
{
    use HasFactory;
    use BranchScoped;

    protected $table = 'additions';

    protected $fillable = [
        'branch_id',
        'code', 'name', 'payslip_label', 'description',
        'calculation_type', 'fixed_amount', 'formula_expression',
        'is_epf_applicable', 'is_etf_applicable',
        'is_gross_applicable', 'is_net_applicable',
        'sort_order', 'effective_from', 'effective_to', 'status',
    ];

    protected $casts = [
        'is_epf_applicable'   => 'boolean',
        'is_etf_applicable'   => 'boolean',
        'is_gross_applicable' => 'boolean',
        'is_net_applicable'   => 'boolean',
        'status'              => 'boolean',
        'effective_from'      => 'date',
        'effective_to'        => 'date',
    ];

    public function branch()
    {
        return $this->belongsTo(Branch::class);
    }

}
