@extends('layouts.app') @section('title', $order->order_no) @section('content') @php $client = $order->client; $cancelled = $order->isCancelled(); $paid = $order->paid(); $due = $cancelled ? 0 : $order->due(); $pct = (float) $order->total > 0 ? min(100, round($paid / (float) $order->total * 100)) : 0; $cost = $order->cost(); $netSales = (float) $order->total - (float) $order->tax_amount; $margin = $netSales - $cost; $marginPct = $netSales > 0 ? round($margin / $netSales * 100) : null; $flow = ['pending' => 'Pending', 'in_production' => 'In production', 'ready' => 'Ready', 'delivered' => 'Delivered']; $keys = array_keys($flow); $currentIdx = array_search($order->status, $keys, true); $nextKey = $currentIdx !== false ? ($keys[$currentIdx + 1] ?? null) : null; $days = $order->delivery_date ? (int) now()->startOfDay()->diffInDays($order->delivery_date->copy()->startOfDay(), false) : null; $late = ! in_array($order->status, ['delivered', 'cancelled']) && $days !== null && $days < 0; $deliveryNote = match (true) { $cancelled => 'Order cancelled', $order->status === 'delivered' => 'Delivered', $days === null => 'No date set', $days < 0 => abs($days).' '.\Illuminate\Support\Str::plural('day', abs($days)).' overdue', $days === 0 => 'Due today', default => 'In '.$days.' '.\Illuminate\Support\Str::plural('day', $days), }; $pcs = rtrim(rtrim(number_format($order->items->sum('quantity'), 2), '0'), '.'); $area = $order->items->sum(fn ($i) => $i->totalArea()); $phone = $client->phone; @endphp {{-- ===== Header ===== --}}
| Design | Size | Qty | Rate | Amount |
|---|---|---|---|---|
| {{ $i->design_name }}@if ($spec){{ $spec }}@endif | {{ $i->sizeText() ?: '—' }}@if ($i->area_sqft){{ number_format($i->area_sqft, 2) }} sq ft each@endif | {{ rtrim(rtrim(number_format($i->quantity, 2), '0'), '.') }} pcs @if ($i->totalArea()){{ number_format($i->totalArea(), 2) }} sq ft@endif | {{ $i->rateText() }}@if (! $i->isPerSqft() && $i->ratePerSqft())≈ {{ money($i->ratePerSqft()) }} / sq ft@endif | {{ money($i->line_total) }} |
| Date | Method | Reference | Amount |
|---|---|---|---|
| @can('payments.edit'){{ $p->paid_on->format('d M Y') }}@else{{ $p->paid_on->format('d M Y') }}@endcan | {{ \App\Models\Payment::METHODS[$p->method] ?? $p->method }} | {{ $p->reference ?: '—' }} | +{{ money($p->amount) }} |
| Vendor | No. | Agreed | Extra | Paid | Balance |
|---|---|---|---|---|---|
| {{ $x->vendor->name }} | {{ $x->number() }} | {{ money($x->assigned_amount) }} | {{ $x->extra() > 0.004 ? money($x->extra()) : '—' }} | {{ money($x->paid()) }} | {{ money($x->due()) }} |
| Vendor | Bill | Description | Amount |
|---|---|---|---|
| {{ $b->vendor->name }} | {{ $b->bill_no ?: '#'.$b->id }} | {{ $b->description ?: '—' }} | {{ money($b->amount) }} |