<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('driver_payouts', function (Blueprint $table) {
            $table->id();
            $table->string('driver_name');
            $table->string('driver_bank');
            $table->string('driver_account_no', 30);
            $table->decimal('settlement_amount', 15, 2)->default(0);
            $table->date('payout_date')->nullable();
            $table->decimal('deficit', 15, 2)->default(0);
            $table->decimal('addition', 15, 2)->default(0);
            $table->decimal('total_amount', 15, 2)->default(0);
            $table->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();
            $table->timestamps();

            $table->index(['driver_bank', 'driver_account_no']);
            $table->index('payout_date');
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('driver_payouts');
    }
};
