From cb273e1256199c492ae8a76fd782b43f4cdcd0ac Mon Sep 17 00:00:00 2001 From: izuddin Date: Thu, 7 Aug 2025 10:30:44 +0700 Subject: [PATCH] Update Rekening Tamsil dan TPG --- app/Http/Controllers/ItemSearchController.php | 46 ++++-- .../RealisasiPendapatanController.php | 68 ++++++-- app/Models/PendapatanRealisasi.php | 4 + app/Models/PendapatanRealisasiSts.php | 15 ++ ..._create_pendapatan_realisasi_sts_table.php | 40 +++++ .../views/realisasi_pendapatan/show.blade.php | 151 ++++++++++++------ routes/web.php | 1 + 7 files changed, 255 insertions(+), 70 deletions(-) create mode 100644 app/Models/PendapatanRealisasiSts.php create mode 100644 database/migrations/2025_08_05_093130_create_pendapatan_realisasi_sts_table.php diff --git a/app/Http/Controllers/ItemSearchController.php b/app/Http/Controllers/ItemSearchController.php index 93f614f..7f8435d 100644 --- a/app/Http/Controllers/ItemSearchController.php +++ b/app/Http/Controllers/ItemSearchController.php @@ -21,6 +21,8 @@ use App\Models\VwRekeningPendapatan; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Http; +use App\Models\PendapatanRealisasiSts; class ItemSearchController extends Controller { @@ -183,16 +185,40 @@ class ItemSearchController extends Controller { $no_skprd = $request->no_skprd; $kode_akun = $request->kode_akun; - $select = DB::raw("NO_SKPRD,TGL_VALIDASI,KODE_BAS,NILAI_BAYAR,TRBAS.N_AKUN"); - $sts = Siesetpembayaran::select($select) - ->join("NEWSIPKD.TRBAS", "SI_ESET_PEMBAYARAN.KODE_BAS", "=", "TRBAS.C_AKUN") - ->where("NO_SKPRD", $no_skprd) - ->where("SI_ESET_PEMBAYARAN.KODE_BAS", $kode_akun) - ->whereRaw("C_TAHUN_BERLAKU<=" . getTA() . " AND C_TAHUN_BERAKHIR>=" . getTA()) - ->first(); - if ($sts) { - $sts["tgl_validasi"] = date("Y-m-d", strtotime($sts["tgl_validasi"])); - $sts["nilai_bayar"] = separateNumberIndo($sts["nilai_bayar"]); + + $arrTPG = ['4.2.01.01.04.0004','4.2.01.01.04.0005','4.2.01.09.02.0004','4.2.01.09.02.0005']; + if (in_array($kode_akun,$arrTPG)){ + $sts = array(); + $cek = PendapatanRealisasiSts::where("rkud_no_sts",$no_skprd)->count(); + if ($cek==0){ + $urlAPI = "http://10.15.34.90:8820/api/tpg-tamsil/cek-sp2t"; + $httpSTS = Http::withHeaders([ + 'Accept' => 'application/json', + ])->withBasicAuth('sidata_tpgtamsil_dev', 'sidataAp!TpgT4ms1lD3v') + ->post($urlAPI, [ + "no_sp2t"=>$no_skprd, + "kode_rekening"=>$kode_akun + ]); + if(isset($httpSTS["data"])){ + $sts["no_skprd"] = $httpSTS["data"]["no_sp2t"]; + $sts["tgl_validasi"] = date("Y-m-d", strtotime($httpSTS["data"]["tanggal_pengesahan"])); + $sts["kode_bas"] = $httpSTS["data"]["kode_rekening"]; + $sts["n_akun"] = $httpSTS["data"]["nam_rekening"]; + $sts["nilai_bayar"] = separateNumberIndo($httpSTS["data"]["jumlah"]); + } + } + }else{ + $select = DB::raw("NO_SKPRD,TGL_VALIDASI,KODE_BAS,NILAI_BAYAR,TRBAS.N_AKUN"); + $sts = Siesetpembayaran::select($select) + ->join("NEWSIPKD.TRBAS", "SI_ESET_PEMBAYARAN.KODE_BAS", "=", "TRBAS.C_AKUN") + ->where("NO_SKPRD", $no_skprd) + ->where("SI_ESET_PEMBAYARAN.KODE_BAS", $kode_akun) + ->whereRaw("C_TAHUN_BERLAKU<=" . getTA() . " AND C_TAHUN_BERAKHIR>=" . getTA()) + ->first(); + if ($sts) { + $sts["tgl_validasi"] = date("Y-m-d", strtotime($sts["tgl_validasi"])); + $sts["nilai_bayar"] = separateNumberIndo($sts["nilai_bayar"]); + } } return response()->json($sts); } diff --git a/app/Http/Controllers/RealisasiPendapatanController.php b/app/Http/Controllers/RealisasiPendapatanController.php index afe8200..439ca6f 100644 --- a/app/Http/Controllers/RealisasiPendapatanController.php +++ b/app/Http/Controllers/RealisasiPendapatanController.php @@ -8,6 +8,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Auth; use Maatwebsite\Excel\Facades\Excel; use App\Models\PendapatanRealisasi; +use App\Models\PendapatanRealisasiSts; use App\Models\Sps_pendapatan; use App\Models\VwJadwalSalur; use App\Models\User; @@ -187,6 +188,7 @@ class RealisasiPendapatanController extends Controller // } $this->readNotif($realisasi_pendapatan->id); $this->setSubtitle("Detail Data"); + // var_dump($realisasi_pendapatan->hasSts); exit; return view('realisasi_pendapatan.show',compact("realisasi_pendapatan")); } @@ -204,37 +206,51 @@ class RealisasiPendapatanController extends Controller try{ $date = date("Ymd"); DB::beginTransaction(); - - $data = PendapatanRealisasi::firstOrNew(array('id' => $realisasiId)); - - if ($data["simtrad4_bersih"]<>replaceMoney($req["rkud_jumlah"])){ - return redirect(URL::to("/realisasi-pendapatan/".$realisasiId))->with('error', "Jumlah STS harus sama dengan Rencana !"); + $dataRealisasi = PendapatanRealisasi::where(['id' => $realisasiId])->first(); + $arrTPG = ['4.2.01.01.04.0004','4.2.01.01.04.0005','4.2.01.09.02.0004','4.2.01.09.02.0005']; + $sisa = 0; + if (in_array($req["rkud_kode_akun"],$arrTPG)){ + $totalSts = PendapatanRealisasiSts::where(["id_pendapatan_realisasi" => $realisasiId])->get()->sum("rkud_jumlah"); + $totalSts += replaceMoney($req["rkud_jumlah"]); + if (replaceMoney($req["rkud_jumlah"]) > $dataRealisasi["simtrad4_bersih"]){ + return redirect(URL::to("/realisasi-pendapatan/".$realisasiId))->with('error', "Jumlah STS harus sama atau lebih kecil dengan Rencana !"); + } + $sisa = $dataRealisasi["simtrad4_bersih"] - replaceMoney($req["rkud_jumlah"]); + }else{ + if ($dataRealisasi["simtrad4_bersih"]<>replaceMoney($req["rkud_jumlah"])){ + return redirect(URL::to("/realisasi-pendapatan/".$realisasiId))->with('error', "Jumlah STS harus sama dengan Rencana !"); + } } $data["rkud_tgl"] = $req["rkud_tgl"]; $data["rkud_no_sts"] = $req["rkud_no_sts"]; $data["rkud_kode_akun"] = $req["rkud_kode_akun"]; $data["rkud_nama_akun"] = $req["rkud_nama_akun"]; $data["rkud_jumlah"] = replaceMoney($req["rkud_jumlah"]); + $data["sisa_sts"] = $sisa; $file = $request->file('file_sts'); if ($file){ - $fileName = $req["rkud_no_sts"].".".$file->getClientOriginalExtension(); + $fileName = str_replace([" ","/"],["_","_"],$req["rkud_no_sts"]).".".$file->getClientOriginalExtension(); $tujuan_upload = config('constants.upload_path_sts').getTA(); File::isDirectory($tujuan_upload) or File::makeDirectory($tujuan_upload, 0777, true, true); $file->move($tujuan_upload, $fileName); $data["file_sts"] = $fileName; } - $data->save(); + + PendapatanRealisasiSts::updateOrCreate([ + "id_pendapatan_realisasi"=>$realisasiId, + "rkud_no_sts"=>$req["rkud_no_sts"] + ],$data); DB::commit(); - $userAnggaran = User::where("role_name","anggaran")->get()->toArray(); - $userAnggaran = array_column($userAnggaran,"id"); - $url = URL::to("/realisasi-pendapatan/".$realisasiId); - $message = "Realisasi Pendapatan dengan No. SP2D BUN ".$data["simtrad4_sp2d_bun"]." telah divalidasi oleh Bidang Perben!"; - $this->sendNotif("bendahara", "anggaran", $userAnggaran, $message, $url, "Realisasi Pendapatan", $data->id); + // $userAnggaran = User::where("role_name","anggaran")->get()->toArray(); + // $userAnggaran = array_column($userAnggaran,"id"); + // $url = URL::to("/realisasi-pendapatan/".$realisasiId); + // $message = "Realisasi Pendapatan dengan No. SP2D BUN ".$data["simtrad4_sp2d_bun"]." telah divalidasi oleh Bidang Perben!"; + // $this->sendNotif("bendahara", "anggaran", $userAnggaran, $message, $url, "Realisasi Pendapatan", $data->id); - return redirect(URL::to("/realisasi-pendapatan"))->with('success','STS berhasil diinput.'); + return redirect(URL::to("/realisasi-pendapatan/".$realisasiId))->with('success','STS berhasil diinput.'); }catch(\Exception $e){ DB::rollBack(); @@ -319,11 +335,33 @@ class RealisasiPendapatanController extends Controller public function downloadSts(PendapatanRealisasi $realisasi) { + $sts = PendapatanRealisasiSts::where("id_pendapatan_realisasi",$realisasi->id)->first(); $headers = [ 'Content-Type' => 'application/pdf', - 'Content-Disposition' => 'attachment;filename='.$realisasi->file_sts + 'Content-Disposition' => 'attachment;filename='.$sts->file_sts ]; - return response()->download(config('constants.upload_path_sts').getTA()."/".$realisasi->file_sts, $realisasi->file_sts, $headers); + return response()->download(config('constants.upload_path_sts').getTA()."/".$sts->file_sts, $sts->file_sts, $headers); + } + + public function deleteSts(PendapatanRealisasiSts $stsId) + { + try{ + DB::beginTransaction(); + + $uploadDir = config('constants.upload_path_sts').getTA(); + if (File::exists($uploadDir.$stsId->file_sts)){ + File::delete($uploadDir.$stsId->file_sts); + } + $stsId->delete(); + + DB::commit(); + return redirect(URL::to("/realisasi-pendapatan/".$stsId->id_pendapatan_realisasi))->with('success','Data STS Pendapatan berhasil dihapus!'); + + }catch(Throwable $e){ + + DB::rollBack(); + return redirect(URL::to("/realisasi-pendapatan/".$stsId->id_pendapatan_realisasi))->with('error','Data STS Pendapatan gagal dihapus.'); + } } } diff --git a/app/Models/PendapatanRealisasi.php b/app/Models/PendapatanRealisasi.php index 61edc06..603367d 100644 --- a/app/Models/PendapatanRealisasi.php +++ b/app/Models/PendapatanRealisasi.php @@ -18,4 +18,8 @@ class PendapatanRealisasi extends Eloquent 'retur','bersih','tw','gelombang','potongan_pph','potongan_jkn' ]; + public function hasSts() { + return $this->hasMany('App\Models\PendapatanRealisasiSts','id_pendapatan_realisasi','id'); + } + } diff --git a/app/Models/PendapatanRealisasiSts.php b/app/Models/PendapatanRealisasiSts.php new file mode 100644 index 0000000..52ce87a --- /dev/null +++ b/app/Models/PendapatanRealisasiSts.php @@ -0,0 +1,15 @@ +id(); + $table->uuid('id_pendapatan_realisasi'); + $table->date('rkud_tgl'); + $table->string('rkud_no_sts',50); + $table->string('rkud_kode_akun',50); + $table->string('rkud_nama_akun',255); + $table->decimal('rkud_jumlah',19,2); + $table->decimal('sisa_sts',19,2)->default(0); + $table->string('file_sts',50); + $table->uuid('created_by')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::dropIfExists('pendapatan_realisasi_sts'); + } +} diff --git a/resources/views/realisasi_pendapatan/show.blade.php b/resources/views/realisasi_pendapatan/show.blade.php index c98420b..9fd6e79 100644 --- a/resources/views/realisasi_pendapatan/show.blade.php +++ b/resources/views/realisasi_pendapatan/show.blade.php @@ -26,51 +26,105 @@

STS

-
- @csrf -
- -
- rkud_no_sts))?"form-control":"form-control-plaintext" }}" value="{{ empty($realisasi_pendapatan->rkud_no_sts)?"-":$realisasi_pendapatan->rkud_no_sts }}" placeholder="" {{ (Auth::user()->can("Input STS DBH Realisasi Pendapatan") && empty($realisasi_pendapatan->rkud_no_sts)) ?"":"disabled" }}> -
+ +
+
+ + @csrf +
+ +
+ rkud_no_sts }}" placeholder="" {{ (Auth::user()->can("Input STS DBH Realisasi Pendapatan")) ?"":"disabled" }}> +
+
+
+ +
+ rkud_no_sts))?"form-control":"form-control-plaintext" }}" value="{{ isset($realisasi_pendapatan->rkud_tgl)?date("Y-m-d",strtotime($realisasi_pendapatan->rkud_tgl)):"-" }}" readonly> +
+
+
+ +
+ rkud_no_sts))?"form-control":"form-control-plaintext" }}" value="{{ empty($realisasi_pendapatan->rkud_kode_akun)?"-":$realisasi_pendapatan->rkud_kode_akun }}" readonly> +
+
+
+ +
+ rkud_no_sts))?"form-control":"form-control-plaintext" }}" value="{{ empty($realisasi_pendapatan->rkud_nama_akun)?"-":$realisasi_pendapatan->rkud_nama_akun }}" readonly> +
+
+
+ +
+ rkud_no_sts))?"form-control":"form-control-plaintext" }} number-separator-indo" value="{{ separateNumberIndo($realisasi_pendapatan->rkud_jumlah) }}" readonly> +
+
+
+ +
+ can("Input STS DBH Realisasi Pendapatan")){ ?> + + +
+
+ can("Input STS DBH Realisasi Pendapatan")){ ?> +
+
+ +
+ +
-
- -
- rkud_no_sts))?"form-control":"form-control-plaintext" }}" value="{{ isset($realisasi_pendapatan->rkud_tgl)?date("Y-m-d",strtotime($realisasi_pendapatan->rkud_tgl)):"-" }}" readonly> -
+
+ + + + + + + + + + + can("Input STS DBH Realisasi Pendapatan")){ ?> + + + + + @foreach($realisasi_pendapatan->hasSts as $key=>$rowSts) + + + + + + + + + + can("Input STS DBH Realisasi Pendapatan")){ ?> + + + + @endforeach + +
NoTanggalNo. STSKode AkunNama AkunJumlahSisa STSFile STS
{{ ($key+1) }}{{ date("d/m/Y",strtotime($rowSts->rkud_tgl)) }}{{ $rowSts->rkud_no_sts }}{{ $rowSts->rkud_kode_akun }}{{ $rowSts->rkud_nama_akun }}{{ separateNumberIndo($rowSts->rkud_jumlah) }}{{ separateNumberIndo($rowSts->sisa_sts) }}id_pendapatan_realisasi/download-sts")."'>".$rowSts->file_sts."" ?> +
+ + + +
+
-
- -
- rkud_no_sts))?"form-control":"form-control-plaintext" }}" value="{{ empty($realisasi_pendapatan->rkud_kode_akun)?"-":$realisasi_pendapatan->rkud_kode_akun }}" readonly> -
-
-
- -
- rkud_no_sts))?"form-control":"form-control-plaintext" }}" value="{{ empty($realisasi_pendapatan->rkud_nama_akun)?"-":$realisasi_pendapatan->rkud_nama_akun }}" readonly> -
-
-
- -
- rkud_no_sts))?"form-control":"form-control-plaintext" }} number-separator-indo" value="{{ separateNumberIndo($realisasi_pendapatan->rkud_jumlah) }}" readonly> -
-
-
- -
- file_sts)?"":"".$realisasi_pendapatan->file_sts."
"; ?> - rkud_no_sts)?"":"style='display:none;'" ?> type="file" name="file_sts" required> -
-
- can("Input STS DBH Realisasi Pendapatan") && empty($realisasi_pendapatan->rkud_no_sts)){ ?> -
- -
- - +
@@ -78,7 +132,9 @@ @section('scripts2')