<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('return_purchases', function (Blueprint $table) {
            $table->id();
            $table->date('date');
            $table->string('purchase_id')->constrained('purchases')->onDelete('cascade');
            $table->string('supplier_id')->constrained('suppliers')->onDelete('cascade');
            $table->decimal('estimated_amount', 10, 2)->default(0.00);
            $table->string('discount', 10)->nullable();
            $table->decimal('discount_amount', 10, 2)->default(0.00);
            $table->decimal('total_return', 10, 2)->default(0.00);
            $table->tinyInteger('status')->default(0);
            $table->foreignId('created_by')->constrained('users')->onDelete('cascade');
            $table->timestamps();
        });
    }

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