<?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::table('invoice_items', function (Blueprint $table) {
            // Add missing columns that the invoice create form expects
            $table->string('item_code', 50)->nullable()->after('item');
            $table->string('item_description', 255)->nullable()->after('item_code');
            $table->decimal('price', 15, 2)->nullable()->after('item_description');
            $table->enum('tax_type', ['inclusive', 'exclusive', 'exempt'])->default('exclusive')->after('price');
            $table->decimal('tax_rate', 5, 2)->default(0)->after('tax_type');
            $table->enum('status', ['active', 'inactive'])->default('active')->after('tax_rate');
        });
    }

    public function down(): void
    {
        Schema::table('invoice_items', function (Blueprint $table) {
            $table->dropColumn([
                'item_code',
                'item_description',
                'price',
                'tax_type',
                'tax_rate',
                'status',
            ]);
        });
    }
};
