<?php

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

class AddPpnColumnsToCashTables extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // Tambah kolom di cashtransactions (tanpa after)
        Schema::table('cashtransactions', function (Blueprint $table) {
            $table->decimal('total_ppn', 15, 2)
                ->nullable();
            $table->boolean('is_pkp')->default(false);
        });

        // Tambah kolom di subcashtransactions (setelah total)
        Schema::table('subcashtransactions', function (Blueprint $table) {
            $table->decimal('ppn_amount', 15, 2)
                ->default(0)
                ->after('total');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('cashtransactions', function (Blueprint $table) {
            $table->dropColumn('total_ppn');
        });

        Schema::table('subcashtransactions', function (Blueprint $table) {
            $table->dropColumn('ppn_amount');
        });
    }
}
