diff --git a/app/Http/Controllers/AccountStatementController.php b/app/Http/Controllers/AccountStatementController.php new file mode 100644 index 0000000..f081da1 --- /dev/null +++ b/app/Http/Controllers/AccountStatementController.php @@ -0,0 +1,57 @@ +norujukan)->json()[0][0]; + $transaction = Http::get(config('api.url').'/portal/transaksipelanggan',['norujukan' => $request->norujukan])->json(); + $cawangan=Http::get(config('api.url').'/api/cawangan/detail/'. $gadaian['kodcaw'])->json()[0]; + $customer = Http::get(config('api.url') . '/api/customers/' . $gadaian['nokp'])->json(); + $poskod = Http::get(config('api.url') . '/api/poskod/' . $customer['poskod'])->json(); + + $accountHolder = [ + 'name' => $customer['nama'], + 'address' => $customer['alamat1'] . '
' . $customer['alamat2'], + 'city_state_zip' => $customer['poskod'] . ', ' . $poskod['daerah']['namadaerah'] . ', ' . $poskod['negeri']['negeri'], + ]; + + $bankDetails = [ + 'name' => $cawangan['cawangan'], + 'address' => $cawangan['alamat1'] . '
' . $cawangan['alamat2'], + 'branch' => $cawangan['namacaw'], + ]; + + + $transaction_count = count(array_filter($transaction, fn($trans) => $trans['trans_type'] == 'A')); + $totalPages = ceil($transaction_count / 10); + + $ansuranTransaction = array_values(array_filter($transaction, fn($trans) => $trans['trans_type'] == 'A')); + $originLoan = $gadaian['pinjaman']; + $bakipinjaman = $originLoan; + $ansuranTransaction = array_map(function($trans) use(&$bakipinjaman) { + $bakipinjaman -= $trans['bayaran_pembiayaan']; + return array_merge($trans, ['bakipinjaman' => $bakipinjaman]); + }, $ansuranTransaction); + + $tebusTransaction = array_values(array_filter($transaction, fn($trans) => $trans['trans_type'] == 'T'))[0]; + + return view('accounts-statements', compact('tebusTransaction','ansuranTransaction','transaction_count','gadaian','transaction','accountHolder', 'bankDetails')); + } + + /** + * Helper function to format currency. + * In a real app, this would be a Blade helper or filter. + * We'll format it directly in the view for simplicity in this example. + */ +} \ No newline at end of file diff --git a/resources/js/components/util/RekodBayaranModal.vue b/resources/js/components/util/RekodBayaranModal.vue index 6192b06..4aa6c24 100644 --- a/resources/js/components/util/RekodBayaranModal.vue +++ b/resources/js/components/util/RekodBayaranModal.vue @@ -43,6 +43,9 @@ Tarikh Bayaran + + Masa Bayaran + Bayaran @@ -54,14 +57,13 @@ -
-
-

- Tiada Data Diperolehi -

-
-
- +
+ + + +

Tiada Data Diperolehi

+
+ @@ -75,7 +77,15 @@
-

+

+

+
+
+ + +
+
+

@@ -125,14 +135,13 @@ -
-
-

- Tiada Data Diperolehi -

-
-
- +
+ + + +

Tiada Data Diperolehi

+
+ @@ -179,25 +188,25 @@ - - - - - - - @@ -205,14 +214,13 @@ +
+ + + +

Tiada Data Diperolehi

