Booking Details {#if selectedBooking}
ID: {selectedBooking.id}
{/if}
{#if selectedBooking} {@const isPastBooking = new Date(selectedBooking.start_time) < new Date()} {@const isUnpaid = selectedBooking.amount_due > 0} {@const showChip = !isPastBooking || isUnpaid} {#if showChip} {isPastBooking ? 'Unpaid' : selectedBooking.status.replace('_', ' ')} {/if} {/if}
{#if loading}
Loading...
{:else if selectedBooking}

Appointment Details

Scheduled Date & Time
{(() => { const date = new SvelteDate(selectedBooking.start_time); const dateStr = date.toLocaleDateString('en-US', { weekday: 'long', day: 'numeric', month: 'short' }); const timeStr = date.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true }); return `${dateStr} at ${timeStr}`; })()}
Duration
{totalDuration} minutes
{#if selectedBooking.notes}
Notes
{selectedBooking.notes}
{/if}
{#if selectedBooking.services && selectedBooking.services.length > 0}

Services

{#each selectedBooking.services as service, index (index)}
{service.service_name || '—'}
{#if service.service_description}
{service.service_description}
{/if}
{service.duration_minutes} min £{service.price?.toFixed(2) || '0.00'}
{/each}
{/if}

Financial Summary

Total Amount £{selectedBooking.total_amount.toFixed(2)}
Amount Paid £{selectedBooking.amount_paid.toFixed(2)}
Amount Due £{selectedBooking.amount_due.toFixed(2)}
{#if selectedBooking.payments && selectedBooking.payments.length > 0}

Payment History

{#each selectedBooking.payments as payment (payment.id)}
{payment.payment_method.replace('_', ' ')} {payment.status}
{payment.payment_type.charAt(0).toUpperCase() + payment.payment_type.slice(1)}
{#if payment.is_vat_applicable}
Net: £{payment.net_amount?.toFixed(2) || '0.00'}
{#if payment.vat_amount}
VAT ({(payment.vat_rate || 0) * 100}%): £{payment.vat_amount.toFixed( 2 )}
{/if}
{/if}
{new SvelteDate(payment.created_at).toLocaleString()}
£{payment.amount.toFixed(2)}
{/each}
{/if}
{/if}