<?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::create('employee_monthly_summaries', function (Blueprint $table) {
            $table->id();
            $table->string('employee_id');
            $table->integer('month');
            $table->integer('year');

            $table->integer('days_worked')->default(0);
            $table->integer('sundays_eligible')->default(0);
            $table->integer('holidays')->default(0);
            $table->integer('leave_enjoyed')->default(0);
            $table->integer('total_paid_days')->default(0);
            $table->integer('absent')->default(0);
            $table->integer('first_shifts')->default(0);
            $table->integer('night_shifts')->default(0);

            $table->decimal('total_working_hours', 8, 2)->default(0);
            $table->decimal('total_ot_hours', 8, 2)->default(0);
            $table->decimal('total_shortage_hours', 8, 2)->default(0);

            $table->timestamps();

            $table->unique(['employee_id', 'month', 'year']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('employee_monthly_summaries');
    }
};
