@php // 1 credit == 1 money-minor in the money wallet, so every ledger // amount is a real money value: divide by 100 and format with the // workspace currency (never hardcode a symbol). $money = fn ($minor) => \App\Support\FormatSettings::display((int) $minor / 100); $curSym = \App\Support\FormatSettings::currencyFor()?->symbol; $csvQs = http_build_query(array_filter([ 'type' => ($filters['type'] ?? 'all') !== 'all' ? $filters['type'] : null, 'from' => $filters['from'] ?? null, 'to' => $filters['to'] ?? null, 'q' => $filters['q'] ?? null, ])); @endphp
{{-- Header --}}
{{ __('Wallet') }} /{{ __('Statement') }}

{{ __('Wallet statement') }}

{{ __('Every dollar that entered or left your wallet — top-ups, message charges, refunds and affiliate earnings.') }}

{{-- Summary cards --}}
{{ __('Current balance') }}
{!! $money((int) round(((int) ($authUser->wallet_credits ?? 0)) * \App\Services\MessageCreditRate::minorPerCredit())) !!}
{{ __('Available to spend') }}
{{ __('Money in') }}
+{!! $money($summary['in']) !!}
{{ __('Top-ups, refunds & earnings') }}
{{ __('Money out') }}
−{!! $money($summary['out']) !!}
{{ __('Spent on messages') }}
{{ __('Net movement') }}
{{ $summary['net'] >= 0 ? '+' : '−' }}{!! $money(abs($summary['net'])) !!}
{{ $summary['count'] }} {{ __('transactions in view') }}
{{-- Filters --}}
{{ __('Reset') }}
{{-- Ledger --}}
@if ($rows->total() === 0)
@include('user.partials.empty-state', [ 'message' => __('No transactions match these filters. Try widening the date range or clearing the search.'), 'resetHref' => route('user.account.wallet.statement'), ])
@else
@foreach ($rows as $tx) @php $amt = (int) $tx->amount; $isIn = $amt > 0; $badge = [ 'topup' => 'bg-wa-mint border border-wa-green/30 text-wa-deep', 'earn' => 'bg-wa-mint border border-wa-green/30 text-wa-deep', 'refund' => 'bg-accent-amber/15 border border-accent-amber/40 text-ink-800', 'spend' => 'bg-paper-50 border border-paper-200 text-ink-700', 'admin_adjust' => 'bg-paper-50 border border-paper-200 text-ink-700', ][$tx->type] ?? 'bg-paper-50 border border-paper-200 text-ink-700'; $typeLabel = [ 'topup' => __('Top-up'), 'earn' => __('Earning'), 'refund' => __('Refund'), 'spend' => __('Message charge'), 'admin_adjust' => __('Adjustment'), ][$tx->type] ?? $tx->type; @endphp @php // Per-message charge detail (only spend rows have one). $charge = $charges[$tx->id] ?? null; $ctx = ($charge && $charge->wamid) ? ($contexts[$charge->wamid] ?? null) : null; $channelLabels = [ 'campaign' => __('Campaign'), 'broadcast' => __('Broadcast'), 'flow' => __('Flow / Chatbot'), 'scheduled' => __('Scheduled'), 'autoreply' => __('Auto-reply'), 'chat' => __('Team Inbox / Chat'), 'api' => __('API'), ]; $engineLabels = [ 'waba' => __('WhatsApp Cloud'), 'baileys' => __('WhatsApp'), 'twilio' => __('Twilio'), ]; @endphp @endforeach
{{ __('Date') }} {{ __('Description') }} {{ __('Type') }} {{ __('Money in') }} {{ __('Money out') }} {{ __('Balance') }}
{{ optional($tx->created_at)->format('M d, Y · H:i') }}
{{ $tx->description ?: ucfirst(str_replace('.', ' ', $tx->source ?? 'transaction')) }}
@if ($ctx)
@if (!empty($ctx['name']))
{{ $ctx['channel'] }}: {{ $ctx['name'] }}
@endif @if (!empty($ctx['recipient']))
{{ __('To') }}: {{ $ctx['recipient'] }}
@endif @if (!empty($ctx['template']))
{{ __('Template') }}: {{ $ctx['template'] }}
@endif
@endif @if ($charge)
@if ($charge->source && isset($channelLabels[$charge->source])) {{ $channelLabels[$charge->source] }} @endif @if ($charge->to_country) {{ $charge->to_country }} @endif @if ($charge->category) {{ $charge->category }} @endif @if ($charge->provider && isset($engineLabels[$charge->provider])) {{ $engineLabels[$charge->provider] }} @endif
@endif
{{ $typeLabel }} {!! $isIn ? '+' . $money($amt) : '—' !!} {!! !$isIn && $amt !== 0 ? '−' . $money(abs($amt)) : '—' !!} {!! $money($tx->balance_after) !!}
@if ($rows->hasPages())
{{ __('Page') }} {{ $rows->currentPage() }} {{ __('of') }} {{ $rows->lastPage() }} · {{ number_format($rows->total()) }} {{ __('total') }}
@if ($rows->onFirstPage()) {{ __('Prev') }} @else {{ __('Prev') }} @endif @if ($rows->hasMorePages()) {{ __('Next') }} @else {{ __('Next') }} @endif
@endif @endif