<?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('bill_payments', function (Blueprint $table) {
            // VAT info coming from reseller at the time of payment
            $table->decimal('reseller_vat_percentage', 8, 2)->default(0)->after('payment_method');
            $table->decimal('payment_amount_without_vat', 12, 2)->default(0)->after('reseller_vat_percentage');
            $table->decimal('vat_amount', 12, 2)->default(0)->after('payment_amount_without_vat');

            // Commission info based on reseller commission_percentage at payment time
            $table->decimal('reseller_commission_percentage', 8, 2)->default(0)->after('vat_amount');
            $table->decimal('reseller_commission_amount', 12, 2)->default(0)->after('reseller_commission_percentage');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('bill_payments', function (Blueprint $table) {
            $table->dropColumn([
                'reseller_vat_percentage',
                'payment_amount_without_vat',
                'vat_amount',
                'reseller_commission_percentage',
                'reseller_commission_amount',
            ]);
        });
    }
};

