<?php

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

/**
 * Operational POS configuration, landlord-editable from the Master Control
 * tenant detail page (Settings tab, "Point of Sale" section).
 *
 * `pos_walkin_only` is the master switch for businesses that never register
 * customers: it removes customer selection from POS/checkout and disables
 * credit notes system-wide, since a credit note is meaningless without a
 * customer to hold it. `pos_amend_window_minutes` bounds the post-print
 * correction flow — how long after completing a sale a cashier may recall and
 * revise it without a manager.
 */
return new class extends Migration
{
    public function up(): void
    {
        Schema::table('tenant_settings', function (Blueprint $table) {
            $table->boolean('pos_walkin_only')->default(false)->after('locale_timezone');
            $table->unsignedSmallInteger('pos_amend_window_minutes')->default(30)->after('pos_walkin_only');
            $table->boolean('pos_allow_amend')->default(true)->after('pos_amend_window_minutes');
        });
    }

    public function down(): void
    {
        Schema::table('tenant_settings', function (Blueprint $table) {
            $table->dropColumn(['pos_walkin_only', 'pos_amend_window_minutes', 'pos_allow_amend']);
        });
    }
};
