done restructure calculation retribution
This commit is contained in:
@@ -16,7 +16,8 @@ class RetributionCalculatorService
|
||||
int $buildingTypeId,
|
||||
int $floorNumber,
|
||||
float $buildingArea,
|
||||
bool $saveResult = true
|
||||
bool $saveResult = true,
|
||||
bool $excelCompatibleMode = false
|
||||
): array {
|
||||
// Get building type with indices
|
||||
$buildingType = BuildingType::with('indices')->findOrFail($buildingTypeId);
|
||||
@@ -49,7 +50,8 @@ class RetributionCalculatorService
|
||||
$infrastructureMultiplier,
|
||||
$heightMultiplier,
|
||||
$floorNumber,
|
||||
$buildingArea
|
||||
$buildingArea,
|
||||
$excelCompatibleMode
|
||||
);
|
||||
|
||||
// Save result if requested
|
||||
@@ -78,7 +80,8 @@ class RetributionCalculatorService
|
||||
float $infrastructureMultiplier,
|
||||
float $heightMultiplier,
|
||||
int $floorNumber,
|
||||
float $buildingArea
|
||||
float $buildingArea,
|
||||
bool $excelCompatibleMode = false
|
||||
): array {
|
||||
// Step 1: Calculate H5 coefficient (Excel formula: RUNDOWN(($E5*($F5+$G5+(0.5*H$3))),4))
|
||||
// H5 = coefficient * (ip_permanent + ip_complexity + (height_multiplier * height_index))
|
||||
@@ -100,7 +103,15 @@ class RetributionCalculatorService
|
||||
$infrastructureCalculation = $infrastructureMultiplier * $mainCalculation;
|
||||
|
||||
// Step 4: Total retribution (Main + Infrastructure)
|
||||
$totalRetribution = $mainCalculation + $infrastructureCalculation;
|
||||
if ($excelCompatibleMode) {
|
||||
// Try to match Excel exactly - round intermediate calculations
|
||||
$mainCalculation = round($mainCalculation, 0);
|
||||
$infrastructureCalculation = round($infrastructureCalculation, 0);
|
||||
$totalRetribution = $mainCalculation + $infrastructureCalculation;
|
||||
} else {
|
||||
// Apply standard rounding to match Excel results more closely
|
||||
$totalRetribution = round($mainCalculation + $infrastructureCalculation, 0);
|
||||
}
|
||||
|
||||
return [
|
||||
'building_type' => [
|
||||
|
||||
Reference in New Issue
Block a user