@extends('pdf.layout') @section('content') @php $n = fn ($v) => rtrim(rtrim(number_format((float) $v, 2), '0'), '.') ?: '0'; $m = fn ($v) => number_format((float) $v, 2); @endphp
Current stock
{{ $n($product->current_stock) }} {{ $product->unit->short_name ?? '' }}
Alert at {{ $n($product->alertLevel()) }}
Sold
{{ $n($salesTotals->qty) }}
MWK {{ $m($salesTotals->amount) }} in {{ $salesTotals->count }} sale(s)
Purchased / stock in
{{ $n($purchaseTotals->qty) }}
MWK {{ $m($purchaseTotals->amount) }}
Prices
MWK {{ $m($product->selling_price) }}
Cost MWK {{ $m($product->purchase_price) }}

{{ $product->category->name ?? 'No category' }}{{ $product->brand ? ' - ' . $product->brand->name : '' }}{{ $product->supplier ? ' - Supplier: ' . $product->supplier->name : '' }}

Sales ({{ $sales->total() }})

@if($sales->count()) @foreach($sales as $item) @endforeach
DateInvoiceCustomerPaymentQtyPriceAmount (MWK)Sold by
{{ \Carbon\Carbon::parse($item->sold_at)->format('d M Y H:i') }} {{ $item->sale->invoice_no ?? '-' }}@if($item->sale?->is_edited) edited@endif {{ $item->sale->customer_name ?? 'Walk-in' }} {{ ucwords(str_replace('_', ' ', $item->sale->payment_method ?? '-')) }} {{ $n($item->quantity) }} {{ $m($item->price) }} {{ $m($item->subtotal) }} {{ ($item->sale?->user ?? $item->sale?->register?->user)->name ?? '-' }}
Total{{ $n($salesTotals->qty) }}{{ $m($salesTotals->amount) }}
@else
No sales in this period.
@endif

Purchases and stock in ({{ $purchases->total() }})

@if($purchases->count()) @foreach($purchases as $row) @endforeach
DateReferenceSupplierStatusQtyUnit costTotal (MWK)ExpiryBy
{{ $row->date->format('d M Y') }} {{ $row->reference }} {{ $row->supplier }} {{ ucfirst($row->status) }} {{ $n($row->quantity) }} {{ $m($row->unit_cost) }} {{ $m($row->line_total) }} {{ $row->expiry ? \Carbon\Carbon::parse($row->expiry)->format('d M Y') : '-' }} {{ $row->user }}
Total{{ $n($purchaseTotals->qty) }}{{ $m($purchaseTotals->amount) }}
@else
No purchases or stock in this period.
@endif

Stock adjustments ({{ $adjustments->total() }})

@if($adjustments->count()) @foreach($adjustments as $a) @endforeach
DateTypeChangeStock before / afterPrice changeReasonBy
{{ $a->created_at->format('d M Y H:i') }} {{ $a->adjustment_type_text }} {{ $a->quantity_change }} {{ $n($a->previous_quantity) }} → {{ $n($a->new_quantity) }} {{ $a->previous_price != $a->new_price ? $m($a->previous_price) . ' -> ' . $m($a->new_price) : '-' }} {{ $a->reason }} {{ $a->user->name ?? '-' }}
@else
No stock adjustments in this period.
@endif

Stock at each register opening and closing ({{ $registers->total() }})

@if($registers->count()) @foreach($registers as $register) @php $open = $register->stock_opening; $close = $register->stock_closing; $change = $open && $close ? (float) $close['qty'] - (float) $open['qty'] : null; @endphp @endforeach
DayRegisterOpenedStock at openingClosedStock at closingChange
{{ $register->opened_at->format('D d M Y') }} #{{ $register->id }} {{ $register->user->name ?? '' }} {{ $register->opened_at->format('H:i') }} {{ $open ? $n($open['qty']) . ($open['estimated'] ? ' est.' : '') : '-' }} {{ $register->closed_at?->format('H:i') ?? 'open' }} {{ $close ? $n($close['qty']) . ($close['estimated'] ? ' est.' : '') : '-' }} {{ $change === null ? '-' : (($change > 0 ? '+' : '') . $n($change)) }}

"est." = worked out from the stock history (no snapshot was taken for that register).

@else
No registers in this period.
@endif @endsection