@if($viewMode === 'list')

📦 Pembelian Bahan Baku

Mencatat riwayat pembelian bahan baku dan mengelola hutang supplier (Account Payable).

@if($successMessage)
✅ {{ $successMessage }}
@endif @if($errorMessage)
⚠️ {{ $errorMessage }}
@endif
@forelse($historyPurchases as $purchase) @php $sisaTagihan = max(0, $purchase->grand_total - $purchase->paid_amount); @endphp @empty @endforelse
TANGGAL NO. BUKTI CABANG SUPPLIER JATUH TEMPO TOTAL (RP) UANG MUKA / BAYAR SISA HUTANG STATUS AKSI
{{ date('d-m-Y', strtotime($purchase->created_at)) }} {{ $purchase->purchase_number }} {{ $purchase->branch->name ?? 'Global' }} {{ $purchase->supplier->name ?? '-' }} {{ $purchase->due_date ? date('d-m-Y', strtotime($purchase->due_date)) : 'LUNAS' }} {{ number_format($purchase->grand_total, 0, ',', '.') }} {{ number_format($purchase->paid_amount, 0, ',', '.') }} {{ number_format($sisaTagihan, 0, ',', '.') }} @if($purchase->status === 'paid' || $sisaTagihan <= 0) LUNAS @elseif($purchase->status === 'partially_paid') CICIL / DP @else BELUM BAYAR @endif
Belum ada transaksi pembelian bahan baku.
TOTAL SELURUH HALAMAN: {{ number_format($summary['grand_total'], 0, ',', '.') }} {{ number_format($summary['paid_amount'], 0, ',', '.') }} {{ number_format($summary['sisa_tagihan'], 0, ',', '.') }}
@if($historyPurchases->hasPages())
{{ $historyPurchases->links() }}
@endif
@elseif($viewMode === 'form')

{{ $editPurchaseId ? '✍️ Edit Pembelian Procurement' : '📝 Input Pembelian Procurement' }}

Form untuk mencatat {{ $editPurchaseId ? 'perubahan pada data' : 'data' }} belanja stok bahan baku kepada supplier secara premium.

@if($errorMessage)
⚠️ {{ $errorMessage }}
@endif

📌 DETAIL INFORMASI NOTA

@error('supplier_id') {{ $message }} @enderror

🛒 DAFTAR ITEM BAHAN BAKU

@foreach($items as $index => $item)
Rp {{ number_format($item['total'] ?? 0, 0, ',', '.') }}
@if(count($items) > 1) @endif
@endforeach

📊 RINGKASAN & BIAYA TAMBAHAN

Nilai potongan diskon akan didistribusikan secara proporsional ke masing-masing bahan baku. Persediaan bahan baku akan dibukukan pada nilai bersih setelah diskon (pro-rata net value) untuk menjaga akurasi pembukuan di neraca saldo.

Subtotal Bahan: Rp {{ number_format($this->subtotal, 0, ',', '.') }}
Potongan Diskon Item: - Rp {{ number_format($this->itemDiscount, 0, ',', '.') }}
Diskon Nota Tambahan: - Rp {{ number_format($additional_discount, 0, ',', '.') }}
Pajak PPN: + Rp {{ number_format($this->tax_amount, 0, ',', '.') }}
TOTAL HUTANG PEMBELIAN: Rp {{ number_format($this->grandTotal, 0, ',', '.') }}
@elseif($viewMode === 'detail' && $detailPurchase) @php $sisaTagihan = max(0, $detailPurchase->grand_total - $detailPurchase->paid_amount); @endphp

📄 Detail Pembelian #{{ $detailPurchase->purchase_number }}

Tanggal: {{ date('d M Y H:i', strtotime($detailPurchase->created_at)) }} | Cabang: {{ $detailPurchase->branch->name ?? 'Global' }}

@if($successMessage)
✅ {{ $successMessage }}
@endif @if($errorMessage)
⚠️ {{ $errorMessage }}
@endif

Supplier

{{ $detailPurchase->supplier->name ?? '-' }}

Status Pembayaran

@if($detailPurchase->status === 'paid' || $sisaTagihan <= 0) LUNAS @elseif($detailPurchase->status === 'partially_paid') CICIL / DP @else BELUM BAYAR @endif

Jatuh Tempo

{{ $detailPurchase->due_date ? date('d M Y', strtotime($detailPurchase->due_date)) : 'LUNAS' }}

🛒 Rincian Item

@foreach($detailPurchase->items as $item) @endforeach
Item / Bahan Baku Harga Qty Subtotal
{{ $item->rawMaterial->name ?? 'Unknown' }} Rp {{ number_format($item->price, 0, ',', '.') }} {{ $item->quantity }} Rp {{ number_format($item->total, 0, ',', '.') }}
@if($sisaTagihan > 0)

💸 CATAT PEMBAYARAN BARU

@endif

Ringkasan Tagihan

Subtotal Item Rp {{ number_format($detailPurchase->subtotal, 0, ',', '.') }}
Pajak (Tax) Rp {{ number_format($detailPurchase->tax_amount, 0, ',', '.') }}
GRAND TOTAL Rp {{ number_format($detailPurchase->grand_total, 0, ',', '.') }}
Total Dibayar Rp {{ number_format($detailPurchase->paid_amount, 0, ',', '.') }}
SISA TAGIHAN Rp {{ number_format($sisaTagihan, 0, ',', '.') }}
@endif