<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Modules\Payroll\Enums\CpfAccountsStatusEnum;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('cpf_accounts', function (Blueprint $table) {
            $table->id();
            $table->foreignId('employee_id')->constrained('employees')->cascadeOnDelete();
            $table->string('account_no')->nullable();
            $table->decimal('employee_percentage', 8, 2)->default(0);
            $table->decimal('employer_percentage', 8, 2)->default(0);
            $table->decimal('balance', 12, 2)->default(0);
            $table->date('opening_date')->nullable();
            $table->date('closing_date')->nullable();
            $table->enum('status', CpfAccountsStatusEnum::casesAsArray())->default(CpfAccountsStatusEnum::ACTIVE);
            $table->timestamps();
        });
    }

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