@extends('layouts.app') @section('title', 'Invoice ' . $invoice->invoice_number) @section('content') @php $sv = $invoice->status instanceof \App\Enums\InvoiceStatus ? $invoice->status->value : $invoice->status; $symbol = $invoice->currency instanceof \App\Enums\Currency ? $invoice->currency->symbol() : (string) $invoice->currency; $isOverdue = $invoice->due_date->isPast() && $sv === 'unpaid'; $remaining = $invoice->remainingAmount(); $invoice->loadMissing('payments'); $payments = $invoice->payments->sortByDesc('paid_at'); $totalPaid = $payments->reduce(fn ($carry, $p) => bcadd($carry, (string) $p->amount, 2), '0'); $paidPct = bccomp((string) $invoice->amount, '0', 2) > 0 ? min(100, max(0, (int) bcmul(bcdiv($totalPaid, (string) $invoice->amount, 4), '100', 0))) : 0; $badgeClass = match($sv) { 'unpaid' => 'bg-amber-50 text-amber-700', 'partial' => 'bg-sky-50 text-sky-700', 'paid' => 'bg-emerald-50 text-emerald-700', default => 'bg-slate-100 text-slate-600', }; $badgeLabel = match($sv) { 'unpaid' => 'Unpaid', 'partial' => 'Partial Payment', 'paid' => 'Paid in Full', default => ucfirst($sv), }; $progressColor = match($sv) { 'paid' => 'bg-emerald-500', 'partial' => 'bg-sky-600', default => 'bg-slate-300', }; $paymentMethods = \App\Enums\PaymentMethod::cases(); $currencies = \App\Enums\Currency::cases(); @endphp
Invoice Amount
{{ $symbol }} {{ number_format($invoice->amount, 2) }}
Also shown as · Rates updated daily
Source: exchangerate-api.com · Updated daily
Linked Proposal
Payments
{{ $symbol }} {{ number_format($totalPaid, 2) }} of {{ $symbol }} {{ number_format($invoice->amount, 2) }}
{{ (int) $paidPct }}% paid
{{-- Payment list --}} @if ($payments->isEmpty())No payments recorded yet
@else{{ $pmSymbol }} {{ number_format($payment->amount, 2) }}
{{ $pmLabel }} · {{ \Carbon\Carbon::parse($payment->paid_at)->format('d M Y') }}
@if ($payment->notes){{ $payment->notes }}
@endif @if ($payment->payment_currency && $payment->payment_currency !== $payment->currency)Paid: {{ $payment->payment_currency->symbol() }} {{ number_format($payment->payment_amount, 2) }} @ {{ number_format($payment->exchange_rate, 4) }}
@endifRecord Payment