@php $typeBadge = ['fixed' => 'sky', 'variable' => 'amber']; // Nav-tab icons for the three tables: the ledger, the overhead-nut analysis, // and payables (supplier bills). $tabIcon = [ 'all' => 'receipt-percent', 'overheads' => 'building-office', 'bills' => 'document-text', ]; // Supplier-bill status → badge colour. $billBadge = [ 'draft' => 'slate', 'awaiting_payment' => 'amber', 'partial' => 'sky', 'paid' => 'emerald', 'cancelled' => 'rose', ]; $costTypeBadge = ['overhead' => 'indigo', 'direct' => 'amber', 'none' => 'slate']; $sourceLabels = [ 'recurring' => __('Recurring expenses'), 'payroll' => __('Payroll'), 'fixed' => __('Fixed operating costs'), ]; @endphp
{{-- Cashflow segmented control: Income (in) / Expenses (out). These two share one "Cashflow" sidebar entry; the toggle is how you move between them. --}} @if ($canManageCategories) {{ __('Categories') }} @endif @if ($canManage) {{ __('New Expense') }} @endif {{-- Comprehensive period filter, drives every card and table below --}}

{{ __('Reporting period') }}

{{ $periodLabel }}

@foreach ($periods as $key => $label) @endforeach
@if ($period === 'custom')
–
@endif
{{-- KPI cards, expense-focused, ordered left→right by priority. Money value locked at 19px per spec; single scrolling row like the Treasury page. --}}
@foreach ($metrics as $m) @php $tone = $m['delta'] === null ? 'muted' : (($m['delta'] >= 0) === $m['up_is_good'] ? 'up' : 'down'); $pill = ['up' => 'bg-emerald-50 text-emerald-700', 'down' => 'bg-rose-50 text-rose-700', 'muted' => 'bg-slate-100 text-slate-500'][$tone]; @endphp

{{ $m['label'] }}

{{ $m['value'] }}

@if ($m['delta'] !== null) {{ number_format(abs($m['delta']), 0) }}% @endif {{ $m['sub'] }}
@endforeach
{{-- ===================== WAITING TO BE POSTED ===================== Recurring instructions (rent, salaries, subscriptions) that have fallen due. BillPro used to turn these into real expenses overnight, on its own. It does not any more: nothing below is in the ledger, and nothing goes in until somebody posts it here. --}} @if (! empty($dueTemplates))

{{ __('Waiting to be posted') }} {{ count($dueTemplates) }}

{{ __('Recurring costs that have fallen due. None of these are in the ledger yet, they are posted only when you say so.') }}

@foreach ($dueTemplates as $due) @endforeach
{{ __('Cost') }} {{ __('Frequency') }} {{ __('Due since') }} {{ __('Paid from') }} {{ __('Usual amount') }} {{ __('Actions') }}
{{ $due['label'] }} @if ($due['detail'] !== '') {{ $due['detail'] }} @endif {{ $due['frequency'] }} {{ $due['due_on'] }} @if ($due['periods'] > 1) {{ trans_choice(':count period outstanding|:count periods outstanding', $due['periods'], ['count' => $due['periods']]) }} @endif {{ $due['account'] ?: __('Not set') }} {{ $due['currency'] }} {{ number_format($due['amount'], 2) }}
@endif {{-- Tabbed tables: the ledger holds every recorded expense; the other tabs are analysis (Overheads nut) and payables (Supplier Bills) --}}
@foreach ($tabs as $key => $label) @endforeach
{{-- ============================== ALL EXPENSES ============================== --}} @if ($tab === 'all')
{{ __('Export') }}
{{-- Unified ledger: operating expenses + job costs + depreciation, counted once each --}}
@forelse ($ledger as $row)

{{ \Illuminate\Support\Str::limit($row['description'], 32) }}

{{ $row['class_label'] }} {{ $row['category'] }}

{{ $base }} {{ number_format($row['base_amount'], 2) }}

{{ $row['date'] ?: '—' }}{{ $row['ref'] ? ' · '.$row['ref'] : '' }}

@if ($row['editable'])
@if ($canManage) @endif @if ($canDelete) @endif
@endif
@empty
@if ($canManage) {{ __('New Expense') }} @endif
@endforelse
{{ __('Rows per page') }}
{{ $ledger->links() }}
@endif {{-- ============================== OVERHEADS ============================== --}} @if ($tab === 'overheads')

{{ __('Overheads') }}

{{ __('The monthly nut break-even must clear, recurring costs classified as overhead, plus payroll and depreciation.') }}

@foreach ($overhead['source'] as $src) {{ $sourceLabels[$src] ?? ucfirst($src) }} @endforeach

{{ __('Monthly overheads') }}

{{ $overhead['base'] }} {{ number_format($overhead['monthly'], 2) }}

{{ __('Recurring') }} {{ $overhead['base'] }} {{ number_format($overhead['recurring'], 2) }} @if (in_array('payroll', $overhead['source'], true)) · {{ __('Payroll') }} {{ $overhead['base'] }} {{ number_format($overhead['payroll'], 2) }} @endif

