From 58b5bc015f6272f8aab395e690ae94e71aa9453d Mon Sep 17 00:00:00 2001 From: Cyclone Date: Sat, 29 Nov 2025 22:12:39 +0800 Subject: [PATCH] added account-statements for specific norujukan --- .../AccountStatementController.php | 66 ++++ resources/views/accounts-statements.blade.php | 373 ++++++++++++++++++ routes/web.php | 55 +++ 3 files changed, 494 insertions(+) create mode 100644 app/Http/Controllers/AccountStatementController.php create mode 100644 resources/views/accounts-statements.blade.php diff --git a/app/Http/Controllers/AccountStatementController.php b/app/Http/Controllers/AccountStatementController.php new file mode 100644 index 0000000..a8a1685 --- /dev/null +++ b/app/Http/Controllers/AccountStatementController.php @@ -0,0 +1,66 @@ +json()[0][0]; + $transaction = Http::get(config('api.url').'/portal/transaksipelanggan',['norujukan' => 'KB2240919-0004'])->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' => 'PERMODALAN KELANTAN BERHAD', + 'address' => $cawangan['alamat1'] . '
' . $cawangan['alamat2'], + 'email' => 'firstcitizensbank@domain.com', + 'branch' => $cawangan['namacaw'], + ]; + + + // Calculate total pages (e.g., 10 transactions per page + one row for header/footer on page 1) + // This is a rough estimate; the Blade file will handle the actual print pagination using CSS. + + $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/views/accounts-statements.blade.php b/resources/views/accounts-statements.blade.php new file mode 100644 index 0000000..8c4907d --- /dev/null +++ b/resources/views/accounts-statements.blade.php @@ -0,0 +1,373 @@ + + + + + + + Bank Statement - {{ $bankDetails['name'] }} + + + + + + + + @php + // Helper function to format currency for the template + function formatCurrency($amount) + { + return is_numeric($amount) ? 'RM ' . 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

+ + + + + + + + + + + + + + + + @php $totalUpah = 0; $totalBayaran = 0; $totalPembiayaan = 0; $totalRebet = 0; @endphp + @foreach ($ansuranTransaction as $transaction) + + + + + + + + + + + @php $totalUpah += $transaction['bayaran_keuntungan']; $totalBayaran += $transaction['duit_masuk']; $totalPembiayaan += $transaction['bayaran_pembiayaan']; $totalRebet += ($transaction['bayaran_keuntungan'] - $transaction['keuntungan_rebet']);@endphp + @endforeach + + + + + + + + + + +
TarikhDeskripsiTempohBayaranUpahPembiayaanRebetBaki
{{ 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']) }} +
Jumlah: + {{ formatCurrency($totalBayaran) }} + {{ formatCurrency($totalUpah) }} + {{ formatCurrency($totalPembiayaan) }} + {{ formatCurrency($totalRebet) }} +
+
+ +
+
+

+ SEMAKAN TERAKHIR

+
+ +
+
+
JUMLAH
+ + {{-- Beginning Balance --}} +
Baki Pembiayaan
+
+ {{ formatCurrency($tebusTransaction['bayaran_pembiayaan']) }} +
+ + {{-- Deposits and Additions --}} +
Keuntungan 1%
+
+ {{ formatCurrency($tebusTransaction['onepercent']) }} +
+ + {{-- ATM & Debit Card Withdrawals --}} +
Rebet Keuntungan 1%
+
+ {{ formatCurrency($tebusTransaction['onepercent'] - $tebusTransaction['onepercent_rebet']) }} +
+ + {{-- Deposits and Additions --}} +
Ujrah
+
+ {{ formatCurrency($tebusTransaction['ujrah']) }} +
+ + {{-- ATM & Debit Card Withdrawals --}} +
Rebet Ujrah
+
+ {{ formatCurrency($tebusTransaction['ujrah'] - $tebusTransaction['ujrah_rebet']) }} +
+ + {{-- +
Ujrah
+
+ + -122.50 +
--}} + + {{-- Separator Line (Visual emphasis for Ending Balance calculation) --}} +
+ + {{-- Ending Balance --}} +
Jumlah Bayaran
+
+ {{ formatCurrency($tebusTransaction['duit_masuk']) }} +
+
+
+ + +
+

Ini ialah penyata akaun yang dijana secara automatik. Sila hubungi kami untuk sebarang percanggahan

+
+
+ + +
+ +
+ + + + diff --git a/routes/web.php b/routes/web.php index c815605..e201a0e 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,60 @@ 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('/autoserahan/rekod', [AutoSerahanController::class,'record'])->name('autoserahan.rekod'); + +Route::get('/accounts/statements', [AccountStatementController::class,'showStatement'])->name('accountstatement.rekod'); +// Route::get('/accounts', function () { + + + +// $accountHolder = [ +// 'name' => 'John Smith', +// 'address' => '2450 Courage St, STE 108', +// 'city_state_zip' => 'Brownsville, TX 78521', +// ]; + +// $bankDetails = [ +// 'name' => 'PERMODALAN KELANTAN BERHAD', +// 'address' => '231 Valley Farms Street Santa Monica, CA 90403', +// 'email' => 'firstcitizensbank@domain.com', +// 'branch' => 'Main Branch - Santa Monica', +// 'account_number' => '111-234-567-890', +// 'statement_date' => '10/31/2025', +// 'period_covered' => '10/01/2025 to 10/31/2025', +// ]; + +// $summary = [ +// 'opening_balance' => 175800.00, +// 'total_credit' => 510000.00, +// 'total_debit' => 94000.00, +// 'closing_balance' => 591800.00, +// 'account_type' => 'Current Account', +// 'transaction_count' => 8, +// ]; + +// $transactions = [ +// // Note: The PDF format has Debit/Credit columns reversed in some tools, +// // but standard accounting puts Credits first. We'll follow the PDF logic +// // where amounts are placed under the correct column (Credit or Debit). +// ['date' => '10/02/2025', 'description' => 'Payment - Credit Card', 'credit' => null, 'debit' => 5400.00, 'balance' => 170400.00], +// ['date' => '10/03/2025', 'description' => 'Payment - Insurance', 'credit' => null, 'debit' => 3000.00, 'balance' => 167400.00], +// ['date' => '10/05/2025', 'description' => 'Account Transfer In', 'credit' => 500000.00, 'debit' => null, 'balance' => 667400.00], +// ['date' => '10/10/2025', 'description' => 'Cheque Deposit', 'credit' => 10000.00, 'debit' => null, 'balance' => 677400.00], +// ['date' => '10/15/2025', 'description' => 'Payment - Electricity', 'credit' => null, 'debit' => 1500.00, 'balance' => 675900.00], +// ['date' => '10/20/2025', 'description' => 'Payment - Water Utility', 'credit' => null, 'debit' => 600.00, 'balance' => 675300.00], +// ['date' => '10/25/2025', 'description' => 'Payment - Car Loan', 'credit' => null, 'debit' => 3500.00, 'balance' => 671800.00], +// ['date' => '10/30/2025', 'description' => 'Account Transfer Out', 'credit' => null, 'debit' => 80000.00, 'balance' => 591800.00], +// ]; + + + +// return view('accounts-statements', compact('accountHolder', 'bankDetails', 'summary', 'transactions')); +// }); + + Route::get('{any}', function () { return view('home'); })->where('any','.*');