<?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->decimal('shipping_cost', 15, 2)->default(0)->after('discount_total');
            $table->enum('sale_terms', ['cash', 'credit'])->default('cash')->after('layout');
            $table->string('delivery_place')->nullable()->after('sale_terms');
            $table->string('warranty')->nullable()->after('delivery_place');
        });

        Schema::table('invoice_items', function (Blueprint $table) {
            $table->string('note')->nullable()->after('line_total');
        });

        Schema::table('companies', function (Blueprint $table) {
            $table->string('tagline')->nullable()->after('name');
            $table->string('bank_account')->nullable()->after('national_id');
        });
    }

    public function down(): void
    {
        Schema::table('invoices', function (Blueprint $table) {
            $table->dropColumn(['shipping_cost', 'sale_terms', 'delivery_place', 'warranty']);
        });
        Schema::table('invoice_items', function (Blueprint $table) {
            $table->dropColumn('note');
        });
        Schema::table('companies', function (Blueprint $table) {
            $table->dropColumn(['tagline', 'bank_account']);
        });
    }
};
