@php $money = fn ($v) => number_format((float) $v, 2); $pct = fn ($v) => rtrim(rtrim(number_format((float) $v, 2), '0'), '.'); $cards = [ ['key' => 'available', 'label' => __('Available to Spend'), 'icon' => 'banknotes', 'chip' => 'bg-emerald-50 text-emerald-600', 'hint' => __('Collected accruals − spend')], ['key' => 'pending', 'label' => __('Pending Collection'), 'icon' => 'clock', 'chip' => 'bg-amber-50 text-amber-600', 'hint' => __('Accrued, invoice not yet paid')], ['key' => 'spent', 'label' => __('Total Spent'), 'icon' => 'receipt-percent', 'chip' => 'bg-violet-50 text-violet-600', 'hint' => __('Marketing-category expenses')], ['key' => 'accrued', 'label' => __('Total Accrued'), 'icon' => 'arrow-trending-up', 'chip' => 'bg-indigo-50 text-indigo-600', 'hint' => __('All marketing earmarks to date')], ]; @endphp
{{-- Header --}} {{ __('Settings') }} {{-- Tabs --}}
@if ($tab === 'overview') {{-- Allocation rate banner --}}

{{ __('Current allocation rate') }}

{{ $pct($stats['rate']) }}% {{ __('of each completed job\'s gross profit') }}

{{ __('This month') }}: +{{ $baseCode }} {{ $money($stats['accrued_this_month']) }} {{ __('accrued') }} · −{{ $baseCode }} {{ $money($stats['spent_this_month']) }} {{ __('spent') }}
{{-- Headline stat cards --}}
@foreach ($cards as $card) @php $value = $baseCode . ' ' . $money($stats[$card['key']]); @endphp

{{ $card['label'] }}

{{ $value }}

{{ $card['hint'] }}

@endforeach
{{-- Accrued vs spent trend --}}

{{ __('Fund movement') }}

{{ __('Accrued vs spent each month, with the cumulative fund balance.') }}

@else {{-- Ledger --}}

{{ __('Marketing ledger') }}

{{ __('Credits (job accruals) and debits (marketing spend), newest first.') }} @if ($ledgerTotal > $ledger->count()) {{ __('Showing the latest :n of :total.', ['n' => $ledger->count(), 'total' => $ledgerTotal]) }} @endif

@forelse ($ledger as $row) @empty @endforelse
{{ __('Date') }} {{ __('Entry') }} {{ __('Amount') }} {{ __('Balance') }}
{{ optional($row['date'])->format('d M Y') ?? '—' }}
$row['type'] === 'credit', 'bg-rose-50 text-rose-600' => $row['type'] === 'debit', ])>

{{ $row['label'] }}

@if ($row['detail'])

{{ \Illuminate\Support\Str::limit(strip_tags($row['detail']), 60) }}

@endif
@if ($row['status'] === \App\Models\MarketingAllocation::PENDING) {{ __('Pending') }} @elseif ($row['status'] === \App\Models\MarketingAllocation::AVAILABLE) {{ __('Available') }} @endif
{{ $row['type'] === 'credit' ? '+' : '−' }}{{ $baseCode }} {{ $money($row['amount']) }} {{ $baseCode }} {{ $money($row['balance']) }}
@endif