<?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('refunds', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('tenant_id');
            $table->string('type', 20)->default('refund'); // refund, cancel
            $table->string('customer_name', 100);
            $table->date('request_date');
            $table->string('product_name', 100);
            $table->bigInteger('original_amount')->default(0);
            $table->bigInteger('refund_amount')->default(0);
            $table->string('reason', 100)->nullable();
            $table->string('status', 20)->default('pending'); // pending, approved, completed, rejected
            $table->date('process_date')->nullable();
            $table->text('note')->nullable();
            $table->timestamps();
            $table->softDeletes();
            $table->index(['tenant_id', 'status']);
            $table->index(['tenant_id', 'type']);
        });
    }

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