<?php

namespace Database\Seeders;

use App\Enums\PayrollAdjustmentType;
use App\Models\Payroll;
use App\Models\PayrollAdjustment;
use App\Models\User;
use Illuminate\Database\Seeder;

class PayrollAdjustmentSeeder extends Seeder
{
    public function run(): void
    {
        $payroll = Payroll::query()->first();
        $user = User::query()->first();

        if ($payroll === null || $user === null) {
            return;
        }

        PayrollAdjustment::factory()->bonus()->create([
            'payroll_id' => $payroll->id,
            'created_by_id' => $user->id,
            'type' => PayrollAdjustmentType::BONUS->value,
        ]);

        PayrollAdjustment::factory()->deduction()->create([
            'payroll_id' => $payroll->id,
            'created_by_id' => $user->id,
            'type' => PayrollAdjustmentType::DEDUCTION->value,
        ]);
    }
}
