@php /** @var \App\Models\Order $order */ $checkout = config('checkout'); $customer = $order->customer; $items = $order->items; $paymentMethod = $order->payment_method; $grossTotal = (float) $order->grand_total; $amountPaid = (float) $order->amount_paid; $refundedTotal = (float) $order->refunded_total; $netPaidTotal = max(0, $amountPaid - $refundedTotal); $outstandingTotal = (float) $order->outstanding_total; if ($outstandingTotal <= 0 && $amountPaid <= 0 && !in_array($order->status->value, ['cancelled', 'refunded'], true)) { $outstandingTotal = $grossTotal; } $isPaid = $amountPaid + 0.01 >= $grossTotal && $outstandingTotal <= 0.01; $isPartiallyPaid = $amountPaid > 0 && !$isPaid && $refundedTotal + 0.01 < $amountPaid; $buyerName = $order->buyer_name ?? $customer?->full_name ?? $customer?->company_name ?? $order->ship_contact_name; $buyerEmail = $order->buyer_email ?? $customer?->email ?? $order->placedBy?->email; $currency = $order->currency ?? 'USD'; $fmt = static fn ($v) => $currency.' '.number_format((float) $v, 2, '.', ','); $logoPath = public_path('images/logo-vidamansa.png'); $logoSrc = file_exists($logoPath) ? 'data:image/png;base64,'.base64_encode(file_get_contents($logoPath)) : null; @endphp Invoice {{ $order->number }}
@if ($logoSrc) Vida Mansa @else

{{ $checkout['company_name'] }}

@endif
{{ $checkout['company_address'] }}
{{ $checkout['support_email'] }}

INVOICE

#{{ $order->number }}
Date: {{ optional($order->placed_at ?? $order->created_at)->format('M d, Y') }}
@if ($order->po_number)
PO: {{ $order->po_number }}
@endif
Payment: {{ $paymentMethod->getLabel() }}
@if ($paymentMethod === \App\Enums\PaymentMethod::Invoice)
Terms: NET {{ $order->payment_terms_days ?? '—' }} @if ($order->payment_due_at) · Due {{ $order->payment_due_at->format('M d, Y') }} @endif
@endif

Bill To

{{ $buyerName }}
@if ($customer?->company_name && $customer->company_name !== $buyerName){{ $customer->company_name }}
@endif @if ($buyerEmail){{ $buyerEmail }}
@endif @if ($order->bill_contact_name && $order->bill_contact_name !== $buyerName){{ $order->bill_contact_name }}
@endif {{ $order->bill_line1 }}
@if ($order->bill_line2){{ $order->bill_line2 }}
@endif {{ $order->bill_city }}, {{ $order->bill_state }} {{ $order->bill_postal_code }}
{{ $order->bill_country_code }}

Ship To

@if ($order->ship_contact_name){{ $order->ship_contact_name }}
@endif {{ $order->ship_line1 }}
@if ($order->ship_line2){{ $order->ship_line2 }}
@endif {{ $order->ship_city }}, {{ $order->ship_state }} {{ $order->ship_postal_code }}
{{ $order->ship_country_code }} @if ($order->ship_phone)
{{ $order->ship_phone }}@endif

Items

@foreach ($items as $item) @endforeach
Product SKU Qty Unit price Line total
{{ $item->product_title }} @if ($item->variant_title)
{{ $item->variant_title }}@endif
{{ $item->sku }} {{ $item->quantity }} {{ $fmt($item->unit_price) }} {{ $fmt($item->line_total) }}
@if ((float) $order->discount_total > 0) @endif @if ($amountPaid > 0) @endif @if ($refundedTotal > 0) @endif
Subtotal{{ $fmt($order->subtotal) }}
Discount @if ($order->discount_code)
{{ $order->discount_code }} @endif
-{{ $fmt($order->discount_total) }}
Shipping @if ($order->shipping_service_name)
{{ collect([$order->shipping_carrier_name, $order->shipping_service_name])->filter()->join(' - ') }} @endif
{{ $fmt($order->shipping_total) }}
Tax{{ $fmt($order->tax_total) }}
Gross order total{{ $fmt($order->grand_total) }}
Amount paid{{ $fmt($amountPaid) }}
Refunded-{{ $fmt($refundedTotal) }}
Net paid{{ $fmt($netPaidTotal) }}
Outstanding balance{{ $fmt(max(0, $outstandingTotal)) }}

Payment

@if ($refundedTotal > 0 && $refundedTotal + 0.01 >= $amountPaid)
Refunded
{{ $fmt($refundedTotal) }} has been refunded. Net paid balance: {{ $fmt($netPaidTotal) }}.
@elseif ($isPaid)
Paid
Payment recorded {{ $order->paid_at?->format('M d, Y g:i A') ?? 'in the payment ledger' }}.
@elseif ($isPartiallyPaid)
Partially paid
{{ $fmt($amountPaid) }} received · {{ $fmt(max(0, $outstandingTotal)) }} outstanding. Finance review is required before cancellation.
@elseif ($paymentMethod === \App\Enums\PaymentMethod::Invoice)
Approved Payment Terms
TermsNET {{ $order->payment_terms_days ?? '—' }}
Due date{{ $order->payment_due_at?->format('M d, Y') ?? '—' }}
Approved decision{{ $order->credit_application_id ? '#'.$order->credit_application_id : '—' }}
@elseif ($paymentMethod === \App\Enums\PaymentMethod::Card)
Credit card via Shopify
Use the secure Shopify checkout associated with this order. Card details are never processed or stored by Vida Mansa Wholesale.
@else
Please reference order {{ $order->number }} in the transfer memo.
@php $blocks = $paymentMethod === \App\Enums\PaymentMethod::Ach ? [($checkout['ach']['label'] ?? 'ACH transfer') => ($checkout['ach'] ?? [])] : [ ($checkout['wire_intl_usd']['label'] ?? 'International wire in USD') => ($checkout['wire_intl_usd'] ?? []), ]; @endphp @foreach ($blocks as $title => $b)
{{ $title }}
@if (!empty($b['swift'])) @endif @if (!empty($b['memo_reference'])) @endif @if (!empty($b['notes'])) @endif
Bank{{ $b['bank_name'] ?? '' }}
Beneficiary{{ $b['beneficiary_name'] ?? '' }}
Beneficiary address{{ $b['beneficiary_address'] ?? '' }}
ABA / Routing{{ $b['routing_number'] ?? '' }}
Account number{{ $b['account_number'] ?? '' }}
SWIFT / BIC{{ $b['swift'] }}
Memo / Reference{{ $b['memo_reference'] }}
Notes{{ $b['notes'] }}
@endforeach @endif