fix calculated and truncate calculation spatial plannings
This commit is contained in:
@@ -26,7 +26,7 @@ class AssignSpatialPlanningsToCalculation extends Command
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Assign retribution calculations to spatial plannings (recalculate mode applies 30% area adjustment)';
|
||||
protected $description = 'Assign retribution calculations to spatial plannings (recalculate mode recalculates with current values)';
|
||||
|
||||
protected $calculatorService;
|
||||
|
||||
@@ -57,7 +57,7 @@ class AssignSpatialPlanningsToCalculation extends Command
|
||||
$q->where('is_active', true);
|
||||
});
|
||||
$this->info('🔄 Recalculate mode: Processing spatial plannings with existing calculations');
|
||||
$this->warn('⚠️ NOTE: Recalculate mode will apply 30% area adjustment to all calculations');
|
||||
$this->warn('⚠️ NOTE: Recalculate mode will recalculate all existing calculations with current values');
|
||||
} elseif (!$force) {
|
||||
// Normal mode: only process those without active calculations
|
||||
$query->whereDoesntHave('retributionCalculations', function ($q) {
|
||||
@@ -141,7 +141,7 @@ class AssignSpatialPlanningsToCalculation extends Command
|
||||
['Errors', $errors],
|
||||
]
|
||||
);
|
||||
$this->info('📊 Recalculate mode applied 30% area adjustment to all calculations');
|
||||
$this->info('📊 Recalculate mode recalculated all existing calculations with current values');
|
||||
} else {
|
||||
$this->table(
|
||||
['Metric', 'Count'],
|
||||
@@ -213,10 +213,9 @@ class AssignSpatialPlanningsToCalculation extends Command
|
||||
]);
|
||||
|
||||
// Assign new calculation
|
||||
$adjustedArea = round($buildingArea * 0.3, 2);
|
||||
$spatialPlanning->assignRetributionCalculation(
|
||||
$calculation,
|
||||
"Recalculated (30% area): Original area {$oldArea}m² → Adjusted area {$adjustedArea}m², Amount {$oldAmount}→{$newAmount}"
|
||||
"Recalculated: Original area {$oldArea}m² → New area {$buildingArea}m², Amount {$oldAmount}→{$newAmount}"
|
||||
);
|
||||
|
||||
$isRecalculated = true;
|
||||
@@ -237,7 +236,7 @@ class AssignSpatialPlanningsToCalculation extends Command
|
||||
|
||||
$spatialPlanning->assignRetributionCalculation(
|
||||
$calculation,
|
||||
'Recalculated (new calculation with 30% area adjustment)'
|
||||
'Recalculated (new calculation with current values)'
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -409,11 +408,9 @@ class AssignSpatialPlanningsToCalculation extends Command
|
||||
// Round area to 2 decimal places to match database storage format
|
||||
$buildingArea = round($spatialPlanning->getCalculationArea(), 2);
|
||||
|
||||
// Apply 30% multiplication for recalculate mode
|
||||
// For recalculate mode, use the current area without any adjustment
|
||||
if ($recalculate) {
|
||||
$originalArea = $buildingArea;
|
||||
$buildingArea = round($buildingArea * 0.3, 2); // 30% of original area
|
||||
$this->info("Recalculate mode: Original area {$originalArea}m² → Adjusted area {$buildingArea}m² (30%)");
|
||||
$this->info("Recalculate mode: Using current area {$buildingArea}m²");
|
||||
}
|
||||
|
||||
$floorNumber = $spatialPlanning->number_of_floors ?: 1;
|
||||
@@ -440,8 +437,6 @@ class AssignSpatialPlanningsToCalculation extends Command
|
||||
'height_index' => $result['input_parameters']['height_index'],
|
||||
'infrastructure_factor' => $result['indices']['infrastructure_factor'],
|
||||
'building_area' => $buildingArea,
|
||||
'original_building_area' => $recalculate ? round($spatialPlanning->getCalculationArea(), 2) : null,
|
||||
'area_adjustment_factor' => $recalculate ? 0.3 : null,
|
||||
'floor_number' => $floorNumber,
|
||||
'building_function' => $spatialPlanning->building_function,
|
||||
'calculation_steps' => $result['calculation_detail'],
|
||||
@@ -460,11 +455,9 @@ class AssignSpatialPlanningsToCalculation extends Command
|
||||
// Basic fallback calculation
|
||||
$totalAmount = $buildingType->is_free ? 0 : ($buildingArea * 50000);
|
||||
|
||||
// Apply 30% multiplication for recalculate mode in fallback too
|
||||
// For recalculate mode in fallback, use current amount without adjustment
|
||||
if ($recalculate) {
|
||||
$originalAmount = $totalAmount;
|
||||
$totalAmount = round($totalAmount * 0.3, 2);
|
||||
$this->warn("Fallback recalculate: Original amount Rp{$originalAmount} → Adjusted amount Rp{$totalAmount} (30%)");
|
||||
$this->warn("Fallback recalculate: Using current amount Rp{$totalAmount}");
|
||||
}
|
||||
|
||||
return [
|
||||
@@ -474,8 +467,6 @@ class AssignSpatialPlanningsToCalculation extends Command
|
||||
'building_type_name' => $buildingType->name,
|
||||
'building_type_code' => $buildingType->code,
|
||||
'building_area' => $buildingArea,
|
||||
'original_building_area' => $recalculate ? round($spatialPlanning->getCalculationArea(), 2) : null,
|
||||
'area_adjustment_factor' => $recalculate ? 0.3 : null,
|
||||
'floor_number' => $floorNumber,
|
||||
'building_function' => $spatialPlanning->building_function,
|
||||
'calculation_method' => 'fallback',
|
||||
|
||||
Reference in New Issue
Block a user