@use('App\Modules\Orders\Enums\OrderStatus') @use('App\Modules\Sellers\Models\SellerStore') @php $a = (array) $order->shipping_address; $cancellable = in_array($order->status, [OrderStatus::PendingPayment, OrderStatus::Placed, OrderStatus::Confirmed], true) && ! $order->items->contains(fn ($i) => $i->shipped_at); $groups = $order->shipments(); $hasEbc = $groups->keys()->contains(SellerStore::EBC); $hasSellers = $groups->keys()->contains(fn ($n) => $n !== SellerStore::EBC); $orderType = $hasEbc && $hasSellers ? ['EBC own + seller', 'warning'] : ($hasEbc ? ['EBC own', 'danger'] : ['Seller order', 'secondary']); // Progress steps for one delivery. $steps = fn ($item) => [ ['Placed', $order->placed_at, true], ['Confirmed', $item->confirmed_at, (bool) $item->confirmed_at || in_array($item->status, [OrderStatus::Confirmed, OrderStatus::Shipped, OrderStatus::Delivered], true)], ['Shipped', $item->shipped_at, (bool) $item->shipped_at], ['Delivered', $item->delivered_at, (bool) $item->delivered_at], ]; @endphp @push('styles') @endpush Orders Proforma invoice {{-- At a glance --}}
Order status
{{ $order->status->label() }}
Type
{{ $orderType[0] }}
Payment
{{ $order->paymentLabel() }} · $order->payment_status === 'paid', 'text-danger' => in_array($order->payment_status, ['failed', 'refund_pending'], true)])>{{ $order->paymentStatusLabel() }}
Total
{{ inr($order->total) }}
Customer
{{ $order->user?->name }}
@if ($order->deliveryPreference())
Preferred delivery
{{ $order->deliveryPreference() }}
@endif
@foreach ($groups as $seller => $items) @php $store = $stores[$seller] ?? null; $st = $items->first()->status; $first = $items->first(); $docs = $invoices->filter(fn ($inv) => $inv->store?->name === $seller); @endphp
Delivery {{ $loop->iteration }} · @if ($store?->isEbc())EBC own @elseSeller@endif {{ $seller }}
@if ($store)
@if ($store->phone)+91 {{ $store->phone }} · @endif @if ($store->user?->email){{ $store->user->email }} · @endif {{ collect([$store->city, $store->state])->filter()->join(', ') }} @if ($store->gstin) · GSTIN {{ $store->gstin }}@endif @can('sellers.manage') · View seller@endcan
@endif
{{ $st->label() }}
@foreach ($items as $item) @endforeach
@if ($item->image)@endif
{{ $item->displayName() }}
{{ inr($item->unit_price) }} × {{ $item->qty }}@if ($item->hsn) · HSN {{ $item->hsn }}@endif @if ($item->status !== $st) · {{ $item->status->label() }}@endif @if ($item->cancel_reason) · {{ $item->cancel_reason }}@endif
@if ($item->returnRequest)
Return: {{ $item->returnRequest->statusLabel() }}
@endif
{{ inr($item->line_total) }} @if ($item->earning)
Seller gets {{ inr($item->earning->net) }}
@endif
@if ($st !== OrderStatus::Cancelled)
    @foreach ($steps($first) as [$label, $at, $done])
  1. $done])>@if ($done)@endif{{ $label }}{{ $at?->format('d M, h:i A') ?? ' ' }}
  2. @endforeach
@endif
@endforeach

Internal note

@csrf @method('PATCH')

Amount

@if ($order->cancel_reason)

{{ $order->cancel_reason }}

@endif
  • Items{{ inr($order->subtotal) }}
  • @if ((float) $order->discount > 0)
  • Coupon {{ $order->coupon_code }}− {{ inr($order->discount) }}
  • @endif
  • Delivery{{ (float) $order->shipping_fee > 0 ? inr($order->shipping_fee) : 'Free' }}
  • @if ((float) $order->packing_fee > 0)
  • Packing{{ inr($order->packing_fee) }}
  • @endif
  • Total{{ inr($order->total) }}
  • @if ((float) $order->refund_amount > 0)
  • Refunded− {{ inr($order->refund_amount) }}
  • @endif

Payment

{{ $order->paymentLabel() }} · {{ $order->paymentStatusLabel() }}
@if ($order->gateway_payment_id)
Razorpay {{ $order->gateway_payment_id }}
@endif @if ($order->paid_at)
Paid {{ $order->paid_at->format('d M Y, h:i A') }}
@endif @if ($order->refund_reference)
Refund ref {{ $order->refund_reference }}
@endif @if ($order->payment_status === 'refund_pending' && $refundable > 0)
{{ inr($refundable) }} still to refund.
@if ($order->payment_method !== 'cod' && $order->gateway_payment_id)
@csrf
@endif
@csrf
@error('reference')
{{ $message }}
@enderror
@endif
@if ($order->risk_flags)
Check this order: {{ collect($order->risk_flags)->map(fn ($f) => \App\Modules\Orders\Services\FraudGuard::FLAGS[$f] ?? $f)->join('; ') }}. @if ($order->placed_ip)IP {{ $order->placed_ip }}.@endif
@endif

Customer

{{ $order->user?->name }}
{{ $order->user?->email }}@if ($order->user?->phone) · +91 {{ $order->user->phone }}@endif
@php($attrs = $order->getAttributes()) @if (! empty($attrs['buyer_gstin']))
GSTIN {{ $attrs['buyer_gstin'] }}@if (! empty($attrs['buyer_legal_name'])) · {{ $attrs['buyer_legal_name'] }}@endif
@endif

Deliver to

{{ $a['name'] ?? '' }} · {{ $a['phone'] ?? '' }}
{{ collect([$a['line1'] ?? null, $a['line2'] ?? null, $a['landmark'] ?? null, $a['city'] ?? null, $a['state'] ?? null])->filter()->join(', ') }} {{ $a['pincode'] ?? '' }}
@if ($order->deliveryPreference())
{{ $order->deliveryPreference() }}
@endif @can('settings.manage')
@csrf
@endcan
@if ($cancellable)

Cancel order

@csrf $errors->has('reason')]) placeholder="Reason (sent to the customer)" aria-label="Reason"> @error('reason')
{{ $message }}
@enderror
@endif