217 lines
8.5 KiB
PHP
217 lines
8.5 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders;
|
|
|
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
|
use Illuminate\Database\Seeder;
|
|
use App\Models\BuildingFunctionFormulaConfig;
|
|
use App\Models\BuildingFunction;
|
|
use App\Models\MasterFormula;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Carbon\Carbon;
|
|
|
|
class BuildingFunctionFormulaConfigSeeder extends Seeder
|
|
{
|
|
/**
|
|
* Run the database seeds.
|
|
*/
|
|
public function run(): void
|
|
{
|
|
$now = Carbon::now();
|
|
|
|
// Mapping Building Function Codes to IDs (sesuai dengan BuildingFunctionSeeder)
|
|
$buildingFunctionMapping = [
|
|
'AGAMA' => 1, // Fungsi Keagamaan
|
|
'SOSIAL_BUDAYA' => 2, // Fungsi Sosial Budaya
|
|
'CAMPURAN_KECIL' => 6, // Campuran Kecil
|
|
'CAMPURAN_BESAR' => 7, // Campuran Besar
|
|
'USAHA_KECIL' => 8, // UMKM
|
|
'USAHA_BESAR' => 9, // Usaha Besar (Non-Mikro)
|
|
'HUNIAN_SEDERHANA' => 10, // Hunian Sederhana <100
|
|
'HUNIAN_TIDAK_SEDERHANA' => 11, // Hunian Tidak Sederhana >100
|
|
];
|
|
|
|
// Get Formula IDs (akan dibuat di MasterFormulaSeeder)
|
|
$formulaMapping = [
|
|
'BEBAS' => 'RETRIBUSI_BEBAS',
|
|
'DASAR' => 'RETRIBUSI_DASAR',
|
|
'LENGKAP' => 'RETRIBUSI_DENGAN_PRASARANA'
|
|
];
|
|
|
|
// Configurations per Building Function dan Floor Level
|
|
$configs = [];
|
|
|
|
// 1. FUNGSI KEAGAMAAN - Bebas Retribusi (semua lantai)
|
|
$configs[] = [
|
|
'building_function_id' => $buildingFunctionMapping['AGAMA'],
|
|
'formula_code' => 'RETRIBUSI_BEBAS',
|
|
'floor_level' => 0, // Berlaku untuk semua lantai
|
|
'min_floor' => null,
|
|
'max_floor' => null,
|
|
'multiplier' => 1.0000,
|
|
'is_active' => true,
|
|
'priority' => 1,
|
|
'notes' => 'Bangunan keagamaan bebas retribusi untuk semua lantai'
|
|
];
|
|
|
|
// 2. FUNGSI SOSIAL BUDAYA - Formula dengan parameter khusus
|
|
for ($floor = 1; $floor <= 6; $floor++) {
|
|
$configs[] = [
|
|
'building_function_id' => $buildingFunctionMapping['SOSIAL_BUDAYA'],
|
|
'formula_code' => 'RETRIBUSI_DENGAN_PRASARANA',
|
|
'floor_level' => $floor,
|
|
'min_floor' => null,
|
|
'max_floor' => null,
|
|
'multiplier' => 1.0000,
|
|
'is_active' => true,
|
|
'priority' => 1,
|
|
'notes' => "Sosial budaya lantai {$floor} - menggunakan parameter khusus sosial budaya"
|
|
];
|
|
}
|
|
|
|
// 3. CAMPURAN KECIL - Formula per lantai
|
|
for ($floor = 1; $floor <= 6; $floor++) {
|
|
$configs[] = [
|
|
'building_function_id' => $buildingFunctionMapping['CAMPURAN_KECIL'],
|
|
'formula_code' => 'RETRIBUSI_DENGAN_PRASARANA',
|
|
'floor_level' => $floor,
|
|
'min_floor' => null,
|
|
'max_floor' => null,
|
|
'multiplier' => 1.0000,
|
|
'is_active' => true,
|
|
'priority' => 1,
|
|
'notes' => "Campuran kecil lantai {$floor} - parameter fungsi 0.6"
|
|
];
|
|
}
|
|
|
|
// 4. CAMPURAN BESAR - Formula per lantai
|
|
for ($floor = 1; $floor <= 6; $floor++) {
|
|
$configs[] = [
|
|
'building_function_id' => $buildingFunctionMapping['CAMPURAN_BESAR'],
|
|
'formula_code' => 'RETRIBUSI_DENGAN_PRASARANA',
|
|
'floor_level' => $floor,
|
|
'min_floor' => null,
|
|
'max_floor' => null,
|
|
'multiplier' => 1.0000,
|
|
'is_active' => true,
|
|
'priority' => 1,
|
|
'notes' => "Campuran besar lantai {$floor} - parameter fungsi 0.8"
|
|
];
|
|
}
|
|
|
|
// 5. UMKM - Formula per lantai
|
|
for ($floor = 1; $floor <= 6; $floor++) {
|
|
$configs[] = [
|
|
'building_function_id' => $buildingFunctionMapping['USAHA_KECIL'],
|
|
'formula_code' => 'RETRIBUSI_DENGAN_PRASARANA',
|
|
'floor_level' => $floor,
|
|
'min_floor' => null,
|
|
'max_floor' => null,
|
|
'multiplier' => 1.0000,
|
|
'is_active' => true,
|
|
'priority' => 1,
|
|
'notes' => "UMKM lantai {$floor} - parameter fungsi 0.5"
|
|
];
|
|
}
|
|
|
|
// 6. USAHA BESAR - Formula per lantai
|
|
for ($floor = 1; $floor <= 6; $floor++) {
|
|
$configs[] = [
|
|
'building_function_id' => $buildingFunctionMapping['USAHA_BESAR'],
|
|
'formula_code' => 'RETRIBUSI_DENGAN_PRASARANA',
|
|
'floor_level' => $floor,
|
|
'min_floor' => null,
|
|
'max_floor' => null,
|
|
'multiplier' => 1.0000,
|
|
'is_active' => true,
|
|
'priority' => 1,
|
|
'notes' => "Usaha besar lantai {$floor} - parameter fungsi 0.7"
|
|
];
|
|
}
|
|
|
|
// 7. HUNIAN SEDERHANA - Formula khusus dengan IP Kompleksitas 0.3
|
|
for ($floor = 1; $floor <= 6; $floor++) {
|
|
$configs[] = [
|
|
'building_function_id' => $buildingFunctionMapping['HUNIAN_SEDERHANA'],
|
|
'formula_code' => 'RETRIBUSI_DENGAN_PRASARANA',
|
|
'floor_level' => $floor,
|
|
'min_floor' => null,
|
|
'max_floor' => null,
|
|
'multiplier' => 1.0000,
|
|
'is_active' => true,
|
|
'priority' => 1,
|
|
'notes' => "Hunian sederhana lantai {$floor} - parameter fungsi 0.15, IP kompleksitas 0.3"
|
|
];
|
|
}
|
|
|
|
// 8. HUNIAN TIDAK SEDERHANA - Formula standar
|
|
for ($floor = 1; $floor <= 6; $floor++) {
|
|
$configs[] = [
|
|
'building_function_id' => $buildingFunctionMapping['HUNIAN_TIDAK_SEDERHANA'],
|
|
'formula_code' => 'RETRIBUSI_DENGAN_PRASARANA',
|
|
'floor_level' => $floor,
|
|
'min_floor' => null,
|
|
'max_floor' => null,
|
|
'multiplier' => 1.0000,
|
|
'is_active' => true,
|
|
'priority' => 1,
|
|
'notes' => "Hunian tidak sederhana lantai {$floor} - parameter fungsi 0.17"
|
|
];
|
|
}
|
|
|
|
// Insert configurations
|
|
foreach ($configs as $config) {
|
|
// Get formula ID
|
|
$formula = DB::table('master_formulas')
|
|
->where('formula_code', $config['formula_code'])
|
|
->first();
|
|
|
|
if ($formula) {
|
|
DB::table('building_function_formula_configs')->updateOrInsert(
|
|
[
|
|
'building_function_id' => $config['building_function_id'],
|
|
'formula_id' => $formula->id,
|
|
'floor_level' => $config['floor_level']
|
|
],
|
|
[
|
|
'min_floor' => $config['min_floor'],
|
|
'max_floor' => $config['max_floor'],
|
|
'multiplier' => $config['multiplier'],
|
|
'is_active' => $config['is_active'],
|
|
'priority' => $config['priority'],
|
|
'notes' => $config['notes'],
|
|
'created_at' => $now,
|
|
'updated_at' => $now
|
|
]
|
|
);
|
|
}
|
|
}
|
|
|
|
$this->command->info('Building Function Formula Configurations seeded successfully!');
|
|
$this->command->info('=== CONFIGURATION SUMMARY ===');
|
|
$this->command->info('Total configurations created: ' . count($configs));
|
|
|
|
// Summary per building function
|
|
$summary = [];
|
|
foreach ($configs as $config) {
|
|
$buildingFunctionId = $config['building_function_id'];
|
|
if (!isset($summary[$buildingFunctionId])) {
|
|
$summary[$buildingFunctionId] = 0;
|
|
}
|
|
$summary[$buildingFunctionId]++;
|
|
}
|
|
|
|
foreach ($buildingFunctionMapping as $code => $id) {
|
|
$count = $summary[$id] ?? 0;
|
|
$this->command->info("{$code}: {$count} configurations");
|
|
}
|
|
|
|
$this->command->info('=== KEY FEATURES ===');
|
|
$this->command->info('✓ Fungsi Keagamaan: Bebas retribusi semua lantai');
|
|
$this->command->info('✓ Setiap fungsi bangunan memiliki parameter berbeda');
|
|
$this->command->info('✓ Setiap lantai memiliki IP ketinggian berbeda');
|
|
$this->command->info('✓ Hunian sederhana: IP kompleksitas khusus 0.3');
|
|
$this->command->info('✓ Formula dapat disesuaikan per fungsi dan lantai');
|
|
}
|
|
}
|