Browse Source

recalculate planned cost after deleting assigned material

pull/3/head
Muhammad Sulaiman Yusuf 3 years ago
parent
commit
12415c6e77
  1. 4
      app/Http/Controllers/AssignMaterialController.php

4
app/Http/Controllers/AssignMaterialController.php

@ -166,13 +166,15 @@ class AssignMaterialController extends Controller
); );
$materialResource->update($dataUpdate); $materialResource->update($dataUpdate);
} }
$activity = Activity::where('id', $data->activity_id)->first();
$activity->rencana_biaya -= $data->budget * $data->qty_planning;
$activity->save();
$delete = $data->delete(); $delete = $data->delete();
}else{ }else{
return response()->json(['status'=>'failed','message'=>'Data Assign material not found!','code'=>400], 400); return response()->json(['status'=>'failed','message'=>'Data Assign material not found!','code'=>400], 400);
die(); die();
} }
if($delete){ if($delete){
return response()->json(['status'=>'success','message'=>'Assign material successfully deleted!','code'=>200], 200); return response()->json(['status'=>'success','message'=>'Assign material successfully deleted!','code'=>200], 200);
}else{ }else{

Loading…
Cancel
Save