@extends('layouts.app') @section('title', 'Bank Reconciliation — Command Centre') @push('styles') @endpush @section('content') @php $user = Auth::user(); $currency_code = $user->base_currency ?? 'USD'; $sym = ['USD'=>'$','EUR'=>'€','GBP'=>'£','OMR'=>'ر.ع.','AED'=>'د.إ','SAR'=>'ر.س','PKR'=>'₨','INR'=>'₹','KWD'=>'د.ك','QAR'=>'ر.ق']; $cs = $sym[$currency_code] ?? $currency_code; $fmt = fn($n) => $cs . number_format(abs((float)$n), 2); $TX_TYPES = [ 'income' => ['label' => 'Income', 'class' => 't-income', 'cat' => 'income'], 'expense' => ['label' => 'Expense', 'class' => 't-expense', 'cat' => 'expense'], 'transfer' => ['label' => 'Transfer', 'class' => 't-transfer', 'cat' => null], 'investment' => ['label' => 'Investment', 'class' => 't-investment', 'cat' => 'expense'], 'loan_disbursement' => ['label' => 'Loan Received', 'class' => 't-loan_disbursement', 'cat' => 'income'], 'loan_repayment' => ['label' => 'Loan Payment', 'class' => 't-loan_repayment', 'cat' => 'expense'], 'credit_card_payment' => ['label' => 'CC Payment', 'class' => 't-credit_card_payment', 'cat' => 'expense'], 'refund' => ['label' => 'Refund', 'class' => 't-refund', 'cat' => 'income'], 'payment' => ['label' => 'Payment', 'class' => 't-payment', 'cat' => 'expense'], ]; $amtClass = fn($type) => match(true) { in_array($type, ['income','refund','loan_disbursement']) => 'amt-inc', in_array($type, ['transfer']) => 'amt-xfer', in_array($type, ['investment']) => 'amt-inv', in_array($type, ['loan_repayment','loan_disbursement']) => 'amt-loan', default => 'amt-exp', }; @endphp
@if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- TOPBAR --}}
Reconciliation Command Centre · {{ $monthDisplay }}
← Accounts ⬇ PDF
{{-- UPLOAD PANEL --}}
⬆ Import Bank Statement
CSV Excel (multi-sheet) PDF @if($totalStatementCount > 0) {{ $totalStatementCount }} loaded @endif
@csrf
📂

Drop file or click to browse

All formats auto-categorised • Multi-sheet Excel supported • Detects income, expenses, loans, investments, CC payments

@if($totalStatementCount > 0) @endif
@if($totalStatementCount > 0)
✓ {{ $totalStatementCount }} statement transactions loaded
@endif
{{-- BALANCE CARDS --}}
🏛 System Balance
{{ $fmt($ledgerBalance) }}
{{ $selectedAccount->account_name ?? 'No Account' }}
📄 Statement Balance
Enter from bank statement
⚖ Difference
{{ ($difference >= 0 ? '+' : '') . $fmt($difference) }}
{{ abs($difference) < 0.01 ? '✓ Perfectly balanced' : 'Unbalanced — investigate' }}
📊 Reconciled
{{ $pctReconciled }}%
{{ ($cntMatched + $cntNear) }} of {{ $totalItems }} matched
{{-- STATS --}}
{{ $cntMatched }}Exact Match
{{ $cntNear }}Near Match
{{ $cntSysOnly }}System Only
{{ $cntStmtOnly }}Statement Only
@foreach($typeSummary as $t => $info)
{{ $info['count'] }} {{ Str::limit(str_replace('_',' ',ucfirst($t)),10) }}
@endforeach
{{-- SUMMARY LINE --}} @if($totalStatementCount > 0)
Statement: {{ $totalStatementCount }} rows
|
System Txns: {{ $systemTransactions->count() }}
|
Pending Add: {{ $cntStmtOnly }}
|
Month: {{ $monthDisplay }}
@endif {{-- BULK BAR --}} @if($cntStmtOnly > 0)
0 selected
@endif {{-- MAIN TABLE --}}
📋 Transactions to Reconcile @if($totalItems > 0) {{ $totalItems }} @endif
@if(empty($reconciliationItems))
🔍

