@php $invoiceNumber = $order->invoice_number ?? ('INV-' . $order->id); $traceUrl = url('/trace-order?search=' . urlencode($invoiceNumber)); /* * QR dibuat SVG supaya aman di hosting yang tidak punya GD/Imagick. * Penyebab barcode sebelumnya tidak muncul biasanya karena format PNG gagal dibuat, * lalu tertangkap catch dan $qr menjadi null. */ $qrSvg = null; try { if (class_exists(\SimpleSoftwareIO\QrCode\Facades\QrCode::class)) { $qrSvg = \SimpleSoftwareIO\QrCode\Facades\QrCode::format('svg') ->size(300) ->margin(2) ->errorCorrection('H') ->generate($traceUrl); } elseif (class_exists('QrCode')) { $qrSvg = QrCode::format('svg') ->size(300) ->margin(2) ->errorCorrection('H') ->generate($traceUrl); } } catch (\Throwable $e) { $qrSvg = null; } $usePpn = (bool) ($order->use_ppn ?? false); $ppnRate = (float) ($order->ppn_rate ?? 0); $ppnAmount = (float) ($order->ppn_amount ?? 0); $subtotalBeforePpn = (float) ($order->subtotal_before_ppn ?? 0); if ($subtotalBeforePpn <= 0) { $subtotalBeforePpn = (float) ($order->total_price ?? 0); if ($usePpn && $ppnAmount > 0) { $subtotalBeforePpn = max($subtotalBeforePpn - $ppnAmount, 0); } } if ($usePpn && $ppnAmount <= 0 && $ppnRate > 0) { $ppnAmount = round($subtotalBeforePpn * ($ppnRate / 100)); } $grandTotal = $usePpn ? ($subtotalBeforePpn + $ppnAmount) : (float) ($order->total_price ?? $subtotalBeforePpn); $paidAmount = (float) ($order->paid_amount ?? $grandTotal); $changeAmount = max($paidAmount - $grandTotal, 0); if ($changeAmount <= 1) { $changeAmount = 0; } $logoSrc = ''; if (!empty($shopLogo)) { if (str_starts_with($shopLogo, 'http://') || str_starts_with($shopLogo, 'https://') || str_starts_with($shopLogo, '/') || str_starts_with($shopLogo, 'data:image')) { $logoSrc = $shopLogo; } else { $logoSrc = asset('storage/' . ltrim($shopLogo, '/')); } } @endphp
@if(env('APP_DEMO', false))
DEMO MODE
@endif
@if($logoSrc) @endif

{{ $shopName }}

@if($shopAddress)
{{ $shopAddress }}
@endif @if($shopPhone)
Telp: {{ $shopPhone }}
@endif
@if($qrSvg) {!! $qrSvg !!} @else
QR tidak tersedia
{{ $invoiceNumber }}
@endif
{{ $invoiceNumber }}
{{ $usePpn ? 'INVOICE + PPN ' . rtrim(rtrim(number_format($ppnRate, 2, ',', '.'), '0'), ',') . '%' : 'TANPA PPN' }}
@if(env('APP_DEMO', false))
Demo Mode
Nota ini adalah simulasi / percobaan
termasuk transaksi palsu dan bukan bukti pembayaran sah
@endif
Tgl: {{ optional($order->paid_at)->format('d/m/Y H:i') ?: now()->format('d/m/Y H:i') }}
Pelanggan: {{ $order->customer_name }}
Kasir: {{ $order->cashier->name ?? '-' }}
Designer: {{ $order->designer->name ?? '-' }}
@foreach($order->items as $item) @php $qty = (float) ($item->qty ?? $item->quantity ?? 0); $price = (float) ($item->calculated_price ?? $item->unit_price ?? $item->price ?? 0); $subtotal = (float) ($item->subtotal ?? ($qty * $price)); if ($price <= 0 && $qty > 0 && $subtotal > 0) { $price = $subtotal / $qty; } @endphp
{{ $item->product_name }} - {{ $item->file_name }}
{{ $item->size_description }} | {{ ($item->sisi ?? 1) }} sisi | {{ $item->material_name ?? '-' }}
{{ rtrim(rtrim(number_format($qty, 2, ',', '.'), '0'), ',') }} x Rp {{ number_format($price,0,',','.') }} Rp {{ number_format($subtotal,0,',','.') }}
@endforeach
Subtotal Rp {{ number_format($subtotalBeforePpn,0,',','.') }}
@if($usePpn)
PPN {{ rtrim(rtrim(number_format($ppnRate, 2, ',', '.'), '0'), ',') }}% Rp {{ number_format($ppnAmount,0,',','.') }}
@endif
TOTAL Rp {{ number_format($grandTotal,0,',','.') }}
Tunai Rp {{ number_format($paidAmount,0,',','.') }}
Kembalian Rp {{ number_format($changeAmount,0,',','.') }}
*** LUNAS ***
@if(env('APP_DEMO', false)) @endif