Browse Source

fix volume actual calc

pull/3/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
71e0432f66
  1. 14
      app/Models/Activity.php

14
app/Models/Activity.php

@ -130,20 +130,14 @@ class Activity extends Model
public function getJobsDoneAttribute()
{
$tmpPercentage = [];
if(!ReportActivityMaterial::where('activity_id', $this->id)->first())
return 0;
if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get())
return 0;
foreach ($dataPlan as $value) {
$tmpPercentage[] = 100;
$getDataVolActual = ReportActivityMaterial::where('assign_material_id', '=', $value->id)->sum("qty");
$percentage = ($getDataVolActual * 100) / $value->qty_planning;
if($value->status_activity != 'done'){
$tmpPercentage[] = $percentage >= 100 ? 90 : $percentage;
}
}
return array_sum($tmpPercentage) > 0 ? array_sum($tmpPercentage) / count($tmpPercentage) : 0;
$totalPlan = $dataPlan->sum('qty_planning');
$totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $this->id)->sum("qty");
$percentage = ($totalVolumeActual * 100) / $totalPlan;
return $percentage > 95 ? 95 : $percentage;
}
public function getAssignHrAttribute()

Loading…
Cancel
Save