Browse Source

handle zero division

pull/3/head
wahyu 1 year ago
parent
commit
e4b46f6d70
  1. 4
      app/Http/Controllers/ActivityController.php

4
app/Http/Controllers/ActivityController.php

@ -431,10 +431,10 @@ class ActivityController extends Controller
$duration = MasterFunctionsHelper::countDays($ganttId, $plannedStart, $plannedEnd); $duration = MasterFunctionsHelper::countDays($ganttId, $plannedStart, $plannedEnd);
if ($today >= $endDate) { if ($today >= $endDate) {
$endDate = $today; $endDate = $today;
$rerataBobot = $activity->bobot_planning / $duration; $rerataBobot = $duration > 0 ? $activity->bobot_planning / $duration : 0;
$bobotActual = $activity->progress * $activity->bobot_planning; $bobotActual = $activity->progress * $activity->bobot_planning;
$sisaBobot = $activity->bobot_planning - $bobotActual; $sisaBobot = $activity->bobot_planning - $bobotActual;
$sisaHari = $sisaBobot / $rerataBobot; $sisaHari = $rerataBobot > 0 ? $sisaBobot / $rerataBobot : 0;
$endDate->modify("+".$sisaHari." Days"); $endDate->modify("+".$sisaHari." Days");
$actualDuration = MasterFunctionsHelper::countDays($ganttId, $startDate, $endDate); $actualDuration = MasterFunctionsHelper::countDays($ganttId, $startDate, $endDate);
$activity->duration = $actualDuration; $activity->duration = $actualDuration;

Loading…
Cancel
Save