@php
use App\Support\InvoiceDomain;
$ledgerSimulationStatuses = [
'Invoice approved.',
'Invoice paid from mandate earnings.',
'Payment request submitted. Company treasury will process settlement.',
'Reimbursement claim approved and posted.',
];
$suppressPayablesLedgerSim = session('status') && in_array(session('status'), $ledgerSimulationStatuses, true);
$statusLabel = static function (string $status): string {
return match ($status) {
'received' => 'Pending',
'under_review' => 'Processing',
'approved' => 'Approved · ready to pay',
'payment_requested' => 'Processing',
'treasury_settlement_pending' => 'Processing',
'partially_paid' => 'Processing',
'scheduled' => 'Scheduled',
'overdue' => 'Restricted',
'paid' => 'Paid',
'disputed' => 'Restricted',
default => ucfirst(str_replace('_', ' ', $status)),
};
};
$invoiceRows = $operationalInvoices->concat($earningsInvoices)->map(function ($i) use ($statusLabel): array {
$meta = $i->meta ?? [];
$issuer = $meta['issuer_display'] ?? $i->counterparty?->name ?? '—';
$categoryLabel = $meta['category_label'] ?? ucwords(str_replace('_', ' ', (string) $i->category));
return [
'id' => $i->id,
'invoice_number' => $i->invoice_number,
'invoice_domain' => $i->invoice_domain,
'domain_label' => InvoiceDomain::label($i->invoice_domain),
'issuer' => $issuer,
'category_label' => $categoryLabel,
'category_code' => $i->category,
'amount' => round((float) $i->amount, 2),
'status' => $i->status,
'status_label' => $statusLabel($i->status),
'is_paid' => $i->status === 'paid',
'account_details' => is_array($meta['account_details'] ?? null) ? $meta['account_details'] : [],
'payment_reference' => $meta['payment_reference'] ?? null,
'due_date' => $i->due_date?->format('Y-m-d'),
'voyage_line' => $i->voyage_id ? 'Voyage #'.$i->voyage_id : null,
'hospital_context' => data_get($meta, 'hospital_payment_context'),
'line_items' => is_array($meta['line_items'] ?? null) ? $meta['line_items'] : [],
'can_approve' => in_array($i->status, ['received', 'under_review'], true),
'can_pay_earnings' => $i->invoice_domain === InvoiceDomain::EARNINGS_PAYABLE
&& in_array($i->status, ['approved', 'scheduled', 'overdue'], true),
'can_submit_operational_request' => $i->invoice_domain === InvoiceDomain::OPERATIONAL_PAYABLE && $i->status === 'approved',
'approve_url' => route('invoices.approve', $i),
'pay_url' => route('invoices.pay', $i),
'submit_payment_request_url' => route('invoices.submit-payment-request', $i),
'attachment_download_url' => filled(data_get($meta, 'governance_attachment_path'))
? route('invoices.governance-attachment', $i)
: null,
];
})->values()->all();
@endphp
@include('partials.head-meta', ['pageTitle' => 'Invoice queue'])
@include('partials.ledger-settlement-simulation-script')
@include('partials.desktop-required-notice')
@include('partials.workspace-lg-only-wrap-start')
@include('partials.activity-drawer')
@include('partials.workspace-shell-operator-chrome')
@include('partials.control-preview-shell-banner')
@include('partials.stripe-powered-financial-rail', ['class' => 'max-w-xl'])
@if (session('status') && ! $suppressPayablesLedgerSim)
{{ session('status') }}
@endif
@if ($errors->has('invoice'))
{{ $errors->first('invoice') }}
@endif
Operational / company payables
Request company treasury settlement. Does not debit mandate earnings allocation.
@forelse($operationalInvoices as $invoice)
@php
$badge = \App\Support\InvoiceDomain::label($invoice->invoice_domain);
$badgeClass = 'bg-slate-50 text-slate-800 border-slate-200';
@endphp
@empty
No operational invoices in queue.
@endforelse
Earnings-domain payables
Debit mandate earnings when processed. Affects withdrawable balance and settlement history.
@forelse($earningsInvoices as $invoice)
@php
$badge = \App\Support\InvoiceDomain::label($invoice->invoice_domain);
$badgeClass = 'bg-violet-50 text-violet-800 border-violet-200';
@endphp
@empty
No earnings-domain invoices in queue.
@endforelse
This invoice is paid. Totals and mandate balance elsewhere reflect this settlement.
Select an action. You will review the impact on the next step before anything is posted.
@include('partials.task-queue-ledger-simulation-overlay')
@include('partials.workspace-lg-only-wrap-end')