@php $base = $pack['base']; $money = fn (float $v) => $base . ' ' . number_format($v, 2); // Signed money for the bridge steps: the sign IS the information there. $signed = fn (float $v) => ($v >= 0 ? '+ ' : '− ') . $base . ' ' . number_format(abs($v), 2); $income = $pack['income']; $bridge = $pack['bridge']; $profit = $pack['profit']; $cash = $pack['cash']; $equity = $pack['equity']; // Headline strip. Deliberately shows BOTH revenue definitions side by side: // seeing them next to each other is what stops the "the system is wrong" // conversation before it starts. $metrics = [ ['label' => __('Gross Sales'), 'value' => $money($income['gross_sales']), 'icon' => 'document-currency-dollar', 'accent' => '#3b6fa0', 'sub' => __('Invoiced this month')], ['label' => __('Cash Collected'), 'value' => $money($profit['cash_collected']), 'icon' => 'banknotes', 'accent' => '#10b981', 'sub' => __('Management revenue')], ['label' => __('Gross Profit'), 'value' => $money($profit['gross_profit']), 'icon' => 'scale-balance', 'accent' => '#7c3aed', 'sub' => number_format($profit['gross_margin_pct'], 1) . '% ' . __('margin')], ['label' => __('Net Profit'), 'value' => $money($profit['net_profit']), 'icon' => 'chart-pie', 'accent' => $profit['net_profit'] >= 0 ? '#0ea5e9' : '#f43f5e', 'sub' => number_format($profit['net_margin_pct'], 1) . '% ' . __('margin')], ['label' => __('Closing Cash'), 'value' => $money($cash['closing']), 'icon' => 'wallet', 'accent' => '#f59e0b', 'sub' => $cash['source'] === 'snapshot' ? __('Frozen at close') : __('Live from treasury')], ]; $snapshot = $pack['snapshot']; $isClosed = $pack['is_closed']; $isReopened = $snapshot && ! $isClosed && $snapshot->reopened_at !== null; @endphp
{{ __('Preview') }} {{ __('Download PDF') }} {{-- Month picker + the locked / open state of the period it belongs to. --}}

{{ __('Reporting month') }}

{{ $pack['period']['label'] }}

