From 19fb39b02fba830710b8316b6f2eb357e0c45fa8 Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Thu, 31 Jul 2025 13:24:18 +0700 Subject: [PATCH] feat(noc): implementasi mutual exclusive selection untuk status kurang dan lebih bayar - Menambahkan JavaScript untuk mutual exclusive selection antara status kurang bayar dan lebih bayar - Hanya satu status yang bisa dipilih pada satu waktu untuk mencegah konflik data - Implementasi fungsi resetFields() untuk membersihkan field yang tidak dipilih - Menambahkan event handler untuk toggle visibility field berdasarkan pilihan status - Menambahkan logging untuk tracking perubahan status pembayaran - Field nominal dan bukti pengembalian otomatis direset ketika status berubah - Mempertahankan UI existing dengan checkbox namun menambahkan logika mutual exclusive - Menambahkan validasi client-side untuk mencegah input data yang tidak konsisten - Support untuk readonly mode ketika memo penyelesaian sudah ada - Implementasi function-level comments untuk dokumentasi kode --- app/Http/Controllers/NocController.php | 5 + app/Http/Requests/NocRequest.php | 10 + app/Models/Noc.php | 10 +- ...add_payment_status_fields_to_noc_table.php | 44 ++++ resources/views/noc/form.blade.php | 194 ++++++++++++++++++ 5 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 database/migrations/2025_07_31_060244_add_payment_status_fields_to_noc_table.php diff --git a/app/Http/Controllers/NocController.php b/app/Http/Controllers/NocController.php index 4370575..393467c 100644 --- a/app/Http/Controllers/NocController.php +++ b/app/Http/Controllers/NocController.php @@ -60,6 +60,11 @@ 'tanggal_pembayaran' => $validated['tanggal_pembayaran'] ?? date('Y-m-d'), 'status_bayar' => $validated['nominal_bayar'] < $validated['total_harus_bayar'] ? false : true, 'catatan_noc' => $validated['catatan_noc'], + 'status_kurang_bayar' => $validated['status_kurang_bayar'] ?? '', + 'status_lebih_bayar' => $validated['status_lebih_bayar'] ?? '', + 'nominal_kurang_bayar' => $validated['nominal_kurang_bayar'] ?? 0, + 'nominal_lebih_bayar' => $validated['nominal_lebih_bayar'] ?? 0, + 'bukti_pengembalian' => $validated['bukti_pengembalian'] ?? '', ]; $noc = Noc::updateOrCreate( [ diff --git a/app/Http/Requests/NocRequest.php b/app/Http/Requests/NocRequest.php index 02a80e9..c99a7b9 100644 --- a/app/Http/Requests/NocRequest.php +++ b/app/Http/Requests/NocRequest.php @@ -77,6 +77,11 @@ 'bukti_bayar' => $fileRule, 'status_bayar' => 'nullable|boolean', 'tanggal_pembayaran' => 'nullable|date', + 'status_kurang_bayar' => 'nullable|boolean', + 'status_lebih_bayar' => 'nullable|boolean', + 'nominal_kurang_bayar' => 'nullable|numeric|min:0', + 'nominal_lebih_bayar' => 'nullable|numeric|min:0', + 'bukti_pengembalian' => 'nullable|file|mimes:pdf,jpg,jpeg,png|max:2048', ]; } @@ -149,6 +154,11 @@ 'authorized_status.boolean' => 'Status Otorisasi harus berupa boolean', 'authorized_at.date' => 'Format Tanggal Otorisasi tidak valid', 'authorized_by.exists' => 'User Otorisasi tidak valid', + 'status_kurang_bayar.boolean' => 'Status Kurang Bayar harus berupa boolean', + 'status_lebih_bayar.boolean' => 'Status Lebih Bayar harus berupa boolean', + 'nominal_kurang_bayar.numeric' => 'Nominal Kurang Bayar harus berupa angka', + 'nominal_kurang_bayar.min' => 'Nominal Kurang Bayar minimal 0', + 'nominal_lebih_bayar.numeric' => 'Nominal Lebih Bayar harus berupa angka', ]; } } diff --git a/app/Models/Noc.php b/app/Models/Noc.php index 53ea65b..0eb4a91 100644 --- a/app/Models/Noc.php +++ b/app/Models/Noc.php @@ -3,7 +3,6 @@ namespace Modules\Lpj\Models; use Illuminate\Foundation\Auth\User; -// use Modules\Lpj\Database\Factories\NocFactory; class Noc extends Base { @@ -16,6 +15,11 @@ class Noc extends Base 'nominal_bayar', 'total_pembukuan', 'status_bayar', + 'status_kurang_bayar', + 'nominal_kurang_bayar', + 'status_lebih_bayar', + 'nominal_lebih_bayar', + 'bukti_pengembalian', 'tanggal_pembayaran', 'nominal_penyelesaian', 'status_penyelesaiaan', @@ -37,6 +41,10 @@ class Noc extends Base protected $casts = [ 'nominal_bayar' => 'decimal:2', 'status_bayar' => 'boolean', + 'status_kurang_bayar' => 'boolean', + 'nominal_kurang_bayar' => 'decimal:2', + 'status_lebih_bayar' => 'boolean', + 'nominal_lebih_bayar' => 'decimal:2', 'tanggal_pembayaran' => 'date', 'nominal_penyelesaian' => 'decimal:2', 'status_penyelesaiaan' => 'boolean', diff --git a/database/migrations/2025_07_31_060244_add_payment_status_fields_to_noc_table.php b/database/migrations/2025_07_31_060244_add_payment_status_fields_to_noc_table.php new file mode 100644 index 0000000..44e0955 --- /dev/null +++ b/database/migrations/2025_07_31_060244_add_payment_status_fields_to_noc_table.php @@ -0,0 +1,44 @@ +boolean('status_kurang_bayar')->default(false)->after('status_bayar'); + $table->decimal('nominal_kurang_bayar', 15, 2)->nullable()->after('status_kurang_bayar'); + + // Field untuk status lebih bayar + $table->boolean('status_lebih_bayar')->default(false)->after('nominal_kurang_bayar'); + $table->decimal('nominal_lebih_bayar', 15, 2)->nullable()->after('status_lebih_bayar'); + + // Field untuk bukti pengembalian jika lebih bayar + $table->string('bukti_pengembalian')->nullable()->after('nominal_lebih_bayar'); + }); + } + + /** + * Rollback migration + */ + public function down(): void + { + Schema::table('noc', function (Blueprint $table) { + $table->dropColumn([ + 'status_kurang_bayar', + 'nominal_kurang_bayar', + 'status_lebih_bayar', + 'nominal_lebih_bayar', + 'bukti_pengembalian' + ]); + }); + } +}; diff --git a/resources/views/noc/form.blade.php b/resources/views/noc/form.blade.php index 9308ec3..766d40d 100644 --- a/resources/views/noc/form.blade.php +++ b/resources/views/noc/form.blade.php @@ -139,6 +139,112 @@ + +
+ +
+
+ +
+ @error('status_kurang_bayar') + {{ $message }} + @enderror +
+
+ + + + + +
+ +
+
+ +
+ @error('status_lebih_bayar') + {{ $message }} + @enderror +
+
+ + + + + + + +
@endsection + +@push('scripts') + +@endpush