<?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('asset_disposals', function (Blueprint $table) {
            $table->id();
            $table->foreignId('fiscal_year_id')->constrained('fiscal_years');
            $table->foreignId('accounting_period_id')->constrained('accounting_periods');
            $table->foreignId('asset_id')->constrained()->cascadeOnDelete();
            $table->date('disposal_date');
            $table->decimal('sale_amount', 15, 2)->default(0);
            $table->decimal('book_value', 15, 2);
            $table->decimal('gain_loss_amount', 15, 2)->default(0);
            $table->foreignId('voucher_id')->nullable()->constrained('account_vouchers')->nullOnDelete();
            $table->text('note')->nullable();
            $table->timestamps();
        });
    }

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