@extends('temple.layouts.app') @section('title', 'Mark Payment — ' . ($receipt->receipt_number ?: $receipt->id)) @section('content') @php /* |-------------------------------------------------------------------------- | DEVOTEE GROUPS (same logic as receipts index / receipt view) |-------------------------------------------------------------------------- */ $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); @endphp
{{-- Header --}}

Counter Payment Update

Update payment status and collection method for Receipt #{{ $receipt->receipt_number ?: $receipt->id }}

@if ($errors->any())
Please review the following:
    @foreach ($errors->all() as $error)
  • {{ $error }}
  • @endforeach
@endif {{-- Devotee & Receipt Summary Card --}}

Receipt Summary

{{ $receipt->receipt_number ?: '#RC-' . str_pad($receipt->id, 6, '0', STR_PAD_LEFT) }}
Devotee Name
{{ $groups->first()['name'] }} @if($groupCount > 1) +{{ $groupCount - 1 }} more @endif
Nakshatram
@if($groupCount > 1) Multiple — see below @elseif(!empty($groups->first()['nakshatram'])) {{ $groups->first()['nakshatram'] }} @else — @endif
Receipt Date
{{ optional($receipt->receipt_date ?: $receipt->receipts_date)->format('d M Y') ?: 'N/A' }}
Total Amount
₹{{ number_format($totalAmount, 2) }}
@foreach ($groups as $group) @php $groupTotal = $group['items']->sum(fn ($i) => (float) ($i->amount ?? 0)); $groupQty = $group['items']->sum(fn ($i) => (int) ($i->quantity ?? 0)); @endphp {{-- Devotee heading row (only when more than one devotee) --}} @if($groupCount > 1) @endif @forelse ($group['items'] as $item) @empty @endforelse @if($groupCount > 1) @endif @endforeach
Vazhipad Offering Quantity Amount (₹)
Devotee {{ $loop->iteration }} — {{ $group['name'] }} @if(!empty($group['nakshatram'])) {{ $group['nakshatram'] }} @endif
{{ $item->vazhipad?->name ?? $item->vazhipad?->vazhipad_name ?? 'Offering' }} {{ $item->quantity ?? 1 }} ₹{{ number_format((float) ($item->amount ?? 0), 2) }}
No Vazhipad items found.
{{ $group['name'] }} Total {{ $groupQty }} ₹{{ number_format($groupTotal, 2) }}
Grand Total {{ $grandQuantity }} items ₹{{ number_format($totalAmount, 2) }}
{{-- Payment Form Card --}}

Update Counter Payment

@csrf @method('PATCH')
₹
₹
Cannot exceed the total amount of ₹{{ number_format($totalAmount, 2) }}.
Cancel
@push('scripts') @endpush @endsection