@extends('layouts.app') @php function getAccountIcon($accountType) { $icons = [ 'bank' => '', 'cash' => '', 'investment' => '', 'credit_card' => '', 'loan' => '', 'mortgage' => '', ]; return $icons[$accountType] ?? $icons['bank']; } function getCurrencySymbol($code) { $symbols = ['USD' => '$', 'EUR' => '€', 'GBP' => '£', 'OMR' => 'ر.ع.', 'AED' => 'د.إ', 'SAR' => 'ر.س', 'PKR' => '₨', 'INR' => '₹']; return $symbols[$code] ?? $code; } function fmtCurrency($amount, $currency) { return getCurrencySymbol($currency) . number_format((float)$amount, 2); } @endphp @section('title', 'Accounts — Financial OS') @push('styles') @endpush @section('content') @php $user = Auth::user(); $canEdit = $canEdit ?? true; $baseCurrency = $user->base_currency ?? 'USD'; $currencySymbol = getCurrencySymbol($baseCurrency); @endphp {{-- TOASTS --}} @if(session('success'))
{{ session('success') }}
@endif @if(session('error'))
{{ session('error') }}
@endif {{-- Stats --}}
Total Assets
{{ $currencySymbol }}{{ number_format($assets->sum('current_balance'), 2) }}
Credit Balance
{{ $currencySymbol }}{{ number_format($totalCcBalance, 2) }}
Available Credit
{{ $currencySymbol }}{{ number_format($availableCredit, 2) }}
Net Worth
{{ $currencySymbol }}{{ number_format($assets->sum('current_balance') - $creditCards->sum('current_balance') - $loans->sum('current_balance'), 2) }}
{{-- Add Account Form --}} @if($canEdit)

Add New Account

@csrf
@endif {{-- Assets --}} @if($assets->isNotEmpty())
Assets
@foreach($assets as $a)
{{ strtoupper($a->account_type) }}
{{ $a->financial_institution ?: 'Account' }}
Account Number
{{ $a->account_number_masked ?: '•••• ' . substr($a->uuid, -4) }}
Name
{{ $a->account_name }}
Currency
{{ $a->currency }}
@if($a->interest_rate > 0)
Interest
{{ number_format($a->interest_rate, 2) }}%
@endif
Current Balance
{{ fmtCurrency($a->current_balance, $a->currency) }}
@if($canEdit && $a->user_id == $user->id)
@endif
@endforeach
@endif {{-- Credit Cards --}} @if($creditCards->isNotEmpty())
Credit Cards
@foreach($creditCards as $a) @php $util = $a->credit_limit > 0 ? ($a->current_balance / $a->credit_limit) * 100 : 0; $accSymbol = getCurrencySymbol($a->currency); $dueDay = (int)$a->due_day; $todayDay = (int)now()->day; $isLate = $dueDay > 0 && $dueDay < $todayDay && $a->current_balance > 0; $utilClass = $util >= 80 ? 'high' : ($util >= 50 ? 'medium' : 'low'); $avail = $a->credit_limit - $a->current_balance; @endphp
CREDIT CARD
{{ $a->financial_institution ?: 'Credit Card' }}
Card Number
{{ $a->account_number_masked ?: '•••• ' . substr($a->uuid, -4) }}
Name
{{ $a->account_name }}
Currency
{{ $a->currency }}
Limit
{{ fmtCurrency($a->credit_limit, $a->currency) }}
Utilization{{ number_format($util, 1) }}%
Balance
{{ fmtCurrency($a->current_balance, $a->currency) }}
Available
{{ fmtCurrency($avail, $a->currency) }}
@if($dueDay > 0)
Due Day: Every {{ $dueDay }}{{ $isLate ? 'LATE' : '' }}
@endif
Cash Adv: {{ $a->cash_advance_fee_percent ?? 3 }}% + {{ fmtCurrency($a->cash_advance_fee_fixed ?? 5, $a->currency) }} Late: {{ $a->late_payment_fee ?? 5 }}% + {{ fmtCurrency($a->late_payment_fee_fixed ?? 25, $a->currency) }}{{ $isLate ? ' (APPLIES)' : '' }}
@if($canEdit && $a->user_id == $user->id)
@endif
@endforeach
@endif {{-- Loans --}} @if($loans->isNotEmpty())
Loans & Mortgages
@foreach($loans as $a)
{{ strtoupper($a->account_type) }}
{{ $a->financial_institution ?: 'Lender' }}
Loan Number
{{ $a->account_number_masked ?: '•••• ' . substr($a->uuid, -4) }}
Name
{{ $a->account_name }}
Currency
{{ $a->currency }}
Interest
{{ number_format($a->interest_rate, 2) }}%
Remaining Balance
{{ fmtCurrency($a->current_balance, $a->currency) }}
@if($canEdit && $a->user_id == $user->id)
@endif
@endforeach
@endif {{-- Closed Accounts --}} @if($closedAccounts->isNotEmpty())
Closed Accounts
@foreach($closedAccounts as $a)
{{ strtoupper($a->account_type) }}
{{ $a->financial_institution ?: 'Closed' }}
Name
{{ $a->account_name }}
@if($a->closed_at)
Closed
{{ \Carbon\Carbon::parse($a->closed_at)->format('M j, Y') }}
@endif
Final Balance
{{ fmtCurrency($a->current_balance, $a->currency) }}
@if($canEdit && $a->user_id == $user->id)
@endif
@endforeach
@endif @if($assets->isEmpty() && $creditCards->isEmpty() && $loans->isEmpty())

No accounts yet. Add your first account above.

@endif {{-- PAYMENT MODAL --}} {{-- CASH ADVANCE MODAL --}} {{-- DEPOSIT MODAL --}} {{-- EDIT MODAL --}} @endsection