create service count floor level and retributions

This commit is contained in:
arifal
2025-06-18 18:44:30 +07:00
parent df70a47bd1
commit 59cc102c5a
13 changed files with 1415 additions and 180 deletions

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('master_parameters', function (Blueprint $table) {
$table->id();
$table->string('parameter_code', 255)->unique()->comment('Kode unik parameter');
$table->string('parameter_name', 255)->comment('Nama parameter');
$table->decimal('default_value', 15, 6)->default(0.000000)->comment('Nilai default parameter');
$table->string('unit', 50)->nullable()->comment('Satuan parameter');
$table->text('description')->nullable()->comment('Deskripsi parameter');
$table->timestamps();
// Add indexes for better performance
$table->index('parameter_name', 'idx_master_parameters_name');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('master_parameters');
}
};

View File

@@ -0,0 +1,36 @@
<?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('master_formulas', function (Blueprint $table) {
$table->id();
$table->string('formula_code', 255)->unique()->comment('Kode unik formula');
$table->string('formula_name', 255)->comment('Nama formula');
$table->text('formula_expression')->comment('Formula matematika');
$table->string('formula_category', 255)->nullable()->comment('Kategori formula');
$table->text('description')->nullable()->comment('Deskripsi formula');
$table->text('usage_notes')->nullable()->comment('Catatan penggunaan');
$table->timestamps();
// Add indexes for better performance
$table->index('formula_category', 'idx_master_formulas_category');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('master_formulas');
}
};

View File

@@ -0,0 +1,36 @@
<?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('formula_parameters', function (Blueprint $table) {
$table->id();
$table->foreignId('formula_id')->constrained('master_formulas')->onDelete('cascade')->comment('ID formula');
$table->foreignId('parameter_id')->constrained('master_parameters')->onDelete('cascade')->comment('ID parameter');
$table->timestamps();
// Composite unique constraint to prevent duplicate relations
$table->unique(['formula_id', 'parameter_id'], 'unique_formula_parameter');
// Indexes for better performance
$table->index('formula_id', 'idx_formula_parameters_formula');
$table->index('parameter_id', 'idx_formula_parameters_parameter');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('formula_parameters');
}
};

View File

@@ -0,0 +1,45 @@
<?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_formula_configs', function (Blueprint $table) {
$table->id();
$table->foreignId('building_function_id')->constrained('building_functions')->onDelete('cascade')->comment('ID fungsi bangunan');
$table->foreignId('formula_id')->constrained('master_formulas')->onDelete('cascade')->comment('ID formula yang digunakan');
$table->integer('floor_level')->comment('Level lantai (1, 2, 3, dst. 0 untuk semua lantai)');
$table->integer('min_floor')->nullable()->comment('Minimum lantai yang berlaku (opsional)');
$table->integer('max_floor')->nullable()->comment('Maximum lantai yang berlaku (opsional)');
$table->decimal('multiplier', 8, 4)->default(1.0000)->comment('Pengali khusus untuk lantai ini');
$table->boolean('is_active')->default(true)->comment('Status aktif konfigurasi');
$table->integer('priority')->default(0)->comment('Prioritas jika ada konflik (angka lebih besar = prioritas lebih tinggi)');
$table->text('notes')->nullable()->comment('Catatan konfigurasi');
$table->timestamps();
// Composite unique constraint untuk mencegah duplikasi konfigurasi
$table->unique(['building_function_id', 'formula_id', 'floor_level'], 'unique_building_formula_floor');
// Indexes untuk performa
$table->index(['building_function_id', 'floor_level'], 'idx_building_floor');
$table->index(['building_function_id', 'is_active'], 'idx_building_active');
$table->index(['floor_level', 'is_active'], 'idx_floor_active');
$table->index('priority', 'idx_priority');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('building_function_formula_configs');
}
};