No transactions to reconcile

Upload a bank statement above to begin, or check the selected account and month.

@else
@foreach($pagedItems as $ri => $item) @php $cleared = isset($item['id']) && in_array((int)$item['id'], $clearedIds); if ($cleared) continue; $is_stmt = $item['type'] === 'statement_only'; $is_sys = $item['type'] === 'system_only'; $is_matched = in_array($item['type'], ['matched', 'near_match']); $disp_date = $item['transaction_date'] ?? $item['stmt_date'] ?? ''; $disp_desc = $item['description'] ?? $item['stmt_desc'] ?? ''; $disp_amt = (float)($item['amount'] ?? $item['stmt_amount'] ?? 0); $disp_type = $item['transaction_type'] ?? $item['stmt_type'] ?? 'expense'; $disp_cat = $item['category_name'] ?? ($item['suggested_cat_name'] ?? '—'); $sys_cat_id = (int)($item['category_id'] ?? 0); $sug_cat_id = (int)($item['suggested_cat_id'] ?? 0); $sug_cat_nm = (string)($item['suggested_cat_name'] ?? ''); $src_sheet = $item['source_sheet'] ?? ''; $row_id = 'row_' . $ri . '_' . substr(md5($disp_date . $disp_desc . $disp_amt), 0, 8); $typeInfo = $TX_TYPES[$disp_type] ?? ['label' => ucfirst($disp_type), 'class' => 't-expense', 'cat' => 'expense']; $dateObj = null; try { $dateObj = \Carbon\Carbon::parse($disp_date); } catch(\Exception $e) {} $amtCls = $amtClass($disp_type); @endphp {{-- Checkbox --}} {{-- Date --}} {{-- Description --}} {{-- Category --}} {{-- Transaction Type --}} {{-- Amount --}} {{-- Status --}} {{-- Statement Match Info --}} {{-- Actions --}} @endforeach {{-- QUICK ADD ROW --}}
Date Description Category Tx Type Amount Status Statement Match Actions
@if($is_stmt) @endif @if($dateObj)
{{ $dateObj->format('d') }} {{ $dateObj->format('M') }}
@else {{ $disp_date }} @endif
@if($is_stmt) @else
{{ $disp_desc }}
@endif @if($src_sheet && $src_sheet !== 'CSV')
📄 {{ $src_sheet }}
@endif @if($is_matched && !empty($item['stmt_desc']))
↔ {{ Str::limit($item['stmt_desc'], 40) }}
@endif
@if($is_stmt)
@foreach($incomeCategories as $cat)
{{ $cat->name }}Income
@endforeach @foreach($expenseCategories as $cat)
{{ $cat->name }}Expense
@endforeach
@else {{ $disp_cat }} @endif
@if($is_stmt) @else {{ $typeInfo['label'] }} @endif @if($is_stmt) @else {{ $fmt($disp_amt) }} @endif @if($item['type'] === 'matched') ✓ Exact @elseif($item['type'] === 'near_match') ≈ Near @elseif($is_sys) ⚠ Sys Only @else 📄 Stmt @endif @if(isset($item['stmt_amount']) && $item['stmt_amount'] > 0) {{ $fmt($item['stmt_amount']) }} @if(isset($item['stmt_date']) && $item['stmt_date'] !== ($item['transaction_date'] ?? ''))
{{ $item['stmt_date'] }}
@endif @else — @endif
@if($is_matched || $item['type'] === 'near_match') @elseif($is_sys) @else @endif
{{-- Pagination --}} @if($totalPages > 1)
@if($reconPage > 1) ← Prev @endif Page {{ $reconPage }} / {{ $totalPages }}  ·  {{ $totalItems }} total @if($reconPage < $totalPages) Next → @endif
@endif @endif
{{-- ===================================================================== EDIT SYSTEM TRANSACTION MODAL (full-featured: all types) ===================================================================== --}} {{-- ===================================================================== QUICK ADD MODAL (for toolbar Quick Entry button) ===================================================================== --}} {{-- ============================================================ JAVASCRIPT ============================================================ --}}
{{-- /.rc-page --}} @endsection