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() public function getJobsDoneAttribute()
{ {
$tmpPercentage = [];
if(!ReportActivityMaterial::where('activity_id', $this->id)->first()) if(!ReportActivityMaterial::where('activity_id', $this->id)->first())
return 0; return 0;
if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get()) if(!$dataPlan = AssignMaterial::where('activity_id', $this->id)->get())
return 0; return 0;
foreach ($dataPlan as $value) { $totalPlan = $dataPlan->sum('qty_planning');
$tmpPercentage[] = 100; $totalVolumeActual = ReportActivityMaterial::where('activity_id', '=', $this->id)->sum("qty");
$getDataVolActual = ReportActivityMaterial::where('assign_material_id', '=', $value->id)->sum("qty"); $percentage = ($totalVolumeActual * 100) / $totalPlan;
$percentage = ($getDataVolActual * 100) / $value->qty_planning; return $percentage > 95 ? 95 : $percentage;
if($value->status_activity != 'done'){
$tmpPercentage[] = $percentage >= 100 ? 90 : $percentage;
}
}
return array_sum($tmpPercentage) > 0 ? array_sum($tmpPercentage) / count($tmpPercentage) : 0;
} }
public function getAssignHrAttribute() public function getAssignHrAttribute()

Loading…
Cancel
Save