@extends('layouts.app') @section('title', 'Invoices') @section('section', 'Sales') @php $cur = config('payments.currency'); $dp = \App\Payments\Support\Currency::decimals($cur); $fmt = fn ($n) => number_format((float) $n, $dp); $tabs = ['all' => 'All', 'due' => 'Unpaid', 'partial' => 'Partial', 'paid' => 'Paid']; $pill = [ 'paid' => ['pill-ok', 'Paid'], 'partial' => ['pill-warn', 'Partial'], 'due' => ['pill-off', 'Unpaid'], ]; @endphp @section('content')

Sales

Invoices

Outstanding

{{ $cur }}{{ $fmt($summary['outstanding']) }}

Open invoices

{{ $summary['open'] }}

Collected

{{ $cur }}{{ $fmt($summary['collected']) }}
@foreach ($tabs as $key => $label) {{ $label }}{{ $counts[$key] }} @endforeach
@if ($sales->isEmpty())
— NO ENTRIES —

@if ($q !== '' || $status !== 'all') Nothing matches this view. Clear filters. @else Invoices will appear here as you make sales. @endif

@else
Invoice
Customer
Date
Due
Status
@foreach ($sales as $sale) @php [$cls, $label] = $pill[$sale->payment_status] ?? ['pill-off', ucfirst($sale->payment_status)]; @endphp
{{ $sale->invoice_no }} Total {{ $cur }} {{ $fmt($sale->total) }}
{{ optional($sale->contact)->name ?? 'Walk-in customer' }}
{{ \Illuminate\Support\Carbon::parse($sale->sale_date)->format('d M Y') }}
{{ (float) $sale->due_amount > 0 ? $cur.' '.$fmt($sale->due_amount) : '—' }}
{{ $label }}
@endforeach
@if ($sales->hasPages()) @endif @endif @endsection