@extends('layouts.app') @section('title', 'Purchases Report') @section('content') @php $qty = fn ($value) => rtrim(rtrim(number_format((float) $value, 2), '0'), '.'); $periods = ['' => 'This month', 'today' => 'Today', 'yesterday' => 'Yesterday', 'this_week' => 'This week', 'last_month' => 'Last month', 'this_year' => 'This year', 'all' => 'All time']; $customDates = request()->hasAny(['from', 'to']) && !request()->filled('period'); $activePeriod = $customDates ? null : request('period', ''); $periodText = $activePeriod === 'all' ? 'all time' : ($from->isSameDay($to) ? 'on ' . $from->format('l, d M Y') : 'from ' . $from->format('d M Y') . ' to ' . $to->format('d M Y')); $filtered = request()->hasAny(['supplier_id', 'product', 'batch_no', 'reference', 'payment_status', 'source']) && collect(request()->only(['supplier_id', 'product', 'batch_no', 'reference', 'payment_status', 'source']))->filter()->isNotEmpty(); $sourceTone = ['purchase' => 'primary', 'opening_stock' => 'info', 'bulk_products' => 'info', 'stock_adjustment' => 'success', 'bulk_stock' => 'success']; @endphp
All stock received {{ $periodText }}: purchases, opening stock of new products and stock adjustments.
| {{ $row->supplier ?? 'No supplier' }} | {{ $qty($row->quantity) }} units | {{ formatCurrency($row->cost) }} |
| Date | Product | Source | Batch | Qty | Unit cost | Cost | Sells for | By |
|---|---|---|---|---|---|---|---|---|
| {{ $item->purchase?->purchase_date?->format('d M Y') }} |
@if($item->product)
{{ $item->product->name }}
@else
Deleted product
@endif
{{ $item->purchase?->reference_no }}{{ $item->purchase?->supplier ? ' · ' . $item->purchase->supplier->name : '' }}
|
{{ $sources[$source] ?? 'Purchase' }} | {{ $item->batch_no ?? '-' }}@if($expiry) exp {{ \Carbon\Carbon::parse($expiry)->format('d M Y') }} @endif |
{{ $qty($item->quantity) }} | {{ formatCurrency($item->unit_cost) }} | {{ formatCurrency($item->line_total) }} | {{ formatCurrency((float) $item->quantity * (float) $item->selling_price) }} | {{ $item->purchase?->user?->name ?? '-' }} |
| Total {{ $items->total() > $items->count() ? '(all pages)' : '' }} | {{ $qty($totals->quantity) }} | {{ formatCurrency($totals->cost) }} | {{ formatCurrency($totals->sales_value) }} | |||||