<?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('customers', function (Blueprint $table) {
            $table->string('gst_treatment')->nullable()->after('gstin');
            $table->string('pan', 10)->nullable()->after('gst_treatment');
            $table->string('tan', 20)->nullable()->after('pan');
            $table->string('tin', 50)->nullable()->after('tan');
            $table->string('vat', 50)->nullable()->after('tin');
            $table->string('website')->nullable()->after('vat');
            $table->string('currency', 10)->default('INR')->after('website');
            $table->boolean('also_use_as_vendor')->default(false)->after('currency');
            $table->boolean('client_wise_item_price')->default(false)->after('also_use_as_vendor');
            $table->string('contact_phone', 20)->nullable()->after('contact_person');
            $table->string('contact_email')->nullable()->after('contact_phone');
            $table->string('billing_address_line1')->nullable()->after('billing_address');
            $table->string('billing_address_line2')->nullable()->after('billing_address_line1');
            $table->boolean('has_shipping_address')->default(false)->after('shipping_address');
            $table->string('shipping_address_line1')->nullable()->after('has_shipping_address');
            $table->string('shipping_address_line2')->nullable()->after('shipping_address_line1');
            $table->string('shipping_city', 100)->nullable()->after('shipping_address_line2');
            $table->string('shipping_state', 100)->nullable()->after('shipping_city');
            $table->string('shipping_pincode', 10)->nullable()->after('shipping_state');
            $table->string('shipping_country', 100)->nullable()->after('shipping_pincode');
            $table->text('notes')->nullable()->after('balance_type');
            $table->text('other_info')->nullable()->after('notes');
            $table->json('additional_contacts')->nullable()->after('other_info');
        });
    }

    public function down(): void
    {
        Schema::table('customers', function (Blueprint $table) {
            $table->dropColumn([
                'gst_treatment', 'pan', 'tan', 'tin', 'vat', 'website', 'currency',
                'also_use_as_vendor', 'client_wise_item_price', 'contact_phone', 'contact_email',
                'billing_address_line1', 'billing_address_line2', 'has_shipping_address',
                'shipping_address_line1', 'shipping_address_line2', 'shipping_city',
                'shipping_state', 'shipping_pincode', 'shipping_country',
                'notes', 'other_info', 'additional_contacts',
            ]);
        });
    }
};