{{-- Locked-month watermark. A closed month's figures are frozen; an open one is still moving under your feet, and the pack must say which. --}} @if ($isClosed)

{{ __('Period closed, figures are final') }}

{{ __('Closed by :who on :when.', [ 'who' => $snapshot->closer?->name ?? __('the system'), 'when' => optional($snapshot->locked_at)->timezone(config('app.display_timezone'))->format('j M Y, H:i') ?? '—', ]) }} {{ __('The cash block below is read from the frozen snapshot, not recomputed.') }}

{{ __('Locked') }}
@elseif ($isReopened)

{{ __('Period reopened for a correction') }}

{{ __('Reopened by :who: “:reason”. Figures are live again and will change until the month is closed a second time.', [ 'who' => $snapshot->reopener?->name ?? __('an administrator'), 'reason' => $snapshot->reopen_reason ?: __('no reason given'), ]) }}

{{ __('Reopened') }}
@else

{{ __('Period still open, figures are provisional') }}

{{ __('Anything back-dated into this month still changes these numbers. Close the month to freeze them.') }}

{{ __('Open') }}
@endif {{-- Headline strip --}}
@foreach ($metrics as $m)

{{ $m['label'] }}

{{ $m['value'] }}

{{ $m['sub'] }}
@endforeach
{{-- ══ THE BRIDGE ══════════════════════════════════════════════════════ The most important block on the page. "Gross Sales" on the directors' spreadsheet means invoiced value; the system's headline revenue is cash collected. Both are right. Showing the walk between them turns a recurring "the system disagrees with my sheet" argument into a two-line explanation. --}}

{{ __('Gross Sales → Cash Collected') }}

{{ __('Two different questions, two correct answers. "Gross Sales" is what you invoiced this month; "Cash Collected" is what actually reached the bank, and it is the figure every profit number on this page is built on.') }}

{{ __('Gross Sales (invoiced)') }}

{{ __('Total value of invoices raised in :month.', ['month' => $pack['period']['label']]) }}

{{ $money($bridge['gross_sales']) }}

@forelse ($bridge['steps'] as $step)

{{ $step['label'] }}

{{ $step['hint'] }}

{{ $signed($step['amount']) }}

@empty
{{ __('Nothing to reconcile: every invoice raised this month was collected in full within it.') }}
@endforelse

{{ __('Cash Collected (management revenue)') }}

{{ __('The revenue basis used by the reports, the profit figures and commission.') }}

{{ $money($bridge['cash_collected']) }}

@if (abs($bridge['residual']) >= 0.01) {{-- Should be unreachable: the walk is derived so it lands on the engine's figure by construction. If it ever fires, the pack says so out loud rather than showing a bridge that does not bridge. --}}

{{ __('Unreconciled difference, please report this') }}

{{ $money($bridge['residual']) }}

@endif
{{-- ══ 1 · INCOME ═════════════════════════════════════════════════════ --}}
@if ($income['refunds_paid'] > 0) @endif
{{-- ══ 2 · EXPENSES ═══════════════════════════════════════════════════ --}}
@foreach ($pack['expenses']['lines'] as $line) @endforeach
{{ __('Line') }} {{ __('Categories included') }} {{ __('Amount') }}
{{ $line['label'] }} {{ $line['categories'] ? implode(', ', array_keys($line['categories'])) : '—' }} {{ $money($line['amount']) }}
{{ __('Total expenses recorded') }} {{ $money($pack['expenses']['total']) }}

{{ __('This total will not equal the costs in the Profit block. The profit and loss takes production cost from the job cost ledger and overheads from the agreed monthly run rate, while this table is simply every expense keyed against the month. They answer different questions on purpose.') }}

{{-- ══ 3 · PROFIT ═════════════════════════════════════════════════════ --}}
@if ($profit['other_opex'] != 0.0) @endif @if ($profit['cancelled_costs'] != 0.0) @endif
{{-- ══ 4 · CASH ═══════════════════════════════════════════════════════ --}}
@foreach ([ ['label' => __('Opening Cash'), 'value' => $cash['opening'], 'tone' => 'text-slate-900'], ['label' => __('Cash In'), 'value' => $cash['in'], 'tone' => 'text-emerald-600'], ['label' => __('Cash Out'), 'value' => $cash['out'], 'tone' => 'text-rose-600'], ['label' => __('Closing Cash'), 'value' => $cash['closing'], 'tone' => 'text-slate-900'], ] as $cell)

{{ $cell['label'] }}

{{ $money($cell['value']) }}

@endforeach
@if (($cash['held_change'] ?? 0) > 0)

{{ __('Of the closing cash, :amount is change held for walk-in customers. It is theirs, it does not expire, and it carries into the next month untouched.', ['amount' => $money($cash['held_change'])]) }}

@endif
{{-- ══ 5 · RECEIVABLES / PAYABLES ═════════════════════════════════════ --}}
@foreach ([ ['key' => 'receivables', 'title' => __('Receivables'), 'sub' => __('What customers still owe you.'), 'icon' => 'arrow-down-tray', 'tone' => 'sky', 'who' => __('Customer')], ['key' => 'payables', 'title' => __('Payables'), 'sub' => __('What you still owe suppliers.'), 'icon' => 'arrow-up-tray', 'tone' => 'orange', 'who' => __('Supplier')], ] as $side) @php $data = $pack[$side['key']]; @endphp

{{ __('Total outstanding') }}

{{ $money($data['grandTotal']) }}

{{ __('Of which overdue') }}

{{ $money($data['overdue']) }}

@foreach ($buckets as $key => $label) @endforeach
{{ __('Ageing') }} {{ __('Amount') }}
{{ $label }}{{ $key === 'current' ? '' : ' ' . __('days') }} {{ $money($data['bucketTotals'][$key]) }}

{{ trans_choice('{0}No open balances.|{1}:count :who with an open balance, as at today.|[2,*]:count :who with open balances, as at today.', $data['counterparties'], [ 'count' => $data['counterparties'], 'who' => \Illuminate\Support\Str::lower($side['who']) . ($data['counterparties'] === 1 ? '' : 's'), ]) }}

@endforeach
{{-- ══ 6 · INVENTORY + 7 · OWNER EQUITY ═══════════════════════════════ --}} {{-- ══ 8 · AUTHORISED ADJUSTMENTS ═════════════════════════════════════ Corrections booked against this month AFTER it was closed. They are shown as an explicit reconciling line, never folded into the frozen figures: a snapshot that quietly changes is not a snapshot. --}} @if ($pack['adjustments']['rows']->isNotEmpty())
@foreach ($pack['adjustments']['rows'] as $adj) @endforeach
{{ __('Account') }} {{ __('Reason') }} {{ __('Approved by') }} {{ __('Effect on profit') }}
{{ $adj->account_label }} {{ $adj->reason }} {{ $adj->approver?->name ?? '—' }} {{ $signed($adj->signedAmount()) }}
{{ __('Net adjustment') }} {{ $signed($pack['adjustments']['net']) }}
@endif

{{ __('All amounts are in :code.', ['code' => $base]) }} {{ __('Receivables, payables and inventory are point in time, as at today; every other figure belongs to :month.', ['month' => $pack['period']['label']]) }}