<?php

namespace App\Models\Tenant;

use App\Models\Concerns\BelongsToTenant;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class PayrollRun extends Model
{
    use BelongsToTenant;

    protected $fillable = [
        'company_id', 'user_id', 'period',
        'base', 'works_revenue', 'works_pct_amount',
        'parts_margin', 'parts_pct_amount',
        'bonus', 'fines', 'advance', 'total',
        'paid', 'paid_at', 'notes',
    ];

    protected $casts = [
        'base' => 'decimal:2',
        'works_revenue' => 'decimal:2',
        'works_pct_amount' => 'decimal:2',
        'parts_margin' => 'decimal:2',
        'parts_pct_amount' => 'decimal:2',
        'bonus' => 'decimal:2',
        'fines' => 'decimal:2',
        'advance' => 'decimal:2',
        'total' => 'decimal:2',
        'paid' => 'boolean',
        'paid_at' => 'date',
    ];

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