<?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
    {
        Schema::table('payroll_summaries', function (Blueprint $table) {
            $table->renameColumn('monthly_salary', 'salary_rate');
            $table->decimal('other_income', 12, 2)->default(0)->after('basic_pay');
            $table->decimal('night_diff_total', 12, 2)->default(0)->after('overtime_total');
            $table->decimal('adjustments_total', 12, 2)->default(0)->after('non_taxable_addition');
            $table->decimal('other_deductions', 12, 2)->default(0)->after('non_taxable_deduction');
            $table->renameColumn('tardiness_amount', 'undertime_amount');
            $table->renameColumn('non_taxable_addition', 'benefits_total');
            $table->renameColumn('non_taxable_deduction', 'loans_total');
            $table->decimal('cola', 12, 2)->default(0)->after('basic_pay');
            $table->longText('details')->nullable()->after('net_pay');
            $table->dropColumn('work_hours');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('payroll_summaries', function (Blueprint $table) {
            $table->decimal('work_hours', 12, 2)->default(0)->after('salary_rate');
            $table->renameColumn('salary_rate', 'monthly_salary');
            $table->renameColumn('benefits_total', 'non_taxable_addition');
            $table->renameColumn('loans_total', 'non_taxable_deduction');
            $table->renameColumn('undertime_amount', 'tardiness_amount');
            $table->dropColumn('other_income');
            $table->dropColumn('cola');
            $table->dropColumn('night_diff_total');
            $table->dropColumn('adjustments_total');
            $table->dropColumn('other_deductions');
            $table->dropColumn('details');
        });
    }
};
