Browse Source

Handling if cost planning < 0

pull/3/head
Wahyu Ramadhan 2 years ago
parent
commit
9503d9e6c6
  1. 7
      app/Models/Activity.php
  2. 3
      app/Models/UserToActivity.php

7
app/Models/Activity.php

@ -127,6 +127,13 @@ class Activity extends Model
if($parent = Activity::find($this->parent_id)){
$parentActWeight = $parent->bobot_planning;
if ($parentActWeight == 0) {
$parent->update([
"persentase_progress" => 0
]);
return;
}
$totalChildProportionalProgress = 0;
$childs = Activity::where("parent_id", $parent->id)->get();
foreach($childs as $child){

3
app/Models/UserToActivity.php

@ -50,6 +50,9 @@ class UserToActivity extends Model
}
$activity->rencana_biaya -= $salary;
if ($activity->rencana_biaya < 0) {
$activity->rencana_biaya = 0;
}
$activity->save();
});

Loading…
Cancel
Save