<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

/**
 * The tenant can choose to have every sales order converted into an invoice
 * the moment it is created — the order desk stops being a promise-to-invoice
 * queue and the shop books sales as they are taken. Defaults to off: the
 * existing behaviour (order first, invoice later, by hand) stays the default.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('app_settings', function (Blueprint $table) {
            $table->boolean('sales_order_auto_invoice')->default(false)->after('sales_order_deadline_warning_days');
        });
    }

    public function down(): void
    {
        Schema::table('app_settings', function (Blueprint $table) {
            $table->dropColumn('sales_order_auto_invoice');
        });
    }
};