diff --git a/app/Http/Controllers/TunaiController.php b/app/Http/Controllers/TunaiController.php index 1e36f79..63902af 100644 --- a/app/Http/Controllers/TunaiController.php +++ b/app/Http/Controllers/TunaiController.php @@ -339,6 +339,15 @@ class TunaiController extends Controller return response()->json($requestteller); } + public function getRequestTellerByRecno($kodcaw,Request $request){ + $current = Carbon::now(); + $current = new Carbon(); + + $requestteller=RequestTeller::on('mysql7')->where([['kodcaw','=',$kodcaw],['update','=',1],['recno','=',$request->recno],['kodlaluan','=',$request->teller]])->get(); + + return response()->json($requestteller); + } + public function getRequestTellerLaporanSerahanBerkala($kodcaw,Request $request) { diff --git a/app/Services/CashFlow/TellerServices.php b/app/Services/CashFlow/TellerServices.php index 4535066..1219d07 100644 --- a/app/Services/CashFlow/TellerServices.php +++ b/app/Services/CashFlow/TellerServices.php @@ -177,7 +177,7 @@ class TellerServices throw new Exception('Unsuccessful Tunai'); } - AddTunai::on($cawangan['mysql'])->create([ + $addtunai = AddTunai::on($cawangan['mysql'])->create([ 'tarikh' => $current->toDateString(), 'kodcaw'=> $this->cawangan, 'kodlaluan'=>$request->teller, @@ -286,6 +286,7 @@ class TellerServices 'txtsen10' => ($request->ambilansen10) ? $request->ambilansen10 : 0, 'txtsen20' => ($request->ambilansen20) ? $request->ambilansen20 : 0, 'txtsen50' => ($request->ambilansen50) ? $request->ambilansen50 : 0, + 'recno' => $addtunai['id'] ) ); // Commit transactions @@ -324,7 +325,7 @@ class TellerServices throw new Exception('Unsuccessful Tunai'); } - AddTunai::on($cawangan['mysql'])->create([ + $addtunai = AddTunai::on($cawangan['mysql'])->create([ 'tarikh' => $current->toDateString(), 'kodcaw'=> $this->cawangan, 'kodlaluan'=>$request->teller, @@ -414,6 +415,7 @@ class TellerServices /* RequestTeller Transaction */ $requestteller = RequestTeller::on('mysql7')->where([['no','=',$request->no],['kodcaw','=',$this->cawangan],['kodlaluan','=',$request->teller],['update','=',0]])->update(array( 'update' => 1, + 'recno' => $addtunai['id'] ) ); // Commit transactions diff --git a/app/Services/Miscellaneous/PanjarServices.php b/app/Services/Miscellaneous/PanjarServices.php index deafb20..bd79ecd 100644 --- a/app/Services/Miscellaneous/PanjarServices.php +++ b/app/Services/Miscellaneous/PanjarServices.php @@ -122,14 +122,13 @@ class PanjarServices $panjar = Panjar::on($cawangan['mysql'])->latest('tarikh')->where('nobaucer', $request->nobaucer)->first(); $vault = Vault::on($cawangan['mysql'])->latest('tarikh')->first(); $deno_panjar = DenoPanjar::on('mysql7')->where('kodcaw', $this->cawangan)->where('recno', $request->recno)->latest('tarikh','masa')->first(); - $totalperubatan = floatval($this->getPerubatanAmount($panjar['tuntutoleh'])) + $panjar['bayaran']; try{ if (!$panjar) throw new \Exception('Custom Exception: Panjar Does Not Exist!'); if (!$denominasi) throw new \Exception('Custom Exception: Denominasi Does Not Exist!'); if (!$vault) throw new \Exception('Custom Exception: Vault Does Not Exist!'); if (!$deno_panjar) throw new \Exception('Custom Exception: Denominasi Panjar Does Not Exist!'); - return DB::transaction(function () use ($cawangan,$deno_panjar,$panjar,$denominasi,$current,$vault,$totalperubatan) { + return DB::transaction(function () use ($cawangan,$deno_panjar,$panjar,$denominasi,$current,$vault) { $return_data = $this->calculation_denominasi($deno_panjar,$denominasi,'masuk'); if($return_data == 'no data') throw new \Exception('Custom Exception: Denominasi Panjar Not Return Data'); @@ -200,10 +199,12 @@ class PanjarServices DenoPanjar::on('mysql7')->where('kodcaw', $this->cawangan)->where('recno', $panjar['recno'])->latest('tarikh','masa')->delete(); Panjar::on($cawangan['mysql'])->where('recno',$panjar['recno'])->delete(); + $totalperubatan = floatval($this->getPerubatanAmount($panjar['tuntutoleh'])); + return $array_response = [ 'result' => 'success', 'data' => 1, - 'bakiperubatan' => $totalperubatan, + 'totalperubatan' => $totalperubatan, 'tuntutoleh' => $panjar['tuntutoleh'], 'jenis' => ($panjar['kategori'] == 'Belanja AM - Perubatan') ? 'perubatan' : 'none' ]; @@ -235,8 +236,6 @@ class PanjarServices $myDateTime = DateTime::createFromFormat('Y-m-d', $request->tarikhbil); $tarikhbil = $myDateTime->format('dmY'); $tagmodal = $this->checkModal($request->jenismodal); - $bakiperubatan = $this->getPerubatanAmount($request->tuntutan); - $currentbaki = floatval($bakiperubatan) - floatval($request->bayaran); $panjar = Panjar::on($cawangan['mysql']) ->create([ 'tarikh'=> $current->toDateString(), @@ -245,7 +244,7 @@ class PanjarServices 'tag' => $tagmodal['tag'], 'kategori' => $tagmodal['kategori'], 'id' => $request->kodlaluan, - 'bakiperubatan' => $currentbaki, + 'bakiperubatan' => 0, 'nobaucer' => $request->baucer, 'nobil' => $tarikhbil, 'tuntutoleh' => $request->tuntutan @@ -346,11 +345,12 @@ class PanjarServices $audit->updated_at = $current; $audit->save(); + $totalperubatan = $this->getPerubatanAmount($request->tuntutan); $array_response = [ 'result' => 'success', 'data' => 1, - 'bakiperubatan' => $currentbaki, + 'totalperubatan' => $totalperubatan, ]; return $array_response; diff --git a/database/migrations/2024_11_11_101144_add_recno_to_requestteller_table.php b/database/migrations/2024_11_11_101144_add_recno_to_requestteller_table.php new file mode 100644 index 0000000..9861ce9 --- /dev/null +++ b/database/migrations/2024_11_11_101144_add_recno_to_requestteller_table.php @@ -0,0 +1,28 @@ +hasColumn('requestteller', $column); + }); + + Schema::connection('mysql7')->table('requestteller', function (Blueprint $table) use ($columns_not_exist) { + array_walk($columns_not_exist, function ($column) use ($table) { + $table->integer($column); + }); + }); + } +} diff --git a/routes/web.php b/routes/web.php index 0998243..99355fe 100644 --- a/routes/web.php +++ b/routes/web.php @@ -380,6 +380,7 @@ $router->group(['prefix'=>'api'], function () use ($router){ $router->post('requestTeller/{kodcaw}',['uses' => 'TunaiController@createRequestTeller']); $router->get('requestTeller/get/{kodcaw}',['uses' => 'TunaiController@getRequestTeller']); $router->get('requestTeller/getlaporan/{kodcaw}',['uses' => 'TunaiController@getRequestTellerLaporanSerahan']); + $router->get('requestTeller/getrekod/{kodcaw}',['uses' => 'TunaiController@getRequestTellerByRecno']); $router->get('requestTeller/getlaporanberkala/{kodcaw}',['uses' => 'TunaiController@getRequestTellerLaporanSerahanBerkala']); $router->get('requestTeller/get/{kodcaw}/date',['uses' => 'TunaiController@getRequestTellerByDate']); $router->put('requestTeller/update/{kodcaw}',['uses' => 'TunaiController@updateRequestTeller']);