<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('dps_accounts', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('customer_id');
            // $table->string('dps_account_no')->unique();
            $table->decimal('monthly_amount', 12, 2);
            $table->integer('duration_months'); // 12, 24, 36
            $table->decimal('interest_rate', 5, 2)->comment('Interest percentage e.g. 6 = 6%');
            $table->enum('interest_type', ['daily', 'weekly', 'monthly'])->default('monthly');
            $table->date('start_date');
            $table->date('maturity_date');
            $table->decimal('total_deposit', 14, 2)->default(0);
            $table->decimal('interest_amount', 14, 2)->default(0);
            $table->decimal('maturity_amount', 14, 2)->default(0);
            $table->enum('status', ['running', 'completed', 'closed', 'withdrawn'])->default('running');

            $table->timestamps();
        });
    }

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