<x-mail::message>
# New Sales Order Received

**Order Reference:** {{ $order->order_number }}
**Order Date:** {{ $order->order_date?->format('d M Y') }}
@if($order->deadline_date)
**Delivery Deadline:** {{ $order->deadline_date->format('d M Y') }}
@endif

---

## Customer Details

@if($customer)
**{{ $customer->business_name }}**
@if($customer->phone)
Phone: {{ $customer->phone }}
@endif
@if($customer->email)
Email: {{ $customer->email }}
@endif
@else
Not recorded
@endif

---

## Order Summary

<x-mail::table>
| Item | Qty | Unit Price | Total |
|:-----|----:|-----------:|------:|
@foreach($items as $item)
| {{ $item->product_name }}{{ $item->is_custom ? ' *(custom)*' : '' }} | {{ \App\Support\Quantity::format($item->quantity, $item->unit) }} | LKR {{ number_format($item->unit_price, 2) }} | LKR {{ number_format($item->line_total, 2) }} |
@endforeach
</x-mail::table>

@php($customItems = $items->where('is_custom', true))
@if($customItems->isNotEmpty())
---

## Custom Item Details

@foreach($customItems as $item)
**{{ $item->product_name }}** — {{ \App\Support\Quantity::format($item->quantity, $item->unit) }} × LKR {{ number_format($item->unit_price, 2) }}
@if($item->custom_description)
{{ $item->custom_description }}
@endif
@if($item->custom_specification)
*Exact details:* {{ $item->custom_specification }}
@endif

@endforeach
@endif

---

@if($order->discount > 0)
**Subtotal:** LKR {{ number_format($order->subtotal, 2) }}
**Discount:** LKR {{ number_format($order->discount, 2) }}
@endif
@if($order->vat_total > 0)
**VAT:** LKR {{ number_format($order->vat_total, 2) }}
@endif

**Order Value: LKR {{ number_format($order->net_total, 2) }}**

@if($order->advance_paid > 0)
**Advance Paid:** LKR {{ number_format($order->advance_paid, 2) }}
**Balance Due on Invoicing:** LKR {{ number_format($order->balance, 2) }}
@else
No payment has been taken yet — the balance falls due when the order is invoiced.
@endif

@if($order->note)
---
**Order Note:** {{ $order->note }}
@endif

---

*This is an automated notification from {{ config('app.name') }}.*

Thanks,<br>
{{ config('app.name') }}
</x-mail::message>
