<?php

namespace Modules\HR\Database\Seeders;

use Illuminate\Database\Seeder;
use Modules\Core\Database\Seeders\Traits\DisableForeignKeys;
use Modules\Core\Enums\StatusEnum;
use Modules\HR\Enums\SalaryComponentsTypeEnum;
use Modules\HR\Enums\SalaryStructureCalculationTypeEnum;
use Modules\HR\Models\SalaryComponent;

class SalaryComponentSeeder extends Seeder
{
    use DisableForeignKeys;

    public function run(): void
    {
        $this->disableForeignKeys();

        SalaryComponent::truncate();

        SalaryComponent::insert([
            [
                'name' => 'Basic Salary',
                'code' => 'BASIC',
                'type' => SalaryComponentsTypeEnum::EARNING,
                'calculation_type' => SalaryStructureCalculationTypeEnum::FIXED,
                'calculation_value' => 0,
                'calculation_basis' => null,
                'is_taxable' => true,
                'is_basic' => true,
                'is_cpf' => true,
                'affects_attendance' => false,
                'affects_overtime' => false,
                'include_in_gross' => true,
                'include_in_net' => true,
                'is_pro_rated' => true,
                'sort_order' => 1,
                'status' => StatusEnum::ACTIVE,
            ],
            [
                'name' => 'House Rent',
                'code' => 'HOUSE_RENT',
                'type' => SalaryComponentsTypeEnum::EARNING,
                'calculation_type' => SalaryStructureCalculationTypeEnum::FIXED,
                'calculation_value' => 0,
                'calculation_basis' => null,
                'is_taxable' => true,
                'is_basic' => false,
                'is_cpf' => false,
                'affects_attendance' => false,
                'affects_overtime' => false,
                'include_in_gross' => true,
                'include_in_net' => true,
                'is_pro_rated' => true,
                'sort_order' => 2,
                'status' => StatusEnum::ACTIVE,
            ],
        ]);

        $this->enableForeignKeys();
    }
}
