From 7bf4b74ee397d3ee44491e7b7cb4a486b043277d Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Fri, 18 Aug 2023 11:38:21 +0700 Subject: [PATCH 1/4] fix calculate scurve --- app/Helpers/MasterFunctionsHelper.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index 07e2c74..681e39b 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -604,6 +604,12 @@ class MasterFunctionsHelper ->where('activity_id', '=', $keyActualM->activity_id) ->groupBy('activity_id') ->first(); + if (!isset($sumVolActual)) { + $sumVolActual = (object) [ + 'activity_id' => $keyActualM->activity_id, + 'ttl_qty_plan' => "0" + ]; + } $sumReportActual = DB::table('report_activity_material') ->where('activity_id', $keyActualM->activity_id) ->sum('qty'); @@ -623,18 +629,29 @@ class MasterFunctionsHelper ->where('activity_id', '=', $keyActualM->activity_id) ->orderBy('status_activity', 'ASC') ->first(); - $dataTempReport[$w]['percentage'] = ($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning; + if (!isset($checkStatusActivity)) { + $checkStatusActivity = (object) [ + 'activity_id' => $keyActualM->activity_id, + 'status_activity' => 'open' + ]; + } + if ($sumVolActual->ttl_qty_plan == "0") { + $actual = 0; + } else { + $actual = $keyActualM->qty / $sumVolActual->ttl_qty_plan; + } + $dataTempReport[$w]['percentage'] = $actual * $keyActualM->bobot_planning; // $sumPercentageActual+=($keyActualM->qty/$sumVolActual->ttl_qty_plan)*$keyActualM->bobot_planning; // if($keyActualM->qty/$sumVolActual->ttl_qty_plan >= 1){ if ($checkStatusActivity->status_activity == 'done') { $sumPercentageActual += $keyActualM->bobot_planning / $reportCount; // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; } else { - if ($keyActualM->qty / $sumVolActual->ttl_qty_plan >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) { - $sumPercentageActual += (($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning) * (95 / 100); + if ( $actual >= 1 || (int) $sumVolActual->ttl_qty_plan == (int) $sumReportActual) { + $sumPercentageActual += ($actual * $keyActualM->bobot_planning) * (95 / 100); // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; } else { - $sumPercentageActual += ($keyActualM->qty / $sumVolActual->ttl_qty_plan) * $keyActualM->bobot_planning; + $sumPercentageActual += $actual * $keyActualM->bobot_planning; // $sumPercentageActual = $sumPercentageActual > $keyGantt['progress'] ? $keyGantt['progress'] : $sumPercentageActual; } } From 7f9fe052e53ddcd849c9e99f907296407b3b1591 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Fri, 18 Aug 2023 16:10:39 +0700 Subject: [PATCH 2/4] Adding more range for scurve --- app/Helpers/MasterFunctionsHelper.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index 681e39b..eb70448 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -200,7 +200,8 @@ class MasterFunctionsHelper ->where('a.version_gantt_id', '=', $keyGantt['id']) ->max("a.planned_end"); // plan date overlapped with assign_material_to_activity's, it should be m_activity' $maxDate = max(new \DateTime($plannedMaxDate), new \DateTime($actualMaxDate)); - $end = $maxDate; + $end = new \DateTime($maxDate->format('Y-m-d') . ' Friday'); + $end->modify('next Friday'); $interval = new \DateInterval('P7D'); } $period = new \DatePeriod($begin, $interval, $end); From 65833f14556412ea6b8a8966fe8896ddd27490d9 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Fri, 18 Aug 2023 17:12:37 +0700 Subject: [PATCH 3/4] delete report when delete overhead --- app/Models/AssignMaterial.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Models/AssignMaterial.php b/app/Models/AssignMaterial.php index 5cb8bc5..0c282a6 100644 --- a/app/Models/AssignMaterial.php +++ b/app/Models/AssignMaterial.php @@ -5,6 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; use App\Models\RequestMaterial; use App\Models\Activity; +use App\Models\ReportActivityMaterial; class AssignMaterial extends Model { @@ -35,6 +36,7 @@ class AssignMaterial extends Model }); static::deleted(function($data) { + $reportActivities = ReportActivityMaterial::where('assign_material_id', $data->id)->delete(); $activity = Activity::where('id', $data->activity_id)->first(); $activity->rencana_biaya -= floatval($data->budget) * floatval($data->qty_planning); $activity->save(); From 584e7ef8594760fa9c4991f1ab78510e4b6c3251 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Mon, 21 Aug 2023 10:41:56 +0700 Subject: [PATCH 4/4] Add column --- app/Models/UserToProyek.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Models/UserToProyek.php b/app/Models/UserToProyek.php index eb80c9b..bffc876 100644 --- a/app/Models/UserToProyek.php +++ b/app/Models/UserToProyek.php @@ -14,6 +14,6 @@ class UserToProyek extends Model protected $fillable = [ 'user_id', 'proyek_id', 'rbs', 'project_role', 'group_r', 'max_used', 'standart_rate', 'uom_standart_rate', 'overtime_rate', 'uom_overtime_rate', 'cost_per_used', 'accrue_at', - 'base_calender', 'created_at', 'created_by', 'updated_at', 'updated_by' + 'base_calender', 'is_customer', 'created_at', 'created_by', 'updated_at', 'updated_by' ]; }