<?php

namespace Database\Factories;

use App\Enums\IsPaid;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Payroll>
 */
class PayrollFactory extends Factory
{
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        $base = fake()->numberBetween(1000000, 5000000);
        $bonus = fake()->numberBetween(0, 500000);
        $deduction = fake()->numberBetween(0, 200000);

        return [
            'user_id' => User::factory(),
            'period_month' => now()->format('Y-m'),
            'base_salary' => $base,
            'bonus' => $bonus,
            'deduction' => $deduction,
            'total_salary' => $base + $bonus - $deduction,
            'is_paid' => fake()->randomElement(IsPaid::cases()),
            'paid_at' => fake()->optional()->dateTime(),
        ];
    }
}
