Browse Source

division by zero catch

pull/3/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
d7cda42844
  1. 25
      app/Http/Controllers/ProjectController.php

25
app/Http/Controllers/ProjectController.php

@ -282,7 +282,7 @@ class ProjectController extends Controller
->join('m_proyek_phase', 'm_proyek_phase.id', '=', 'm_proyek.phase_id')
->groupBy('m_proyek_phase.name', 'm_proyek_phase.color')
->get();
} catch (\Exception $e) {
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
try {
@ -291,7 +291,7 @@ class ProjectController extends Controller
->join('m_type_proyek', 'm_type_proyek.id', '=', 'm_proyek.type_proyek_id')
->groupBy('m_type_proyek.name')
->get();
} catch (\Exception $e) {
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
@ -452,10 +452,14 @@ class ProjectController extends Controller
$dataTempPlan [$x]['biaya_actual'] = $keyPlanM->biaya_actual;
$dataTempPlan [$x]['duration'] = $keyPlanM->duration;
$dataTempPlan [$x]['persentase_progress'] = $keyPlanM->persentase_progress;
$dataTempPlan [$x]['percentage'] = ($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning;
$sumPercentagePlan+=($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning;
$totalBCWP += (((($keyPlanM->persentase_progress*$keyPlanM->bobot_planning)/100)/$keyPlanM->duration)* $totalRencanaBudget)/100;
$dataTempPlan [$x]['totalBCWP'] = $totalBCWP;
try {
$dataTempPlan [$x]['percentage'] = ($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning;
$sumPercentagePlan+=($keyPlanM->qty_planning/$sumVolPlan->ttl_qty_plan)*$keyPlanM->bobot_planning;
$totalBCWP += (((($keyPlanM->persentase_progress*$keyPlanM->bobot_planning)/100)/$keyPlanM->duration)* $totalRencanaBudget)/100;
$dataTempPlan [$x]['totalBCWP'] = $totalBCWP;
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
$x++;
}
@ -476,11 +480,11 @@ class ProjectController extends Controller
$dataTempReport [$w]['biaya_actual'] = $keyActualM->biaya_actual;
$dataTempReport [$w]['duration'] = $keyActualM->duration;
$dataTempReport [$w]['persentase_progress'] = $keyActualM->persentase_progress;
$dataTempReport [$w]['percentage'] = ($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
$sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
try {
$dataTempReport [$w]['percentage'] = ($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
$sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning;
$totalACWP += $keyActualM->biaya_actual/$keyActualM->duration;
} catch (\Exception $e) {
} catch (\DivisionByZeroError $e) {
return response()->json(['message' => $e->getMessage()]);
}
$dataTempReport [$w]['totalacwp'] = $totalACWP;
@ -520,7 +524,7 @@ class ProjectController extends Controller
}else{
$estimatedCost = ($totalRencanaBudget+0);
}
} catch (\Exception $e) {
} catch (\DivisionByZeroError $e) {
return response()->json([
'message' => $e->getMessage(),
"line" => 566,
@ -791,5 +795,6 @@ class ProjectController extends Controller
return response()->json(['status'=>'success', 'data'=> $response, 'code'=>200], 200);
}
}

Loading…
Cancel
Save