<?php

namespace Database\Factories;

use App\Enums\PayrollAdjustmentType;
use App\Models\Payroll;
use App\Models\PayrollAdjustment;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;

/**
 * @extends Factory<PayrollAdjustment>
 */
class PayrollAdjustmentFactory extends Factory
{
    public function definition(): array
    {
        return [
            'payroll_id' => Payroll::factory(),
            'type' => fake()->randomElement(PayrollAdjustmentType::cases())->value,
            'amount' => fake()->numberBetween(50_000, 1_000_000),
            'description' => fake()->sentence(3),
            'created_by_id' => User::factory(),
            'created_at' => now(),
        ];
    }

    public function bonus(): static
    {
        return $this->state(fn (array $attributes) => [
            'type' => PayrollAdjustmentType::BONUS->value,
        ]);
    }

    public function deduction(): static
    {
        return $this->state(fn (array $attributes) => [
            'type' => PayrollAdjustmentType::DEDUCTION->value,
        ]);
    }
}
