Browse Source

implement 2 digits decimal on price related fields

pull/3/head
Muhammad Sulaiman Yusuf 2 years ago
parent
commit
a65ea51209
  1. 14
      app/Http/Controllers/ActivityController.php
  2. 11
      app/Http/Controllers/AssignMaterialController.php
  3. 43
      app/Http/Controllers/ReportActivityMaterialController.php
  4. 3
      app/Http/Controllers/RequestMaterialController.php
  5. 3
      app/Models/AssignMaterial.php
  6. 3
      app/Models/RequestMaterial.php

14
app/Http/Controllers/ActivityController.php

@ -325,8 +325,8 @@ class ActivityController extends Controller
}
$data = Activity::find($id);
$oldRencanaBiaya = (int)$data->rencana_biaya;
$newRencanaBiaya = (int)$request->rencana_biaya;
$oldRencanaBiaya = $data->rencana_biaya;
$newRencanaBiaya = str_replace(",",".",$request->rencana_biaya);
if($oldRencanaBiaya==$newRencanaBiaya){
$updateBobot = false;
}else{
@ -341,7 +341,6 @@ class ActivityController extends Controller
$dataUpdate['type_activity'] = $request->type;
}
if($data){
$upactual = false;
$result = $data->update($dataUpdate);
if($result){
if($parent && (int)$parent > 0){
@ -448,6 +447,7 @@ class ActivityController extends Controller
$data = Activity::find($id);
if($data){
$data->progress = (int)$data->persentase_progress/100;
$data->rencana_biaya = str_replace(".", ",", $data->rencana_biaya);
$data->jobs_done = $this->sumVolumeActualMaterial($data->id);
$data->assign_hr = $this->getUserActivity($data->id);
$data->assign_tools = $this->getToolsActivity($data->id);
@ -475,14 +475,6 @@ class ActivityController extends Controller
}
}
private function calculateProgress($id)
{
$sumBobot = Activity::where("parent_id", $id)->sum("bobot_planning");
$dataActivity = Activity::find($id);
$restBobot = $dataActivity->bobot_planning - $sumBobot;
return $restBobot;
}
private function updatePersentaseProgress($id)
{
$sumProgress = Activity::where("parent_id", $id)->sum("persentase_progress");

11
app/Http/Controllers/AssignMaterialController.php

@ -99,7 +99,16 @@ class AssignMaterialController extends Controller
public function datatables(Request $request){
$id_activity = $request->query('idact');
$data = AssignMaterial::select("assign_material_to_activity.*","m.description as material_name", "m.uom as uom")->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")->where('assign_material_to_activity.activity_id', $id_activity)->get();
$data = AssignMaterial::select(
"assign_material_to_activity.*","m.description as material_name", "m.uom as uom"
)
->join("m_req_material as m", "m.id", "=", "assign_material_to_activity.material_id")
->where('assign_material_to_activity.activity_id', $id_activity)
->orderBy('plan_date', 'desc')
->get();
foreach($data as $d){
$d->budget = str_replace(".", ",", $d->budget);
}
return Datatables::of($data)
->addIndexColumn()
->addColumn('action', function($row){

43
app/Http/Controllers/ReportActivityMaterialController.php

@ -17,31 +17,15 @@ class ReportActivityMaterialController extends Controller
'qty' => 'required'
]);
$valAssignMaterialId = AssignMaterial::where('activity_id', $request->activity_id)->first();
$data = $request->all();
$data['created_by'] = $this->currentName;
$data['assign_material_id'] = $valAssignMaterialId->id;
$checkPrice = AssignMaterial::where("id", $valAssignMaterialId->id)->first();
$price = $checkPrice->budget;
$updateActivity = Activity::find($request->activity_id);
if($updateActivity){
$costActualOld = $updateActivity->biaya_actual == null ? 0 : (int)$updateActivity->biaya_actual;
$costActualNew = $costActualOld + ($price*$request->qty);
$updateActivity->biaya_actual = $costActualNew;
$updateActivity->save();
$result = ReportActivityMaterial::create($data);
if($result){
$data['assign_material_id'] = AssignMaterial::where('activity_id', $request->activity_id)->pluck('id')->first();
if(!ReportActivityMaterial::create($data))
return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400]);
$this->countForProgress($request->activity_id);
return response()->json(['status'=>'success','message'=>'Input progress report activity created','code'=>200]);
}else{
return response()->json(['status'=>'failed','message'=>'Input progress report activity failed created','code'=>400]);
}
}else{
return response()->json(['status'=>'success','message'=>'Update cost actual failed','code'=>400]);
}
}
public function updateStatusStartFinish(Request $request){
@ -71,21 +55,10 @@ class ReportActivityMaterialController extends Controller
public function delete($id)
{
$data = ReportActivityMaterial::find($id);
if($data){
$delete = $data->delete();
}else{
return response()->json(['status'=>'failed','message'=>'data menu not found!','code'=>400], 400);
die();
}
if(!ReportActivityMaterial::findOrFail($id)->delete())
return response()->json(['status'=>'failed','message'=>'Failed to deleted the data!','code'=> 500], 500);
if($delete){
return response()->json(['status'=>'success','message'=>'data menu successfully deleted!','code'=>200], 200);
}else{
return response()->json(['status'=>'failed','message'=>'data menu failed deleted!','code'=>400], 400);
}
return response()->json(['status'=>'success','message'=> 'Data deleted!','code'=>200], 200);
}
private function countForProgress($id)

3
app/Http/Controllers/RequestMaterialController.php

@ -19,7 +19,8 @@ class RequestMaterialController extends Controller
]);
$data = $request->all();
$data['price'] = str_replace(",", ".", $data['price']);
$data['qty'] = str_replace(",", ".", $data['qty']);
$data['status'] = "fom";
$data['created_by'] = $this->currentName;

3
app/Models/AssignMaterial.php

@ -20,8 +20,7 @@ class AssignMaterial extends Model
protected $casts = [
'id' => 'integer',
'budget' => 'float',
'qty_planning' => 'float',
'budget' => 'string',
];
public static function boot() {

3
app/Models/RequestMaterial.php

@ -13,8 +13,7 @@ class RequestMaterial extends Model
protected $casts = [
'id' => 'integer',
'price' => 'float',
'qty' => 'float',
'price' => 'string',
];
protected $fillable = [

Loading…
Cancel
Save