+
+ @@ -390,6 +401,53 @@ export default { break; } }, + rekodSAGStatements: function(norujukan){ + let urlroute = window.route('accountstatement.rekod', norujukan) + window.open(urlroute, '_blank'); + }, + formatDate(datetime, type) { + if (!datetime) return ''; + + const date = new Date(datetime); + + if (type === 'date') { + // Return date only in dd/mm/yyyy format + const day = String(date.getDate()).padStart(2, '0'); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const year = date.getFullYear(); + return `${day}/${month}/${year}`; + } + + if (type === 'time') { + // Return time in 12-hour format with AM/PM + let hours = date.getHours(); + const minutes = String(date.getMinutes()).padStart(2, '0'); + const seconds = String(date.getSeconds()).padStart(2, '0'); + const ampm = hours >= 12 ? 'PM' : 'AM'; + + hours = hours % 12; + hours = hours ? hours : 12; // the hour '0' should be '12' + hours = String(hours).padStart(2, '0'); + + return `${hours}:${minutes}:${seconds} ${ampm}`; + } + + // Default: return both date and time + const day = String(date.getDate()).padStart(2, '0'); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const year = date.getFullYear(); + + let hours = date.getHours(); + const minutes = String(date.getMinutes()).padStart(2, '0'); + const seconds = String(date.getSeconds()).padStart(2, '0'); + const ampm = hours >= 12 ? 'PM' : 'AM'; + + hours = hours % 12; + hours = hours ? hours : 12; + hours = String(hours).padStart(2, '0'); + + return `${day}/${month}/${year} ${hours}:${minutes}:${seconds} ${ampm}`; + }, } } diff --git a/resources/js/pages/Detailspelanggan.vue b/resources/js/pages/Detailspelanggan.vue index 2e126c0..a5ca76d 100644 --- a/resources/js/pages/Detailspelanggan.vue +++ b/resources/js/pages/Detailspelanggan.vue @@ -2,7 +2,7 @@
-
+
@@ -334,12 +335,13 @@ @@ -457,12 +459,13 @@ diff --git a/resources/views/accounts-statements.blade.php b/resources/views/accounts-statements.blade.php new file mode 100644 index 0000000..9a71036 --- /dev/null +++ b/resources/views/accounts-statements.blade.php @@ -0,0 +1,501 @@ + + + + + + + Account Statements - {{ $bankDetails['name'] }} + + + + + + + + @php + // Helper function to format currency for the template + function formatCurrency($amount, $currency = 'RM') + { + return is_numeric($amount) ? `$currency ` . number_format($amount, 2) : '-'; + } + @endphp + +
+ + +
+
+

{{ $bankDetails['name'] }} +

+

{!! $bankDetails['address'] !!}

+
+
+
{{ $gadaian['norujukan'] }}
+
+ IC: + {{ $gadaian['nokp'] }} + + Tarikh Pembiayaan: + {{ $gadaian['t_gadai'] }} + + Tempoh Pembiayaan: + {{ $gadaian['tempoh'] }} +
+
+
+ + +
+ +
+

{{ $accountHolder['name'] }}

+

{!! $accountHolder['address'] !!}

+

{{ $accountHolder['city_state_zip'] }}

+
+ +
+

{{ $bankDetails['branch'] }}

+

Page 1 of 1

+
+
+ + +
+

Ringkasan Pembiayaan

+
+ +
+
Pembiayaan:
+
{{ formatCurrency($gadaian['pinjaman']) }} +
+
+
+
Nilai Marhun:
+
{{ formatCurrency($gadaian['nilaimarhun']) }}
+
+
+
+
1 Percent:
+
{{ formatCurrency($gadaian['ujrah']) }}
+
Ujrah:
+
{{ formatCurrency($gadaian['onepercent']) }}
+
+
+
Keuntungan:
+
{{ formatCurrency($gadaian['ujrah'] + $gadaian['onepercent']) }}
+
+ +
+ + +
+
Harga Jualan:
+
{{ formatCurrency($gadaian['hargajualan']) }}
+
+
+
Jumlah Transaksi:
+
{{ $transaction_count }}
+
+
+
Harga Tebus:
+
{{ formatCurrency($tebusTransaction['duit_masuk']) }} +
+
+
+
+ + +
+

Transaksi

+ +
+ Bil + No Rujukan - Jenis Penyelesaian Pembiayaan + + Jenis + Pembiayaan Asal + Tempoh - Tarikh Penyelesaian Pembiayaan + + Tarikh + Action
-
-
-

- Tiada Data Diperolehi -

-
-
-
@@ -266,12 +274,15 @@
- +
-
-
-

- Tiada data yang diperolehi dalam carian -

-
+
+ + + +

+ Tiada data yang diperolehi dalam carian +

-
-
-

- Tiada data yang diperolehi dalam carian -

-
+
+ + + +

+ Tiada data yang diperolehi dalam carian +

-
-
-

- Tiada data yang diperolehi dalam carian -

-
+
+ + + +

+ Tiada data yang diperolehi dalam carian +

+ + + + + + + + + + + + + + @php $totalUpahRebet=0;$totalUpah = 0; $totalBayaran = 0; $totalPembiayaan = 0; $totalRebet = 0; @endphp + @foreach ($ansuranTransaction as $transaction) + + + + + + + + + + + @php $totalUpahRebet += $transaction['keuntungan_rebet']; $totalUpah += $transaction['bayaran_keuntungan']; $totalBayaran += $transaction['duit_masuk']; $totalPembiayaan += $transaction['bayaran_pembiayaan']; $totalRebet += ($transaction['bayaran_keuntungan'] - $transaction['keuntungan_rebet']);@endphp + @endforeach + + + + + + + + + + + + + + + + + + + + + + + +
TarikhDeskripsiTempohBayaran (RM)Upah (RM)Pembiayaan (RM)Rebet (RM)Baki (RM)
{{ date('d/m/Y', strtotime($transaction['created_at'])) }}{{ ($transaction['teller'] == 'Online') ? 'Bayaran Online' : 'Bayaran Kaunter' }} + {{ $transaction['beza_tempoh'] }} + + @if ($transaction['duit_masuk']) + {{ formatCurrency($transaction['duit_masuk']) }} + @else + - + @endif + + @if ($transaction['bayaran_keuntungan']) + {{ formatCurrency($transaction['bayaran_keuntungan']) }} + @else + - + @endif + + @if ($transaction['bayaran_pembiayaan']) + {{ formatCurrency($transaction['bayaran_pembiayaan']) }} + @else + - + @endif + + {{ formatCurrency($transaction['bayaran_keuntungan'] - $transaction['keuntungan_rebet']) }} + + {{ formatCurrency($transaction['bakipinjaman']) }} +
{{ date('d/m/Y', strtotime($tebusTransaction['created_at'])) }}Tebus Kaunter + {{ $tebusTransaction['beza_tempoh'] }} + + @if ($tebusTransaction['duit_masuk']) + {{-- {{ formatCurrency($tebusTransaction['duit_masuk']) }} --}} + - + @else + - + @endif + + @if ($tebusTransaction['bayaran_keuntungan']) + {{ formatCurrency($tebusTransaction['bayaran_keuntungan']) }} + @else + - + @endif + + @if ($tebusTransaction['bayaran_pembiayaan']) + {{-- {{ formatCurrency($tebusTransaction['bayaran_pembiayaan']) }} --}} + - + @else + - + @endif + + @php $tebusRebet = ($tebusTransaction['bayaran_keuntungan'] - $tebusTransaction['keuntungan_rebet']) - $totalRebet;@endphp + {{ formatCurrency($tebusRebet) }} + + 0 +
Jumlah + {{ formatCurrency($totalBayaran) }} + {{ formatCurrency($totalUpah + $tebusTransaction['bayaran_keuntungan']) }} + {{ formatCurrency($totalPembiayaan) }} + {{ formatCurrency($totalRebet + $tebusRebet) }} +
+ + +
+
+
+

+ SEMAKAN BAKI PEMBIAYAAN

+
+ @php + /*Calculation Baki Pembiayaan*/ + $bakiPembiayaan = $tebusTransaction['bayaran_pembiayaan']; + $onePercent = $tebusTransaction['onepercent']; + $onePercentRebet = $tebusTransaction['onepercent'] - $tebusTransaction['onepercent_rebet']; + $ujrah = $tebusTransaction['ujrah']; + $ujrahRebet = $tebusTransaction['ujrah'] - $tebusTransaction['ujrah_rebet']; + $totalBayaranPembiayaan = $bakiPembiayaan + $onePercent - $onePercentRebet + $ujrah - $ujrahRebet; + @endphp + +
+
+
JUMLAH
+ + {{-- Beginning Balance --}} +
Baki Pembiayaan
+
+ {{ formatCurrency($bakiPembiayaan) }} +
+ + {{-- Deposits and Additions --}} +
(+) Keuntungan 1%
+
+ {{ formatCurrency($onePercent) }} +
+ + {{-- ATM & Debit Card Withdrawals --}} +
(-) Rebet Keuntungan 1%
+
+ {{ formatCurrency($onePercentRebet) }} +
+ + {{-- Deposits and Additions --}} +
(+) Ujrah
+
+ {{ formatCurrency($ujrah) }} +
+ + {{-- ATM & Debit Card Withdrawals --}} +
(-) Rebet Ujrah
+
+ {{ formatCurrency($ujrahRebet) }} +
+ + {{-- Separator Line (Visual emphasis for Ending Balance calculation) --}} +
+ + {{-- Ending Balance --}} +
Jumlah Bayaran
+
+ {{ formatCurrency($totalBayaranPembiayaan) }} +
+
+
+ +
+
+

+ SEMAKAN BAKI HARGA JUALAN

+
+ + @php + /*Calculation Baki Harga Jualan*/ + $bakiHargaJualan = $gadaian['hargajualan'] - $totalBayaran; + $upah12 = $gadaian['upah12']; + $totalUpahRebet = $totalUpahRebet; + $tebusRebet = ($tebusTransaction['bayaran_keuntungan'] - $tebusRebet); + $totalBayaranBakiHargaJualan = $bakiHargaJualan - $upah12 + $totalUpahRebet + $tebusRebet; + @endphp + +
+
+
JUMLAH
+ + {{-- Beginning Balance --}} +
Baki Harga Jualan
+
+ {{ formatCurrency($bakiHargaJualan) }} +
+ + {{-- Deposits and Additions --}} +
(-) Upah 12
+
+ {{ formatCurrency($upah12) }} +
+ + {{-- ATM & Debit Card Withdrawals --}} +
(+) Jumlah Rebet
+
+ {{ formatCurrency($totalUpahRebet) }} +
+ + {{-- Deposits and Additions --}} +
(+) Upah Tebus Rebet
+
+ {{ formatCurrency($tebusRebet) }} +
+ + {{-- Separator Line (Visual emphasis for Ending Balance calculation) --}} +
+ + {{-- Ending Balance --}} +
Jumlah Bayaran
+
+ {{ formatCurrency($totalBayaranBakiHargaJualan) }} +
+
+
+
+ + + + + + +
+ +
+ + + + \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index c815605..1c7e8c2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -6,6 +6,7 @@ use App\Http\Controllers\OnlineTransactionController; use App\Http\Controllers\OnlineTransactionGadaianController; use App\Http\Controllers\OnlineTransactionLogController; use App\Http\Controllers\OnlineTransactionTrailController; +use App\Http\Controllers\AccountStatementController; use App\Http\Controllers\AutoSerahanController; use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Http; @@ -200,6 +201,9 @@ Route::get('/autoserahan/reject', [AutoSerahanController::class,'reject'])->nam Route::get('/autoserahan/list', [AutoSerahanController::class,'getList'])->name('autoserahan.get'); Route::get('/autoserahan/rekod', [AutoSerahanController::class,'record'])->name('autoserahan.rekod'); +//Account Statements +Route::get('/accounts/statements/{norujukan}', [AccountStatementController::class,'showStatement'])->name('accountstatement.rekod'); + Route::get('{any}', function () { return view('home'); })->where('any','.*');