@extends('temple.layouts.app') @section('title', 'Receipt #' . ($receipt->receipt_number ?: str_pad($receipt->id, 6, '0', STR_PAD_LEFT))) @section('content') @php /* |-------------------------------------------------------------------------- | DEVOTEE GROUPS (same logic as receipts index / receipt view) |-------------------------------------------------------------------------- | One group per devotee, each with its own items. | Old receipts (no devotee rows) fall back to devotee_name + items. */ $devotees = $receipt->devotees ?? collect(); if (! $devotees instanceof \Illuminate\Support\Collection) { $devotees = collect($devotees); } $groups = collect(); foreach ($devotees as $devoteeRow) { $groupItems = $devoteeRow->items ?? collect(); if (! $groupItems instanceof \Illuminate\Support\Collection) { $groupItems = collect($groupItems); } $groups->push([ 'name' => $devoteeRow->devotee_name ?: 'Walk-in Devotee', 'nakshatram' => $devoteeRow->nakshatram, 'items' => $groupItems, ]); } if ($groups->isEmpty()) { $legacyItems = $receipt->items ?? collect(); if (! $legacyItems instanceof \Illuminate\Support\Collection) { $legacyItems = collect($legacyItems); } $groups->push([ 'name' => $receipt->devotee_name ?: 'Walk-in Devotee', 'nakshatram' => $receipt->nakshatram, 'items' => $legacyItems, ]); } $groupCount = $groups->count(); $grandTotal = $groups->sum(function ($group) { return $group['items']->sum(function ($item) { return (float) ($item->amount ?? 0); }); }); $grandQuantity = $groups->sum(function ($group) { return $group['items']->sum(function ($item) { return (int) ($item->quantity ?? 0); }); }); $totalAmount = (float) ($receipt->total_amount ?: $grandTotal); $pStatus = strtolower($receipt->payment_status ?? 'pending'); @endphp {{-- ============================================================ PRINT-ONLY STYLES These rules only take effect when printing (window.print()). On screen, nothing below changes — the print voucher stays hidden. ============================================================ --}} {{-- ============================================================ PRINT-ONLY VOUCHER MARKUP — invisible on screen, only rendered when the page is printed. ============================================================ --}}
| Vazhipad | Qty | Amount |
|---|---|---|
| {{ $item->vazhipad?->name ?? $item->vazhipad?->vazhipad_name ?? 'Offering' }} | {{ $item->quantity ?? 1 }} | ₹{{ number_format((float) ($item->amount ?? 0), 2) }} |
| No Vazhipad | ||
| # | Vazhipad Offering | Quantity | Amount (₹) |
|---|---|---|---|
| {{ $loop->iteration }} | {{ $item->vazhipad?->name ?? $item->vazhipad?->vazhipad_name ?? 'Offering' }} | {{ $item->quantity ?? 1 }} | ₹{{ number_format((float) ($item->amount ?? 0), 2) }} |
| No offering items attached to this devotee. | |||
| {{ $group['name'] }} Total | {{ $groupQty }} | ₹{{ number_format($groupTotal, 2) }} | |
| Total Contribution Amount | {{ $grandQuantity }} items | ₹{{ number_format($totalAmount, 2) }} | |