<?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('misc_receipt_items', function (Blueprint $table) {
            $table->id();
            $table->foreignId('misc_receipt_id')
                ->constrained()
                ->cascadeOnDelete();
            $table->foreignId('item_id')->constrained();
            // snapshots
            $table->string('item_code_snapshot')->nullable();
            $table->string('item_name_snapshot')->nullable();
            $table->decimal('quantity', 10, 3);
            $table->decimal('unit_cost', 10, 4)->default(0);
            $table->softDeletes();
            $table->timestamps();
        });
    }

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