<?php

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

return new class extends Migration
{
    /**
     * Add dedicated breakdown columns to employee_payrolls so the
     * Payroll History Report can show each figure separately.
     */
    public function up(): void
    {
        Schema::table('employee_payrolls', function (Blueprint $table) {
            $table->decimal('ot_hours',       8,  2)->default(0)->after('net_salary');
            $table->decimal('ot_amount',      12, 2)->default(0)->after('ot_hours');
            $table->decimal('award',          12, 2)->default(0)->after('ot_amount');
            $table->decimal('absent_days',    8,  2)->default(0)->after('award');
            $table->decimal('absent_amount',  12, 2)->default(0)->after('absent_days');
            $table->decimal('advance_deduction', 12, 2)->default(0)->after('absent_amount');
            $table->decimal('loan_deduction',    12, 2)->default(0)->after('advance_deduction');
            $table->decimal('other_deduction',   12, 2)->default(0)->after('loan_deduction');
        });
    }

    public function down(): void
    {
        Schema::table('employee_payrolls', function (Blueprint $table) {
            $table->dropColumn([
                'ot_hours','ot_amount','award',
                'absent_days','absent_amount',
                'advance_deduction','loan_deduction','other_deduction',
            ]);
        });
    }
};