<?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('rnd_general_journals', function (Blueprint $table) {
            $table->id();
            $table->string('rnd_general_journal_number')->unique();
            $table->date('document_date');
            $table->decimal('nominal_debet',20,2)->nullable();
            $table->decimal('nominal_credit',20,2)->nullable();
            $table->text('note')->nullable();
            $table->string('company_code');
            $table->decimal('print_number',20,2)->nullable();
            $table->unsignedBigInteger('department_id');
            $table->unsignedBigInteger('created_by')->nullable();
            $table->unsignedBigInteger('updated_by')->nullable();
            $table->timestamps();

            $table->foreign('department_id')->references('id')->on('department')->onDelete('restrict');
            $table->foreign('created_by')->references('id')->on('users')->onDelete('restrict');
            $table->foreign('updated_by')->references('id')->on('users')->onDelete('restrict');
        });
    }

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