@extends('documents.procurement._layout', [ 'documentTitle' => 'Goods Receipt Note', 'reference' => $grn->grn_reference, 'documentDate' => \Carbon\Carbon::parse($grn->received_date)->format('d M Y'), ]) @section('header-meta') @if($grn->lpo)
LPO Ref: {{ $grn->lpo->lpo_reference }}
@endif
{{ strtoupper($grn->status) }}
@endsection @section('content') @php $supplier = $grn->supplier; $location = $grn->deliveryLocation; $conditionColors = ['good' => 'bg-green', 'short' => 'bg-amber', 'damaged' => 'bg-red']; @endphp {{-- Supplier + Receipt details --}}
Supplier:
{{ $supplier?->name ?? '—' }}
@if($supplier?->contact_name) {{ $supplier->contact_name }}
@endif @if($supplier?->contact_phone) {{ $supplier->contact_phone }}
@endif
Receipt Details:
@if($location) Delivery Location: {{ $location->name }}
@endif Received By: {{ $grn->receivedBy?->name ?? '—' }}
@if($grn->delivery_note_number) Delivery Note: {{ $grn->delivery_note_number }}
@endif
{{-- Items table --}} @foreach($grn->items as $i => $item) @php $colorClass = $conditionColors[$item->condition] ?? ''; @endphp @if($item->variance_reason) @endif @endforeach
# Product SKU Ordered Received Condition Unit Cost Line Total
{{ $i + 1 }} {{ $item->product?->name ?? '—' }} {{ $item->product?->sku ?? '—' }} {{ number_format((float) ($item->lpoItem?->quantity ?? 0), 0) }} {{ number_format((float) $item->quantity_received, 0) }} {{ ucfirst($item->condition) }} {{ number_format((float) $item->unit_cost_source, 2) }} {{ number_format((float) ($item->quantity_received * $item->unit_cost_source), 2) }}
Variance: {{ ucwords(str_replace('_', ' ', $item->variance_reason)) }}
{{-- Totals --}} @php $src = $grn->lpo?->source_currency_code ?? $org->currency_code ?? 'UGX'; $base = $org->currency_code ?? 'UGX'; $isForeign = $src !== $base; $subtotalSrc = (float) $grn->subtotal_source ?: $grn->items->filter(fn($i) => $i->quantity_received > 0)->sum(fn($i) => $i->quantity_received * $i->unit_cost_source); $hasCharges = (float) $grn->total_amount_source > 0 && (float) $grn->total_amount_source !== $subtotalSrc; @endphp @if($hasCharges) @if((float) $grn->tax_amount_source > 0) @endif @if((float) $grn->freight_amount_source > 0) @endif @if((float) $grn->insurance_amount_source > 0) @endif @if((float) $grn->other_charges_source > 0) @endif @endif @if($isForeign && $hasCharges) @endif
Items Received {{ $grn->items->where('quantity_received', '>', 0)->sum('quantity_received') }}
Subtotal ({{ $src }}) {{ number_format($subtotalSrc, 2) }}
Tax {{ number_format((float) $grn->tax_amount_source, 2) }}
Freight {{ number_format((float) $grn->freight_amount_source, 2) }}
Insurance {{ number_format((float) $grn->insurance_amount_source, 2) }}
Other Charges {{ number_format((float) $grn->other_charges_source, 2) }}
Grand Total ({{ $src }}) {{ number_format($hasCharges ? (float) $grn->total_amount_source : $subtotalSrc, 2) }}
Equivalent ({{ $base }}) {{ $base }} {{ number_format((float) $grn->total_amount_base, 2) }}
{{-- Signature block --}}
Received By
{{ $grn->receivedBy?->name ?? '—' }}
Checked By
 
Date
{{ \Carbon\Carbon::parse($grn->received_date)->format('d M Y') }}
@endsection