@extends('layouts.app') @section('title', 'All Bank Transactions') @section('content')
@if(session('success')) @endif
{{ $stats['total_transactions'] }}
Total Transactions ({{ now()->format('M Y') }})
৳{{ number_format($stats['total_deposits'], 2) }}
Total Deposits ({{ now()->format('M Y') }})
৳{{ number_format($stats['total_withdrawals'], 2) }}
Total Withdrawals ({{ now()->format('M Y') }})
{{ $stats['pending_transactions'] }}
Pending ({{ now()->format('M Y') }})
{{ $stats['completed_transactions'] }}
Completed ({{ now()->format('M Y') }})
৳{{ number_format($stats['total_deposits'] - $stats['total_withdrawals'], 2) }}
Net Balance ({{ now()->format('M Y') }})
Filters
@php $hasFilters = request()->hasAny(['search', 'transaction_type', 'status', 'date_from', 'date_to']); @endphp @if($hasFilters)
Filtered Results Summary
@php $filteredStats = [ 'count' => $transactions->total(), 'total_deposit_balance' => $transactions->sum('deposit_balance'), 'total_fee' => $transactions->sum('fee'), 'total_withdraw_balance' => $transactions->sum('withdraw_balance'), 'deposits' => $transactions->where('transaction_type', 'deposit')->sum('deposit_balance'), 'withdrawals' => $transactions->where('transaction_type', 'withdrawal')->sum('withdraw_balance'), ]; $netAmount = $filteredStats['deposits'] - $filteredStats['withdrawals']; @endphp {{ $filteredStats['count'] }} transactions Deposits: +৳{{ number_format($filteredStats['deposits'], 2) }} Withdrawals: -৳{{ number_format($filteredStats['withdrawals'], 2) }} Net: ৳{{ number_format($netAmount, 2) }} Total Deposits: ৳{{ number_format($filteredStats['total_deposit_balance'], 2) }} Total Withdrawals: ৳{{ number_format($filteredStats['total_withdraw_balance'], 2) }} Total Fee: ৳{{ number_format($filteredStats['total_fee'], 2) }}
@endif
@php // Pre-calculate running balances per transaction (Balance after Deposit) $runningBalances = []; $accountIds = $transactions->pluck('bank_account_info_id')->unique()->filter()->values(); foreach ($accountIds as $accountId) { $account = \App\Models\BankAccountInfo::find($accountId); $opening = $account->opening_balance ?? 0; $allTx = \App\Models\BankTransaction::where('bank_account_info_id', $accountId) ->orderBy('transaction_date', 'asc') ->orderBy('id', 'asc') ->get(); $balance = $opening; foreach ($allTx as $tx) { $balance += $tx->deposit_balance; $balance -= $tx->withdraw_balance; $runningBalances[$tx->id] = $balance; } } @endphp @forelse($transactions as $index => $transaction) @empty @endforelse
SL Date Bank Account Account Holder Type Description Amount Fee Withdrawal Deposit Balance Status Initiated & Created by
{{ $transactions->firstItem() + $index }} {{ $transaction->transaction_date->format('M d, Y H:i') }} {{ $transaction->bankAccountInfo->bank_name }}
{{ $transaction->bankAccountInfo->account_number }}
{{ $transaction->bankAccountInfo->accountHolder->name }} {{ ucfirst($transaction->transaction_type) }} {{ $transaction->description ?? 'N/A' }} {{ $transaction->signed_amount }} @if($transaction->fee > 0) ৳{{ number_format($transaction->fee, 2) }} @else - @endif ৳{{ number_format($transaction->withdraw_balance, 2) }} ৳{{ number_format($transaction->deposit_balance, 2) }} ৳{{ number_format($runningBalances[$transaction->id] ?? 0, 2) }} @php $isApproved = !is_null($transaction->approved_by) && !is_null($transaction->approved_at); @endphp
@if($transaction->status != 'completed') {{ ucfirst($transaction->status) }}
@endif @if($isApproved) @else @endif
@if($transaction->initiated_by || $transaction->created_by)
@if($transaction->initiated_by)
Initiated: {{ $transaction->initiatedBy->name ?? 'N/A' }}
@endif @if($transaction->created_by)
Created: {{ $transaction->createdBy->name ?? 'N/A' }}
@endif
@else - @endif
No transactions found.
@if($transactions->hasPages())
Showing {{ $transactions->firstItem() }} to {{ $transactions->lastItem() }} of {{ $transactions->total() }} transactions
@endif
@endsection