@php $product = $this->product; $batches = $this->getBatches(); $totalRemaining = $batches->sum('remaining'); $totalBatchQty = $batches->sum('quantity'); @endphp
{{-- Header --}}

{{ $product->name }}

SKU: {{ $product->sku ?? '-' }} | Satuan: {{ $product->unit }}

{{-- Desktop: Table --}}
@forelse($batches as $batch) @php $remaining = (float) $batch->remaining; $adjusted = (float) $batch->adjusted; $used = (float) $batch->quantity - $remaining - $adjusted; $ref = $batch->reference ?: ($batch->purchaseOrder?->po_number ?? 'Batch #' . $batch->id); $isFromPO = (bool) $batch->purchase_order_id; $isFromSO = str_starts_with($batch->reference ?? '', 'SO-'); $isFromSync = str_contains($batch->reference ?? '', 'Sinkronisasi'); $source = $isFromPO ? 'PO' : ($isFromSO ? 'Opname' : ($isFromSync ? 'Sync' : 'Manual')); $sourceBg = $isFromPO ? 'background:#DBEAFE;color:#1E40AF;' : ($isFromSO ? 'background:#FEF3C7;color:#92400E;' : 'background:#E5E7EB;color:#374151;'); $poNumber = $batch->purchaseOrder?->po_number; @endphp @empty @endforelse
BATCH / NOTA SUMBER HARGA AWAL SISA TERJUAL ADJUST AKSI
{{ $ref }}
@if($poNumber && $ref !== $poNumber)
{{ $poNumber }}
@endif
{{ $source }} Rp {{ number_format((float) $batch->cost_per_unit, 0, ',', '.') }} {{ number_format((float) $batch->quantity, 0, ',', '.') }} {{ number_format($remaining, 0, ',', '.') }} {{ number_format(max(0, $used), 0, ',', '.') }} {{ $adjusted > 0 ? number_format($adjusted, 0, ',', '.') : '0' }} @if($used > 0) Terjual @else - @endif
Belum ada batch untuk produk ini.
{{-- Mobile: Card list --}}
@forelse($batches as $batch) @php $remaining = (float) $batch->remaining; $adjusted = (float) $batch->adjusted; $used = (float) $batch->quantity - $remaining - $adjusted; $ref = $batch->reference ?: ($batch->purchaseOrder?->po_number ?? 'Batch #' . $batch->id); $isFromPO = (bool) $batch->purchase_order_id; $isFromSO = str_starts_with($batch->reference ?? '', 'SO-'); $isFromSync = str_contains($batch->reference ?? '', 'Sinkronisasi'); $source = $isFromPO ? 'PO' : ($isFromSO ? 'Opname' : ($isFromSync ? 'Sync' : 'Manual')); $sourceBg = $isFromPO ? 'background:#DBEAFE;color:#1E40AF;' : ($isFromSO ? 'background:#FEF3C7;color:#92400E;' : 'background:#E5E7EB;color:#374151;'); @endphp
{{-- Row 1: Batch ref + source badge --}}

{{ $ref }}

{{ $source }}
{{-- Row 2: Stats grid --}}

Harga

{{ number_format((float) $batch->cost_per_unit, 0, ',', '.') }}

Awal

{{ number_format((float) $batch->quantity, 0, ',', '.') }}

Sisa

{{ number_format($remaining, 0, ',', '.') }}

Terjual

{{ number_format(max(0, $used), 0, ',', '.') }}

{{-- Row 3: Adjust + Action --}}
Adjust: {{ $adjusted > 0 ? number_format($adjusted, 0, ',', '.') : '0' }} @if($used > 0) Terjual @else - @endif
@empty

Belum ada batch untuk produk ini.

@endforelse