@include('sales.distributor._invoice-style-distributor')
@php $paidTotal = $sale->payment_method === 'cash' ? (float) $sale->grand_total : (float) $sale->payments->sum('amount'); $remaining = max(0, (float) $sale->grand_total - $paidTotal); $money = fn($amount) => 'Rp ' . number_format((float) $amount, 2, ',', '.'); @endphp
@if ($sale->tenant?->tenant_logo_url) @endif

{{ $sale->tenant?->name ?? '-' }}

@if ($sale->tenant?->address)

{{ $sale->tenant->address }}

@endif
Kepada: {{ $sale->customer?->name ?? '-' }}
Kirim ke: {{ $sale->customer?->address ?: '-' }}

FAKTUR

{{ $sale->sale_number }}
Tanggal: {{ $sale->sale_date?->format('d/m/Y') ?? '-' }}
Jatuh Tempo: {{ $sale->getAttribute('due_date') ? \Illuminate\Support\Carbon::parse($sale->getAttribute('due_date'))->format('d/m/Y') : '-' }}
No. Surat Jalan: {{ $sale->getAttribute('delivery_number') ?: '-' }}
@foreach ($sale->details as $index => $detail) @endforeach
No Nama Barang Banyak Unit Harga Satuan Disc% Total
{{ $index + 1 }} {{ $detail->product?->name ?? '-' }} @if ($detail->product?->sku) KODE: {{ $detail->product->sku }} @endif {{ rtrim(rtrim(number_format((float) $detail->quantity, 2, ',', '.'), '0'), ',') }} {{ $detail->unit?->code ?? '-' }} {{ $money($detail->unit_price) }} - {{ $money($detail->line_total) }}
@if ($sale->note)

Catatan: {{ $sale->note }}

@endif
Tanda Terima
{{ $sale->customer?->name ?? '-' }}
Hormat Kami
{{ $sale->tenant?->name ?? '-' }}
Subtotal
{{ $money($sale->subtotal) }}
Diskon
{{ $money($sale->discount_amount) }}
DP
-
Pajak
{{ $money($sale->tax_amount) }}
Total
{{ $money($sale->grand_total) }}
Bayar
{{ $money($paidTotal) }}
Sisa
{{ $money($remaining) }}