From 00f077544b1b59560ebcbf6420d01da22d78d791 Mon Sep 17 00:00:00 2001 From: hafifierahman Date: Sun, 10 Nov 2024 22:32:28 +0800 Subject: [PATCH] edited route test to panjar --- app/Http/Controllers/DenominasiController.php | 17 ++++++++++++----- app/Services/Miscellaneous/PanjarServices.php | 4 +++- routes/web.php | 10 +++++----- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/app/Http/Controllers/DenominasiController.php b/app/Http/Controllers/DenominasiController.php index efdcd73..3dc632c 100644 --- a/app/Http/Controllers/DenominasiController.php +++ b/app/Http/Controllers/DenominasiController.php @@ -8,39 +8,46 @@ use App\Denominasi; use App\Services\CashFlow\TellerServices; use Illuminate\Http\Request; use App\Services\Miscellaneous\PanjarServices; - +use Log; use Carbon\Carbon; class DenominasiController extends Controller { - public function test($kodcaw,Request $request){ + public function cashdeposit($kodcaw,Request $request){ $teller = new TellerServices($kodcaw); $response = $teller->CashDeposit($request); return response()->json($response); } - public function test2($kodcaw,Request $request){ + public function cashwithdraw($kodcaw,Request $request){ $teller = new TellerServices($kodcaw); $response = $teller->CashWithdrawals($request); return response()->json($response); } - public function test3($kodcaw,Request $request){ + public function createpanjar($kodcaw,Request $request){ $teller = new PanjarServices($kodcaw); $response = $teller->create($request); return response()->json($response); } - public function test4($kodcaw,Request $request){ + public function deletepanjar($kodcaw,Request $request){ $teller = new PanjarServices($kodcaw); $response = $teller->delete($request); return response()->json($response); } + public function getPerubatanAmount($kodcaw,Request $request){ + $teller = new PanjarServices($kodcaw); + $response = $teller->getPerubatanAmount($request->tuntutoleh); + + return response()->json($response); + } + public function listdenominasi($kodcaw) { $current = Carbon::now(); diff --git a/app/Services/Miscellaneous/PanjarServices.php b/app/Services/Miscellaneous/PanjarServices.php index bd79ecd..498bafc 100644 --- a/app/Services/Miscellaneous/PanjarServices.php +++ b/app/Services/Miscellaneous/PanjarServices.php @@ -368,8 +368,10 @@ class PanjarServices } public function getPerubatanAmount($tuntutanoleh){ + $current = Carbon::now(); + $cawangan = Cawangan::on('mysql7')->where('kodcaw', $this->cawangan)->first(); - $panjar = Panjar::on($cawangan['mysql'])->where('kategori','Belanja AM - Perubatan')->where('tuntutoleh',$tuntutanoleh)->sum('bayaran'); + $panjar = Panjar::on($cawangan['mysql'])->whereYear('tarikh',$current->year)->where('kategori','Belanja AM - Perubatan')->where('tuntutoleh',$tuntutanoleh)->sum('bayaran'); return $panjar; } diff --git a/routes/web.php b/routes/web.php index 99355fe..08e33c3 100644 --- a/routes/web.php +++ b/routes/web.php @@ -648,11 +648,11 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->get('/cawangan/getcawnotisall/{kodcaw}',['uses'=>'CawanganCallCenterController@getcawnotisall']); $router->get('/cawangan/bycawnotisperingatan/{kodcaw}/{notisid}',['uses'=>'CawanganCallCenterController@bycawnotisperingatan']); - $router->post('test/updatetunai/{kodcaw}',['uses'=>'DenominasiController@test']); - $router->post('test/serahantunai/{kodcaw}',['uses'=>'DenominasiController@test2']); - $router->post('test/createpanjar/{kodcaw}',['uses'=>'DenominasiController@test3']); - $router->post('test/deletepanjar/{kodcaw}',['uses'=>'DenominasiController@test4']); - + $router->post('panjar/updatetunai/{kodcaw}',['uses'=>'DenominasiController@cashdeposit']); + $router->post('panjar/serahantunai/{kodcaw}',['uses'=>'DenominasiController@cashwithdraw']); + $router->post('panjar/createpanjar/{kodcaw}',['uses'=>'DenominasiController@createpanjar']); + $router->post('panjar/deletepanjar/{kodcaw}',['uses'=>'DenominasiController@deletepanjar']); + $router->get('panjar/getperubatan/{kodcaw}',['uses'=>'DenominasiController@getPerubatanAmount']); });