@extends('layouts.app') @section('title', $invoice->number) @section('content')

๐Ÿงพ {{ $invoice->number }}

{{ $invoice->patient->full_name }} @if($invoice->treatmentPlan) ยท {{ $invoice->treatmentPlan->title }} @endif
{{ $invoice->status->label() }} ๐Ÿ“„ PDF @if($invoice->patient->whatsapp_opt_in && $invoice->status !== \App\Enums\InvoiceStatus::Draft) @can('update', $invoice)
@csrf
@endcan @endif
@if($invoice->status === \App\Enums\InvoiceStatus::Draft) @can('update', $invoice)
@csrf
@csrf
@endcan @endif
{{-- Items --}}
@foreach($invoice->items as $item) @endforeach
{{ __('Description') }}{{ __('Tooth') }}{{ __('Qty') }}{{ __('Amount') }}
{{ $item->description }} {{ $item->tooth ?? 'โ€”' }} {{ $item->qty }} {{ number_format($item->amount) }}
{{ __('Subtotal') }}{{ number_format($invoice->subtotal) }}
{{ __('Discount') }}โˆ’ {{ number_format($invoice->discount_amount) }}
{{ __('Total') }}{{ number_format($invoice->total) }}
{{ __('Paid') }}{{ number_format($invoice->paid_amount) }}
{{ __('Remaining') }} {{ number_format($invoice->remaining()) }}
{{-- Payment history --}}

{{ __('Payments') }}

@forelse($invoice->payments as $p) @empty @endforelse
{{ $p->method->icon() }} {{ $p->method->label() }} @if($p->reference)#{{ $p->reference }}@endif {{ number_format($p->amount) }} {{ $p->paid_at->setTimezone(\App\Support\ClinicTime::timezone())->format('d M Y ยท H:i') }} {{ $p->receiver?->name }}
{{ __('No payments yet.') }}
{{-- Quick payment --}} @if($invoice->status->isOpen()) @can('recordPayment', $invoice)

โšก {{ __('Quick payment') }}

{{ __('Amount is prefilled with the remaining balance โ€” tap a method to record.') }}

@include('invoices._quickpay', ['invoice' => $invoice, 'methods' => $methods])
@endcan @endif {{-- Installments --}}

๐Ÿ’ฐ {{ __('Installments') }}

@if($invoice->installments->isEmpty()) @if($invoice->status->isOpen() && $invoice->remaining() > 0) @can('installments.manage')
@csrf

@endcan @else

โ€”

@endif @else @foreach($invoice->installments as $inst) @if($inst->remaining() > 0 && $invoice->status->isOpen()) @can('recordPayment', $invoice) @endcan @endif @endforeach
{{ $inst->seq === 0 ? __('Down') : '#'.$inst->seq }} {{ $inst->due_date->format('d M Y') }} @if($inst->isOverdue()){{ __('Overdue') }}@endif {{ number_format($inst->paid_amount) }}/{{ number_format($inst->amount) }} {{ $inst->status->label() }}
@include('invoices._quickpay', ['invoice' => $invoice, 'installment' => $inst, 'methods' => $methods])
@endif
@push('page-scripts') @endpush @endsection