<?php

namespace App\Models\Hr;

use App\Models\User;
use App\Traits\BelongsToStore;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class SalaryRecord extends Model
{
    use BelongsToStore;

    protected $fillable = [
        'store_id', 'user_id', 'year_month',
        'base_salary', 'position_salary', 'performance', 'overtime_pay',
        'subsidy', 'social_insurance', 'housing_fund', 'tax',
        'absence_deduction', 'other_deduction', 'actual_amount',
        'status', 'confirmed_at', 'paid_at',
    ];

    protected function casts(): array
    {
        return [
            'base_salary' => 'decimal:2',
            'position_salary' => 'decimal:2',
            'performance' => 'decimal:2',
            'overtime_pay' => 'decimal:2',
            'subsidy' => 'decimal:2',
            'social_insurance' => 'decimal:2',
            'housing_fund' => 'decimal:2',
            'tax' => 'decimal:2',
            'absence_deduction' => 'decimal:2',
            'other_deduction' => 'decimal:2',
            'actual_amount' => 'decimal:2',
            'status' => 'integer',
            'confirmed_at' => 'datetime',
            'paid_at' => 'datetime',
        ];
    }

    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }
}
