@extends('layouts.app') @section('content')

{{ $fund->name ?? $fund->holder }}

{{ $fund->purpose ?? 'General Fund' }} · Held by {{ $fund->holder }}

@if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash'))
@csrf @method('PUT')
@endif
@php $totalFund = $fund->amount + $fund->total_top_up; $spent = $totalFund - $fund->balance; $pct = $totalFund > 0 ? round(($fund->balance / $totalFund) * 100) : 0; $entryCount = ($entries ?? collect())->count(); $topupCount = ($topups ?? collect())->count(); @endphp

Initial Amount

{{ $currentBusiness->currency_symbol }}{{ number_format($fund->amount) }}

Top-ups

+{{ $currentBusiness->currency_symbol }}{{ number_format($fund->total_top_up) }}

Total Fund

{{ $currentBusiness->currency_symbol }}{{ number_format($totalFund) }}

Spent

{{ $currentBusiness->currency_symbol }}{{ number_format($spent) }}

Balance

{{ $currentBusiness->currency_symbol }}{{ number_format($fund->balance) }}

{{ $pct }}% remaining

Status

{{ $fund->status }}

Location

{{ $fund->location ?? '-' }}

Payment

{{ $fund->payment_method }}

Received From

{{ $fund->received_from ?? '-' }}

Approved By

{{ $fund->approved_by ?? '-' }}

Date Created

{{ \Carbon\Carbon::parse($fund->date)->format('d M Y') }}

@if($fund->notes)
Notes:

{{ $fund->notes }}

@endif
@if(($heads ?? collect())->count() > 0)

Spending Heads

@foreach($heads as $head) @php $headPct = $head->allocated > 0 ? round((($head->allocated - $head->balance) / $head->allocated) * 100) : 0; @endphp @endforeach
@endif

Cash Received / Top-ups

@if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash')) @endif
@forelse($topups ?? [] as $topup) @empty @endforelse @if(($topups ?? collect())->count() > 0) @endif
Date Amount Source Notes
{{ $topup->date->format('d M Y') }} +{{ $currentBusiness->currency_symbol }}{{ number_format($topup->amount) }} {{ $topup->source ?? '-' }} {{ $topup->notes ?? '-' }}

No cash received yet.

@if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash')) @endif
Total Cash In +{{ $currentBusiness->currency_symbol }}{{ number_format(($topups ?? collect())->sum('amount')) }}

Expenses

@if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash')) @endif
@if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash')) @endif @forelse($entries ?? [] as $entry) @if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash')) @endif @empty @endforelse @if(($entries ?? collect())->count() > 0) @if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash')) @endif @endif
Date Description Head Paid To Receipt AmountActions
{{ $entry->date->format('d M Y') }} {{ $entry->description }} @if($entry->category) {{ $entry->category }} @endif @if($entry->head) {{ $entry->head->name }} @else - @endif {{ $entry->paid_to ?? '-' }} @if($entry->receipt_file) {{ $entry->receipt_file_name ?? 'View' }} @elseif($entry->receipt_ref) {{ $entry->receipt_ref }} @else - @endif -{{ $currentBusiness->currency_symbol }}{{ number_format($entry->amount) }}
@csrf @method('DELETE')

No expenses logged yet.

@if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash')) @endif
Total Cash Out -{{ $currentBusiness->currency_symbol }}{{ number_format(($entries ?? collect())->sum('amount')) }}
@php $totalAllocated = ($heads ?? collect())->sum('allocated'); $unallocated = $totalFund - $totalAllocated; @endphp

Unallocated Pool

{{ $currentBusiness->currency_symbol }}{{ number_format($unallocated) }}

Total Fund: {{ $currentBusiness->currency_symbol }}{{ number_format($totalFund) }} | Allocated: {{ $currentBusiness->currency_symbol }}{{ number_format($totalAllocated) }}

@if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash')) @endif
@foreach($heads ?? [] as $head) @php $headSpent = $head->total_out; $headAllocated = $head->allocated; $headBalance = $head->balance; $headPctUsed = $headAllocated > 0 ? round(($headSpent / $headAllocated) * 100) : 0; @endphp

{{ $head->name }}

@if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash'))
@endif

Allocated

{{ $currentBusiness->currency_symbol }}{{ number_format($headAllocated) }}

Spent

{{ $currentBusiness->currency_symbol }}{{ number_format($headSpent) }}

Balance

{{ $currentBusiness->currency_symbol }}{{ number_format($headBalance) }}

{{ $headPctUsed }}% used

@endforeach
@if(($headTransfers ?? collect())->count() > 0)

Transfer History

@if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash')) @endif
@foreach($headTransfers as $transfer) @endforeach
Date From To Amount Reason
{{ $transfer->date->format('d M Y') }} @if($transfer->fromHead) {{ $transfer->fromHead->name }} @else - @endif @if($transfer->toHead) {{ $transfer->toHead->name }} @else - @endif {{ $currentBusiness->currency_symbol }}{{ number_format($transfer->amount) }} {{ $transfer->reason ?? '-' }}
@else

No head transfers yet.

@if(auth()->user()->hasPermission($currentBusiness->id, 'can_edit_petty_cash')) @endif
@endif
@endsection