<?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('employee_payable_payments', function (Blueprint $table) {
            $table->id();
            $table->string('employee_payable_payment_number')->unique();
            $table->date('employee_payable_payment_date');
            $table->decimal('total_debt',20,2);
            $table->unsignedBigInteger('acc_total')->nullable();
            $table->unsignedBigInteger('acc_disc')->nullable();
            $table->text('notes')->nullable();
            $table->string('company_code')->unsigned();
            $table->unsignedBigInteger('department_id');
            $table->unsignedBigInteger('created_by');
            $table->unsignedBigInteger('updated_by');
            $table->timestamps();

            $table->foreign('acc_total')->references('id')->on('coa')->onDelete('restrict');
            $table->foreign('acc_disc')->references('id')->on('coa')->onDelete('restrict');
            $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('employee_payable_payments');
    }
};
