<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        // Drop the existing employees table
        Schema::dropIfExists('payroll_settings');

        Schema::create('payroll_settings', function (Blueprint $table) {
            $table->id();
            $table->unsignedSmallInteger('night_differential_rate')->default(0);
            $table->string('pagibig_settings_frequency')->nullable();
            $table->string('pagibig_settings_basis')->nullable();
            $table->string('sss_settings_frequency')->nullable();
            $table->string('sss_settings_basis')->nullable();
            $table->string('philhealth_settings_frequency')->nullable();
            $table->string('philhealth_settings_basis')->nullable();
            $table->string('withholding_tax_settings_frequency')->nullable();
            $table->string('withholding_tax_settings_basis')->nullable();
            $table->string('tax_table_basis')->nullable();
            $table->unsignedSmallInteger('working_days_per_year')->nullable();
            $table->string('payment_type')->nullable();
            $table->decimal('cola_range_from',12,2)->nullable();
            $table->decimal('cola_range_to',12,2)->nullable();
            $table->decimal('minimum_wage_for_tax_exemption', 12, 2)->nullable();
            $table->time('night_differential_from')->nullable();
            $table->time('night_differential_to')->nullable();
            $table->unsignedMediumInteger('overtime_minute_from')->nullable();
            $table->unsignedMediumInteger('overtime_minute_to')->nullable();
            $table->unsignedSmallInteger('late_grace_period')->nullable();
            $table->unsignedSmallInteger('undertime_grace_period')->nullable();
            $table->unsignedSmallInteger('undertime_minute_from')->nullable();
            $table->unsignedSmallInteger('undertime_minute_to')->nullable();
            $table->unsignedSmallInteger('max_undertime_minute')->nullable();
            $table->text('gross_income_formula')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('payroll_settings', function (Blueprint $table) {
            //
        });
    }
};
