@php
use App\Models\Currency;
$sym = Currency::symbolFor($doc->currency);
$exp = (int) $doc->currency_exponent;
$fmt = fn ($minor) => $sym . number_format(((int) $minor) / (10 ** $exp), $exp);
$items = $doc->items_json ?? [];
$statusColor = [
'draft' => '#6b6559', 'sent' => '#0369a1', 'accepted' => '#0b7a4b',
'rejected' => '#b3402e', 'expired' => '#b45309', 'invoiced' => '#0b3d2e',
];
$brand = function_exists('brand_name') ? brand_name() : config('app.name');
@endphp
{{ $brand }} · {{ __($doc->typeLabel()) }}
{{ $doc->title ?: __($doc->typeLabel()) }}
{{ $doc->number }}
{{ __(ucfirst($doc->status)) }}
@if ($doc->valid_until)Valid until {{ $doc->valid_until->format('d M Y') }}@endif
@if ($doc->buyer_name || $doc->company?->name || $doc->buyer_email)
{{ __('Prepared for') }}
@if ($doc->buyer_name){{ $doc->buyer_name }}
@endif
@if ($doc->company?->name){{ $doc->company->name }}
@endif
@if ($doc->buyer_email){{ $doc->buyer_email }}
@endif
@if ($doc->buyer_phone){{ $doc->buyer_phone }}@endif
@endif
{{ __('Line items') }}
| {{ __('Description') }} | {{ __('Qty') }} | {{ __('Unit') }} | {{ __('Amount') }} |
@forelse ($items as $it)
| {{ $it['description'] ?? '' }} |
{{ rtrim(rtrim(number_format((float) ($it['qty'] ?? 0), 2), '0'), '.') }} |
{{ $fmt($it['unit_price_minor'] ?? 0) }} |
{{ $fmt($it['line_total_minor'] ?? 0) }} |
@empty
| {{ __('No items.') }} |
@endforelse
{{ __('Subtotal') }}{{ $fmt($doc->subtotal_minor) }}
@if ($doc->tax_minor > 0)
{{ __('Tax') }} ({{ rtrim(rtrim(number_format($doc->tax_rate_bp / 100, 2), '0'), '.') }}%){{ $fmt($doc->tax_minor) }}
@endif
{{ __('Total') }}{{ $fmt($doc->total_minor) }}
@if ($doc->notes)
{{ __('Notes') }}
{{ $doc->notes }}
@endif
@php
$justDecided = session('decided');
$openStates = ['draft', 'sent', 'expired'];
$isOpen = in_array($doc->status, $openStates, true);
@endphp
{{-- Confirmation banner after the customer acts --}}
@if ($justDecided === 'accepted' || $doc->status === 'accepted')
✓ {{ __('You accepted this :type. :brand has been notified and will follow up.', ['type' => strtolower(__($doc->typeLabel())), 'brand' => $brand]) }}
@elseif ($justDecided === 'rejected' || $doc->status === 'rejected')
{{ __('This :type was declined. If this was a mistake, please contact :brand.', ['type' => strtolower(__($doc->typeLabel())), 'brand' => $brand]) }}
@elseif ($doc->status === 'invoiced')
✓ {{ __('Accepted — an invoice has been issued for this :type.', ['type' => strtolower(__($doc->typeLabel()))]) }}
@endif
{{-- Customer decision buttons (only while still open) --}}
@if ($isOpen)
{{ __('Your decision') }}
{{ __('By accepting you confirm the scope and pricing above.') }}
@endif