<?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('invoices', function (Blueprint $table) {
            $table->string('title')->nullable()->after('number');
            $table->decimal('commission_percent', 5, 2)->nullable()->after('total');
            $table->decimal('late_fee_amount', 19, 0)->default(0)->after('commission_percent');
            $table->text('admin_reason')->nullable()->after('description');
            $table->string('tracking_code', 100)->nullable()->after('admin_reason');
            $table->string('payment_method', 30)->nullable()->after('tracking_code');
            $table->string('counterparty_name')->nullable()->after('payment_method');
            $table->string('counterparty_phone', 30)->nullable()->after('counterparty_name');
        });
    }

    public function down(): void
    {
        Schema::table('invoices', function (Blueprint $table) {
            $table->dropColumn([
                'title',
                'commission_percent',
                'late_fee_amount',
                'admin_reason',
                'tracking_code',
                'payment_method',
                'counterparty_name',
                'counterparty_phone',
            ]);
        });
    }
};
