add spatial plannings retribution calculations
This commit is contained in:
@@ -13,15 +13,17 @@ return new class extends Migration
|
||||
{
|
||||
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->string('code')->unique()->comment('Kode unik fungsi bangunan');
|
||||
$table->string('name', 255)->comment('Nama fungsi bangunan');
|
||||
$table->text('description')->nullable()->comment('Deskripsi detail fungsi bangunan');
|
||||
$table->unsignedBigInteger('parent_id')->nullable()->comment('ID parent untuk hierarki');
|
||||
$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->integer('level')->default(0)->comment('Level hierarki (0=root, 1=child, dst)');
|
||||
$table->integer('sort_order')->default(0)->comment('Urutan tampilan');
|
||||
$table->decimal('base_tariff', 15, 2)->nullable()->comment('Tarif dasar per m2');
|
||||
|
||||
// Indexes untuk performa
|
||||
$table->index(['parent_id', 'level']);
|
||||
$table->index(['level', 'sort_order']);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
<?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('floor_height_indices', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->integer('floor_number')->comment('Nomor lantai');
|
||||
$table->decimal('ip_ketinggian', 10, 6)->comment('Indeks ketinggian per lantai');
|
||||
$table->text('description')->nullable()->comment('Deskripsi indeks ketinggian');
|
||||
$table->timestamps();
|
||||
|
||||
// Unique constraint untuk floor_number
|
||||
$table->unique('floor_number');
|
||||
$table->index('floor_number');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('floor_height_indices');
|
||||
}
|
||||
};
|
||||
@@ -14,13 +14,12 @@ return new class extends Migration
|
||||
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->decimal('fungsi_bangunan', 10, 6)->nullable()->comment('Parameter fungsi bangunan');
|
||||
$table->decimal('ip_permanen', 10, 6)->nullable()->comment('Parameter IP permanen');
|
||||
$table->decimal('ip_kompleksitas', 10, 6)->nullable()->comment('Parameter IP kompleksitas');
|
||||
$table->decimal('indeks_lokalitas', 10, 6)->nullable()->comment('Parameter indeks lokalitas');
|
||||
$table->decimal('asumsi_prasarana', 8, 6)->nullable()->comment('Parameter asumsi prasarana untuk perhitungan retribusi');
|
||||
$table->decimal('koefisien_dasar', 15, 6)->nullable()->comment('Koefisien dasar perhitungan');
|
||||
$table->timestamps();
|
||||
|
||||
// Unique constraint untuk 1:1 relationship
|
||||
|
||||
@@ -14,14 +14,13 @@ return new class extends Migration
|
||||
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->string('name', 255)->comment('Nama formula');
|
||||
$table->integer('floor_number')->comment('Nomor lantai (1, 2, 3, dst, 0=semua lantai)');
|
||||
$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');
|
||||
// Indexes untuk performa
|
||||
$table->index(['building_function_id', 'floor_number'], 'idx_building_floor');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
<?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');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
<?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_proposals', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('spatial_planning_id')->nullable()->constrained('spatial_plannings')->onDelete('cascade');
|
||||
$table->foreignId('building_function_id')->constrained('building_functions')->onDelete('cascade');
|
||||
$table->foreignId('retribution_formula_id')->constrained('retribution_formulas')->onDelete('cascade');
|
||||
$table->string('proposal_number')->unique()->comment('Nomor usulan retribusi');
|
||||
$table->integer('floor_number')->comment('Nomor lantai (1, 2, 3, dst)');
|
||||
$table->decimal('floor_area', 15, 6)->comment('Luas lantai ini (m2)');
|
||||
$table->decimal('total_building_area', 15, 6)->comment('Total luas bangunan (m2)');
|
||||
$table->decimal('ip_ketinggian', 10, 6)->comment('IP ketinggian untuk lantai ini');
|
||||
$table->decimal('floor_retribution_amount', 15, 2)->comment('Jumlah retribusi untuk lantai ini');
|
||||
$table->decimal('total_retribution_amount', 15, 2)->comment('Total retribusi keseluruhan');
|
||||
$table->json('calculation_parameters')->nullable()->comment('Parameter yang digunakan dalam perhitungan');
|
||||
$table->json('calculation_breakdown')->nullable()->comment('Breakdown detail perhitungan');
|
||||
$table->text('notes')->nullable()->comment('Catatan tambahan');
|
||||
$table->datetime('calculated_at')->comment('Waktu perhitungan dilakukan');
|
||||
$table->timestamps();
|
||||
|
||||
// Indexes untuk performa
|
||||
$table->index(['spatial_planning_id', 'floor_number'], 'idx_spatial_floor');
|
||||
$table->index(['building_function_id'], 'idx_function');
|
||||
$table->index('calculated_at');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('retribution_proposals');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user