<?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('ledger_entries', function (Blueprint $table) {
            $table->id();
            $table->date('entry_date');
            $table->foreignId('chart_of_account_id')->constrained('chart_of_accounts');
            $table->foreignId('currency_id')->constrained('currencies');
            $table->decimal('amount', 15, 2);
            $table->text('description')->nullable();
            $table->string('source_type')->nullable(); // invoice, payment, wage, manual
            $table->unsignedBigInteger('source_id')->nullable();
            $table->foreignId('created_by')->constrained('users');
            $table->timestamps();
            $table->softDeletes();
        });
    }

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