@extends('layouts.finance') @section('title', 'Bank Accounts') @section('subtitle', 'Manage and view detail on every account') @section('content') @php $dateFilter = $dateFilter ?? ['active' => false, 'from' => null, 'to' => null, 'label' => null]; $dateFilterActive = (bool) ($dateFilter['active'] ?? false); $balanceFor = fn($account) => $dateFilterActive ? (float) ($account->filtered_balance ?? 0) : (float) $account->current_balance; // Wallets default to USD, so they were being counted inside "US Total" with // no way to see them. Split them out the same way the dashboard does. $isWallet = fn($account) => trim((string) ($account->transaction_category ?? '')) === 'Wallets'; $walletAccounts = $accounts->filter($isWallet); $bankOnly = $accounts->reject($isWallet); $walletTotal = $walletAccounts->sum($balanceFor); $usTotal = $bankOnly->where('currency', 'USD')->sum($balanceFor); $pkTotal = $bankOnly->where('currency', 'PKR')->sum($balanceFor); $auTotal = $bankOnly->where('currency', 'AUD')->sum($balanceFor); // Everything in USD terms, so the page has one figure that ties to the // dashboard's Bank Balance (which has always included wallets). $grandTotalUsd = $usTotal + $walletTotal + $metrics->usd($pkTotal, 'PKR') + $metrics->usd($auTotal, 'AUD'); $countryFor = fn($currency) => $currency === 'PKR' ? 'Pakistan' : ($currency === 'AUD' ? 'Australia' : 'USA'); $pillFor = fn($currency) => $currency === 'PKR' ? 'pill-amber' : ($currency === 'AUD' ? 'pill-teal' : 'pill-blue'); @endphp @include('dashboard.cards._date-filter', ['dateFilter' => $dateFilter, 'filterRoute' => 'finance.accounts'])