<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::table('sales', function (Blueprint $table) {
            $table->enum('payment_method', ['cash', 'qris', 'debit'])->default('cash')->after('channel');
            $table->unsignedBigInteger('subtotal')->default(0)->after('user_id');
            $table->unsignedBigInteger('tax_amount')->default(0)->after('subtotal');
            $table->unsignedBigInteger('service_amount')->default(0)->after('tax_amount');
            $table->timestamp('voided_at')->nullable()->after('notes');
            $table->text('void_reason')->nullable()->after('voided_at');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('sales', function (Blueprint $table) {
            $table->dropColumn(['payment_method', 'subtotal', 'tax_amount', 'service_amount', 'voided_at', 'void_reason']);
        });
    }
};
