<?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
    {
        if (Schema::hasTable('sale_returns')) {
            return;
        }

        Schema::create('sale_returns', function (Blueprint $table) {
            $table->id();
            $table->string('return_no', 50)->nullable()->index();
            $table->string('customer_name', 100)->index();
            $table->string('customer_phone', 20)->nullable()->index();
            $table->string('customer_address', 255)->nullable();
            $table->date('return_date')->index();
            $table->text('notes')->nullable();
            $table->decimal('refund_total', 12, 2)->default(0);
            $table->timestamps();
        });
    }

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