update retribution calculation spatial plannings

This commit is contained in:
arifal
2025-06-17 17:58:37 +07:00
parent 236b6f9bfc
commit 6946fa7074
14 changed files with 1069 additions and 1 deletions

View File

@@ -0,0 +1,44 @@
<?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('spatial_plannings', function (Blueprint $table) {
$table->text('no_tapak')->nullable();
$table->text('no_skkl')->nullable();
$table->text('no_ukl')->nullable();
$table->string('building_function')->nullable();
$table->string('sub_building_function')->nullable();
$table->integer('number_of_floors')->default(1);
$table->decimal('land_area', 18, 6)->nullable();
$table->decimal('site_bcr', 10, 6)->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('spatial_plannings', function (Blueprint $table) {
$table->dropColumn([
'no_tapak',
'no_skkl',
'no_ukl',
'building_function',
'sub_building_function',
'number_of_floors',
'land_area',
'site_bcr',
]);
});
}
};

View File

@@ -0,0 +1,37 @@
<?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::create('building_functions', function (Blueprint $table) {
$table->id();
$table->string('code')->unique();
$table->string('name');
$table->string('description')->nullable();
$table->unsignedBigInteger('parent_id')->nullable();
$table->foreign('parent_id')->references('id')->on('building_functions')->onDelete('cascade');
$table->boolean('is_active')->default(true);
$table->integer('level')->default(0);
$table->integer('sort_order')->default(0);
$table->index(['parent_id', 'is_active']);
$table->index(['level', 'sort_order']);
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('building_functions');
}
};

View File

@@ -0,0 +1,38 @@
<?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::create('building_function_parameters', function (Blueprint $table) {
$table->id();
$table->foreignId('building_function_id')->constrained('building_functions')->onDelete('cascade');
$table->decimal('fungsi_bangunan', 10, 6)->comment('Parameter fungsi bangunan');
$table->decimal('ip_permanen', 10, 6)->comment('Parameter IP permanen');
$table->decimal('ip_kompleksitas', 10, 6)->comment('Parameter IP kompleksitas');
$table->decimal('ip_ketinggian', 10, 6)->comment('Parameter IP ketinggian');
$table->decimal('indeks_lokalitas', 10, 6)->comment('Parameter indeks lokalitas');
$table->boolean('is_active')->default(true);
$table->text('notes')->nullable();
$table->timestamps();
// Unique constraint untuk 1:1 relationship
$table->unique('building_function_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('building_function_parameters');
}
};

View File

@@ -0,0 +1,35 @@
<?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::create('retribution_formulas', function (Blueprint $table) {
$table->id();
$table->foreignId('building_function_id')->constrained('building_functions')->onDelete('cascade');
$table->string('name')->comment('Nama formula');
$table->text('formula_expression')->comment('Rumus matematika untuk perhitungan');
$table->text('description')->nullable()->comment('Deskripsi formula');
$table->boolean('is_active')->default(true);
$table->timestamps();
// Unique constraint untuk 1:1 relationship
$table->unique('building_function_id');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('retribution_formulas');
}
};

View File

@@ -0,0 +1,44 @@
<?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::create('retribution_calculations', function (Blueprint $table) {
$table->id();
$table->foreignId('spatial_planning_id')->constrained('spatial_plannings')->onDelete('cascade');
$table->foreignId('retribution_formula_id')->nullable()->constrained('retribution_formulas')->onDelete('set null');
$table->foreignId('detected_building_function_id')->nullable()->constrained('building_functions')->onDelete('set null');
$table->decimal('luas_bangunan', 15, 6)->comment('Luas bangunan yang digunakan dalam perhitungan');
$table->json('used_parameters')->nullable()->comment('Parameter yang digunakan dalam perhitungan');
$table->string('used_formula')->nullable()->comment('Formula yang digunakan dalam perhitungan');
$table->decimal('calculation_result', 15, 6)->nullable()->comment('Hasil perhitungan retribusi');
$table->datetime('calculation_date')->nullable()->comment('Tanggal perhitungan');
$table->foreignId('calculated_by')->nullable()->constrained('users')->onDelete('set null');
$table->text('notes')->nullable();
$table->timestamps();
// Unique constraint untuk 1:1 relationship dengan spatial_plannings
$table->unique('spatial_planning_id');
// Index untuk performa query dengan nama yang lebih pendek
$table->index(['retribution_formula_id', 'calculation_date'], 'idx_formula_calc_date');
$table->index(['detected_building_function_id', 'calculation_date'], 'idx_building_func_calc_date');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('retribution_calculations');
}
};