@php $org = auth()->user()->organization ?? \App\Models\System\Organization::find(auth()->user()->organization_id); @endphp @extends('documents.procurement._layout', [ 'documentTitle' => 'Spend by Supplier', 'reference' => null, 'documentDate' => $reportDate, 'noAutoPrint' => true, ]) @section('header-meta')
Period: {{ $from->format('d M Y') }}{{ $until->format('d M Y') }}
Currency: {{ $currency }}
@endsection @section('content') @php $grandInvoiced = $rows->sum('total_invoiced'); $grandPaid = $rows->sum('total_paid'); $grandBalance = $grandInvoiced - $grandPaid; @endphp {{-- Summary strip --}}
Suppliers
{{ $rows->count() }}
Total Invoiced
{{ number_format($grandInvoiced, 0) }}
Total Paid
{{ number_format($grandPaid, 0) }}
Outstanding
{{ number_format($grandBalance, 0) }}
@if($rows->isEmpty())

No invoices found for this period.

@else @foreach($rows as $row) @php $balance = (float)$row->total_invoiced - (float)$row->total_paid; $pct = (float)$row->total_invoiced > 0 ? round((float)$row->total_paid / (float)$row->total_invoiced * 100, 1) : 0; $rowClass = $balance > 0 ? 'bg-amber' : 'bg-green'; @endphp @endforeach
Supplier Invoices Total Invoiced ({{ $currency }}) Total Paid ({{ $currency }}) Outstanding ({{ $currency }}) % Paid
{{ $row->supplier?->name ?? '—' }} {{ $row->invoice_count }} {{ number_format((float)$row->total_invoiced, 2) }} {{ number_format((float)$row->total_paid, 2) }} {{ number_format($balance, 2) }} {{ $pct }}%
TOTAL {{ $rows->sum('invoice_count') }} {{ number_format($grandInvoiced, 2) }} {{ number_format($grandPaid, 2) }} {{ number_format($grandBalance, 2) }}
@endif @endsection