@if ($canManageCategories) {{ __('Classify categories') }} @endif
@forelse ($overhead['rows'] as $row) @empty @endforelse
{{ __('Overhead') }} {{ __('Frequency') }} {{ __('Daily rate') }} {{ __('Monthly (:base)', ['base' => $overhead['base']]) }}
{{ $row['label'] }} {{ $row['frequency'] }} @if (! is_null($row['daily_rate'])) {{ $overhead['base'] }} {{ number_format($row['daily_rate'], 2) }}/{{ __('day') }} @if ($row['daily_basis'] === 'calendar') {{ trans_choice(':count calendar day|:count calendar days', (int) $row['days'], ['count' => (int) $row['days']]) }} @elseif ($row['daily_basis'] === 'working') {{ trans_choice(':count working day|:count working days', (int) $row['days'], ['count' => (int) $row['days']]) }} @else {{ trans_choice(':count day|:count days', (int) $row['days'], ['count' => rtrim(rtrim(number_format((float) $row['days'], 1), '0'), '.')]) }} @endif @else — @endif {{ $overhead['base'] }} {{ number_format($row['monthly_base'], 2) }}
@endif {{-- ============================== SUPPLIER BILLS ============================== --}} @if ($tab === 'bills')

{{ __('Supplier Bills') }}

{{ __('Accounts payable raised this period. Manage bills and payments on Purchasing.') }}

{{ __('Billed') }}

{{ $supplierBills['base'] }} {{ number_format($supplierBills['total'], 2) }}

{{ __('Outstanding') }}

{{ $supplierBills['base'] }} {{ number_format($supplierBills['outstanding'], 2) }}

{{ __('Purchasing') }}
@forelse ($supplierBills['rows'] as $bill) @empty @endforelse
{{ __('Bill #') }} {{ __('Supplier') }} {{ __('Bill date') }} {{ __('Due') }} {{ __('Status') }} {{ __('Total') }} {{ __('Balance') }}
{{ $bill['number'] }} {{ $bill['supplier'] }} {{ $bill['date'] ?: '—' }} @if ($bill['due']) {{ $bill['due'] }} @else — @endif {{ $bill['status_label'] }} {{ $bill['currency'] }} {{ number_format($bill['total'], 2) }} {{ $bill['currency'] }} {{ number_format($bill['balance'], 2) }}
@endif
{{ $editingId ? __('Edit Expense') : __('New Expense') }}

{{ __('Link to a job to count this as a direct cost of that job (added to its profit). Leave blank for a general company expense.') }}

{{-- Marketing spend can be booked to a campaign (CRM, D13). --}} @if ($campaigns->isNotEmpty())

{{ __('The campaign shows this as its actual spend. Only Marketing expenses can be linked.') }}

@endif
@if ($fundAccounts->isEmpty())

{{ __('No fund accounts yet, create one under Treasury first.') }}

@else

{{ __('Which account this money comes out of. Must match the currency above.') }}

@endif

{{ __('Bank/EcoCash fee to send this payment. Booked as a separate "Bank Charges" expense so the fee leaves the account and shows in your P&L. Leave blank if none.') }}

@if ($is_recurring)
@endif
{{-- Daily-rate basis (§15): spread an overhead's monthly cost across a chosen days-worked divisor. --}}

{{ __('Daily rate = monthly amount ÷ days worked. Shown on the overheads panel.') }}

@if ($daily_rate_basis === 'custom')
@endif
{{ __('Cancel') }} {{ __('Save') }}
{{ __('Expense Categories') }}

{{ $editingCategoryId ? __('Edit Category') : __('Add Category') }}

{{ $editingCategoryId ? __('Update') : __('Add') }} @if ($editingCategoryId) @endif
@if ($categories->isNotEmpty())
@foreach ($categories as $category)
{{ $category->name }} {{ $category->type }} @if (($category->cost_type ?? 'none') !== 'none') {{ $category->cost_type === 'overhead' ? __('Overhead') : __('Direct') }} @endif @unless ($category->is_active) {{ __('Inactive') }} @endunless
@endforeach
@else

{{ __('No categories yet. Add one above.') }}

@endif
{{ __('Done') }}
{{ __('Classify categories') }}

{{ __('Set how each category is treated in the break-even nut. Overheads count toward the monthly nut; direct costs belong to a job.') }}

@if (! empty($overhead['categories']))
@foreach ($overhead['categories'] as $cat)
{{ $cat['name'] }} @if ($cat['monthly'] > 0) {{ $overhead['base'] }} {{ number_format($cat['monthly'], 2) }}/{{ __('mo') }} {{ __('to the nut') }} @endif @if ($canManageCategories) @else {{ ucfirst($cat['cost_type']) }} @endif
@endforeach
@else

{{ __('No categories yet.') }}

@endif
{{ __('Done') }}
@php $posting = collect($dueTemplates)->firstWhere('id', $postingId); @endphp {{ $posting ? __('Post :label', ['label' => $posting['label']]) : __('Post recurring cost') }}

{{ __('This records the cost in the ledger and takes the money out of the account you choose. Nothing is posted until you confirm here.') }}

{{ __('Correct it if this period was different from the standing amount.') }}

{{ __('The account the money actually left. It must hold the same currency as the cost.') }}

@if ($posting && $posting['periods'] > 1) @endif
{{ __('Cancel') }} {{ __('Post expense') }} {{ __('Posting...') }}