@vite(['resources/css/app.css']) @php use Carbon\Carbon; $invoiceNumber = 'INV/' . Carbon::parse($sale->report_date)->format('Y/m/') . str_pad($sale->id, 4, '0', STR_PAD_LEFT); $companyName = 'PT GRACE INDO PRATAMA'; $companyAddress = 'Jl. Industri No. 12, Medan, Sumatera Utara'; $companyPhone = '(061) 12345678'; $companyEmail = 'sales@graceindopratama.co.id'; $bankName = 'Transfer Bank'; $bankAccountName = 'A/N PT Grace Indo Pratama'; $invoiceDate = Carbon::parse($sale->report_date)->translatedFormat('d F Y'); $saleDate = Carbon::parse($sale->sale_date)->translatedFormat('d F Y'); $statusText = strtoupper($sale->status); $statusColor = $sale->status === 'Terhutang' ? 'text-red-700' : 'text-green-700'; $customerDisplay = $sale->customer_name ?: '-'; $customerRegion = trim( ($sale->customer_city ? $sale->customer_city . ', ' : '') . ($sale->customer_province ?: ''), ); $paymentHistories = $sale->paymentHistories->sortBy([['payment_date', 'asc'], ['id', 'asc']])->values(); $totalPaid = $paymentHistories->sum('amount'); $isPo = $sale->stock_type === 'po'; $stockTypeLabel = $isPo ? 'Pre-Order (PO)' : 'Ready Stock'; $totalFulfilled = $sale->items->sum('fulfilled_quantity'); $totalOrdered = $sale->items->sum('quantity'); @endphp {{-- top tools --}}
Preview Invoice
{{ $invoiceNumber }}
Kembali
{{-- invoice paper --}}
{{-- title --}}

INVOICE PENJUALAN

@if ($isPo)
(PRE-ORDER)
@endif
{{-- header company + invoice info --}}
BHOS Technology
{{ $companyName }}
{{ $companyAddress }}
Telp: {{ $companyPhone }}
Email: {{ $companyEmail }}
Invoice No : {{ $invoiceNumber }}
Tanggal Invoice : {{ $invoiceDate }}
Tanggal Penjualan : {{ $saleDate }}
Tipe Stok : {{ $stockTypeLabel }}
{{-- customer --}}
Kepada:
{{ $customerDisplay }}
{{ $customerRegion ?: '-' }}
Kontak: {{ $sale->customer_contact ?: '-' }}
@if ($sale->customer_address)
{{ $sale->customer_address }}
@endif
{{-- items --}}
Detail Barang
@if ($isPo) @endif @foreach ($sale->items as $item) @php $remaining = max(0, $item->quantity - $item->fulfilled_quantity); @endphp @if ($isPo) @endif @endforeach
SKU Nama Produk QtyDipenuhi SisaUnit Harga Satuan Diskon Subtotal
{{ $item->productStock?->productVariant?->sku ?? '-' }} {{ $item->productStock?->productVariant?->name ?? '-' }} {{ $item->quantity }} {{ $item->fulfilled_quantity }} {{ $remaining }} {{ $item->productStock?->productVariant?->unit ?? '-' }} Rp {{ number_format($item->price, 0, ',', '.') }} Rp {{ number_format($item->discount, 0, ',', '.') }} Rp {{ number_format($item->subtotal, 0, ',', '.') }}
@if ($isPo)
Keterangan PO: Total Ordered: {{ $totalOrdered }} | Sudah Dipenuhi: {{ $totalFulfilled }} | Sisa: {{ max(0, $totalOrdered - $totalFulfilled) }}
@endif
{{-- payment summary --}}
Ringkasan & Riwayat Pembayaran
{{-- grand total --}}
Grand Total:
Rp {{ number_format($sale->total_amount, 0, ',', '.') }}
{{-- daftar pembayaran --}}
Riwayat Pembayaran Masuk:
@if ($paymentHistories->count())
@foreach ($paymentHistories as $payment)
Pembayaran ke-{{ $loop->iteration }} — {{ \Carbon\Carbon::parse($payment->payment_date)->format('d/m/Y') }}
Rp {{ number_format($payment->amount, 0, ',', '.') }}
@endforeach
@else
Belum ada pembayaran tercatat
@endif
{{-- total paid --}}
Total Sudah Dibayar:
Rp {{ number_format($totalPaid, 0, ',', '.') }}
{{-- remaining --}}
Jumlah Terhutang:
Rp {{ number_format($sale->debt_amount, 0, ',', '.') }}
{{-- status --}}
Status Pembayaran:
{{ $statusText }}
{{-- payment method --}}
Metode Pembayaran
{{ $bankName }}
{{ $bankAccountName }}
{{-- notes --}}
Catatan
{{ $sale->notes ?: 'Pengiriman dilakukan maksimal 2 hari kerja setelah pembayaran diverifikasi.' }}
{{-- signatures --}}
Penanggung Jawab
{{ $sale->personResponsible?->name ?? '-' }}
Diterima Oleh
(                                      )