<?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('payments', function (Blueprint $table) {

            $table->id();

            $table->string('receipt_no',30)->unique();

            $table->foreignId('sales_invoice_id')
                ->constrained()
                ->restrictOnDelete();

            $table->foreignId('client_id')
                ->constrained()
                ->restrictOnDelete();

            $table->date('payment_date');

            $table->decimal('amount',15,2);

            $table->enum('payment_mode',[
                'Cash',
                'Card',
                'Bank Transfer',
                'Cheque',
                'UPI'
            ]);

            $table->string('reference_no')->nullable();

            $table->text('remarks')->nullable();

            $table->unsignedBigInteger('created_by')->nullable();

            $table->timestamps();

            $table->softDeletes();

        });
    }

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