@extends("client.layouts.app") @section("title", __("client.invoices.invoice_prefix", ["id" => $invoice->invoice_num ?? $invoice->id])) @section("content") {{ __('client.invoices.back_to_invoices') }}

{{ __('client.invoices.invoice_prefix', ['id' => $invoice->invoice_num ?? $invoice->id]) }}

{{ __('client.invoices.issued') }} {{ $invoice->date?->format(date_fmt()) ?? "N/A" }}

@if($invoice->sourceInvoice)

{{ __('admin.invoices.source_proforma') }}: {{ $invoice->sourceInvoice->invoice_num }}

@endif
{{ __('client.invoices.download_pdf') }} @foreach($invoice->creditNotes as $note) {{ __('client.invoices.credit_note', ['number' => $note->number]) }} @endforeach {{ invoice_status_label($invoice->status) }}
{{ __('client.invoices.invoice_details') }}
{{ __('client.invoices.due') }}: {{ $invoice->due_date?->format(date_fmt()) ?? "N/A" }} {{-- An open invoice carries the method chosen at checkout, not one it was paid with: "Paid via" there told the customer it was paid. --}} @if($invoice->payment_method)  ·  {{ in_array(strtolower((string) $invoice->status), ['paid', 'partially_paid', 'refunded'], true) ? __('client.invoices.paid_via') : __('client.invoices.payment_method_label') }} {{ payment_method_label((string) $invoice->payment_method) }} @endif
@foreach($invoice->items as $item) @endforeach
{{ __('common.table.description') }} {{ __('common.table.qty') }} {{ __('common.table.price') }} {{ __('common.table.amount') }}
{{ $item->description }} {{ (int) $item->qty }} {{ invoice_money_fmt($item->amount, $invoice) }} {{ invoice_money_fmt($item->amount * (int) $item->qty, $invoice) }}
@php $vatGroups = []; foreach ($invoice->items as $it) { $r = $it->tax_rate !== null ? (float) $it->tax_rate : ($it->taxed ? (float) $invoice->tax_rate : 0.0); $label = $it->tax_label ?: ($r > 0 ? rtrim(rtrim(number_format($r, 2), '0'), '.').'%' : null); if ($label === null) { continue; } $tx = (float) $it->amount * (int) $it->qty * $r / 100; $net = (float) $it->amount * (int) $it->qty; if (! isset($vatGroups[$label])) { $vatGroups[$label] = ['amount' => 0.0, 'rate' => $r, 'net' => 0.0]; } $vatGroups[$label]['amount'] += $tx; $vatGroups[$label]['net'] += $net; } uasort($vatGroups, fn ($a, $b) => $b['rate'] <=> $a['rate']); @endphp @if($invoice->subtotal && $invoice->subtotal != $invoice->total)
{{ __('client.cart.subtotal') }} {{ invoice_money_fmt($invoice->subtotal, $invoice) }}
@endif @foreach($vatGroups as $label => $g)
{{ $label }} {{ invoice_money_fmt($g['amount'], $invoice) }} {{ invoice_money_fmt($g['net'], $invoice) }}
@endforeach @if(($invoice->tax2 ?? 0) > 0)
{{ __('client.cart.tax').' 2' }}{{ $invoice->tax_rate2 > 0 ? " (" . rtrim(rtrim(number_format((float) $invoice->tax_rate2, 2), '0'), '.') . "%)" : '' }} {{ invoice_money_fmt($invoice->tax2, $invoice) }}
@endif
{{ __('client.invoices.total_due') }} {{ invoice_money_fmt($invoice->total, $invoice) }}
@if(billing_rate_note($invoice))
{{ __('pdf.amount_in') }} {{ billing_money_fmt($invoice->total, $invoice) }}
{{ billing_rate_note($invoice) }}
@endif @if(isset($balance) && $balance > 0 && $balance < (float) $invoice->total)
{{ __('client.invoices.amount_paid') }} {{ invoice_money_fmt((float) $invoice->total - $balance, $invoice) }}
{{ __('client.invoices.remaining_balance') }} {{ invoice_money_fmt($balance, $invoice) }}
@endif
@if(strtolower($invoice->status) === "payment_pending" || (isset($pendingNotification) && $pendingNotification))
{{ __('client.invoices.payment_notification_pending_title') }}
{{ __('client.invoices.payment_notification_pending_text') }} @if(isset($pendingNotification) && $pendingNotification)
{{ __('client.invoices.reported_on') }} {{ $pendingNotification->created_at->timezone(display_tz())->format(datetime_fmt()) }} — {{ dual_money_fmt((float) $pendingNotification->amount, $invoice) }} @endif
@endif {{-- What happened when we tried to take this from the card on file. Rendered only where there is something to say and only while the shop collects by card at all: the controller hands over nothing otherwise, so an installation with the feature switched off draws this block never. --}} @if(isset($chargeAttempt) && $chargeAttempt && in_array(strtolower($invoice->status), ["unpaid", "overdue", "partially_paid"])) @if($chargeAttempt->state === \App\Enums\ChargeAttemptState::ActionRequired)
{{ __('client.invoices.charge_action_required_title') }}
{{ __('client.invoices.charge_action_required_text') }}
@elseif($chargeAttempt->state === \App\Enums\ChargeAttemptState::Scheduled)
{{ __('client.invoices.charge_failed_title') }}
@if($chargeAttempt->next_attempt_at) {{ __('client.invoices.charge_retry_text', ['date' => $chargeAttempt->next_attempt_at->timezone(display_tz())->format(date_fmt())]) }} @else {{ __('client.invoices.charge_failed_text') }} @endif
@elseif($chargeAttempt->state === \App\Enums\ChargeAttemptState::Exhausted)
{{ __('client.invoices.charge_failed_title') }}
{{ __('client.invoices.charge_failed_text') }}
@elseif($chargeAttempt->state === \App\Enums\ChargeAttemptState::NeedsReview) {{-- A charge was sent and we cannot yet say what became of it. Saying so is the point: a customer who pays again on top of a payment that did go through has paid twice for one invoice. --}}
{{ __('client.invoices.charge_checking_title') }}
{{ __('client.invoices.charge_checking_text') }}
@endif @endif @if(in_array(strtolower($invoice->status), ["unpaid", "overdue", "partially_paid"]))
{{ __('client.invoices.pay_this_invoice') }} — {{ dual_money_fmt($balance ?? $invoice->total, $invoice) }}
@if(($usableCredit ?? 0) > 0) {{-- The account's balance first: it costs the customer nothing to use. --}}
@csrf
@endif @if(!empty($gateways)) @if(has_billing_conversion($invoice)) {{-- The invoice reads in the customer's currency; most gateways take the shop currency, and a card's own bank converts it. --}}

{{ __('client.invoices.currency_charge_note', [ 'billing' => strtoupper((string) $invoice->billing_currency), 'shop' => strtoupper((string) ($invoice->source_currency ?: currency_code_default())), 'amount' => invoice_money_fmt($balance ?? $invoice->total, $invoice), ]) }}

@endif

{{ __('client.invoices.select_payment_method') }}

@foreach($gateways as $i => $gw)
{{ $gatewayLabels[$gw] ?? ucfirst($gw) }}
@endforeach
@foreach($gateways as $i => $gw)
@if(isset($gatewayForms[$gw]) && $gatewayForms[$gw]) {!! $gatewayForms[$gw] !!} @if($gw === "banktransfer" && !(isset($pendingNotification) && $pendingNotification)) @include("client.invoices.partials.payment-notification-form") @endif @elseif($gw === "stripe")

{{ __('client.invoices.stripe_desc') }}

{{ __('client.invoices.stripe_placeholder') }}
@elseif($gw === "paypal")

{{ __('client.invoices.paypal_desc') }}

@else

{{ __('client.invoices.payment_form_for') }} {{ $gatewayLabels[$gw] ?? ucfirst($gw) }} {{ __('client.invoices.not_configured') }}

@endif
@endforeach @else
{{ __('client.invoices.no_payment_methods') }}
@endif
@endif @section("scripts") @endsection @endsection