Merged in cherrypick/api_fix_button_terima_gadai (pull request #191)

Cherrypick/api fix button terima gadai
This commit is contained in:
nurulnisha muhammad
2024-07-08 14:07:56 +00:00
committed by Muhd hafifie
3 changed files with 37 additions and 13 deletions
+25 -13
View File
@@ -349,22 +349,34 @@ class GadaiController extends Controller
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$old_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
// $old_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->delete();
Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->delete();
// Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->delete();
// Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->delete();
$audit = new Audit();
$audit->users = $request->teller;
$audit->actions = $request->transaction;
$audit->norujukan = $norujukan;
$audit->old_data = $old_data;
$audit->kodcaw = $request->kodcaw;
$audit->created_at = $current;
$audit->updated_at = $current;
$audit->save();
// $old_data = Gadai::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->first();
$old_data = Gadai::on($cawangan['mysql'])->where([['norujukan','=',$norujukan],['pinjaman','=','NULL']])->orWhere([['norujukan','=',$norujukan],['pinjaman','=',0.00]])->first();
if($old_data){
Gadai::on($cawangan['mysql'])->where([['norujukan','=',$norujukan],['pinjaman','=','NULL']])->delete();
Marhun::on($cawangan['mysql'])->where('norujukan','=',$norujukan)->delete();
return response('Batal Berjaya', 200);
$audit = new Audit();
$audit->users = $request->teller;
$audit->actions = $request->transaction;
$audit->norujukan = $norujukan;
$audit->old_data = $old_data;
$audit->kodcaw = $request->kodcaw;
$audit->created_at = $current;
$audit->updated_at = $current;
$audit->save();
//return response('Batal Berjaya', 200);
return response('Batal Berjaya', 200);
} else {
return response()->json('false');
}
}
public function pembelianKomuditi($kodcaw,$norujukan){
+10
View File
@@ -246,4 +246,14 @@ class MarhunController extends Controller
return response()->json($totalnilaimarhun);
}
public function getMarhunCaw($kodcaw,$norujukan)
{
$cawangan = Cawangan::on('mysql7')->where('kodcaw','=',$kodcaw)->first();
$data = Marhun::on($cawangan['mysql'])
->where('norujukan','=', $norujukan)
->sum('marhun.n_marhun');
return response()->json($data,200);
}
}
+2
View File
@@ -178,6 +178,8 @@ $router->group(['prefix'=>'api'], function () use ($router){
$router->get('marhunterkumpul/laporan/{kodcaw}/{tarikh}',['uses'=>'MarhunController@getLaporanMarhunTerkumpul']);
$router->get('marhun/mutu/sag',['uses'=>'MarhunController@getMutuMarhun']);
$router->get('marhun/nilai/terkini',['uses'=>'MarhunController@getNilaiMarhunLatest']);
//new added 230624
$router->get('marhun/gadai/{kodcaw}/{norujukan}',['uses'=>'MarhunController@getMarhunCaw']);
$router->get('jemas',['uses'=>'MarhunController@getAllJemas']);