@if(!empty($organisation->logo)) @php $logoPath = 'storage/app/public/' . ltrim(str_replace('storage/', '', $organisation->logo), '/'); $absolutePath = base_path($logoPath); @endphp @if(file_exists($absolutePath)) @endif @endif

{{ $organisation->organisation_name }}

Budget vs Actual Comparison Report

Period: {{ \Carbon\Carbon::parse($start_date)->format('M j, Y') }} to {{ \Carbon\Carbon::parse($end_date)->format('M j, Y') }}

Budget: {{ $budget->name }} • Period Type: {{ ucfirst($period) }} • As of: {{ $as_of_date }}

Currency: {{ $currency }}
Generated on: {{ now()->format('M j, Y H:i') }}
@php $allAccounts = []; // Get all unique accounts across all periods foreach ($data as $periodData) { foreach ($periodData as $accountId => $accountData) { if (!isset($allAccounts[$accountId])) { $allAccounts[$accountId] = $accountData['account_name']; } } } // Calculate grand totals $grandBudgetTotal = 0; $grandActualTotal = 0; $grandVarianceTotal = 0; @endphp @foreach($data as $periodLabel => $periodData)

{{ $periodLabel }} ({{ \Carbon\Carbon::parse($periodData[array_key_first($periodData)]['start_date'] ?? $start_date)->format('M d') }} - {{ \Carbon\Carbon::parse($periodData[array_key_first($periodData)]['end_date'] ?? $end_date)->format('M d, Y') }})

@php $periodBudgetTotal = 0; $periodActualTotal = 0; $periodVarianceTotal = 0; $itemsPerPage = 20; $currentItem = 0; @endphp @foreach($allAccounts as $accountId => $accountName) @php $accountData = $periodData[$accountId] ?? [ 'account_name' => $accountName, 'budgeted' => 0, 'actual' => 0, 'variance' => 0 ]; $currentItem++; $periodBudgetTotal += $accountData['budgeted']; $periodActualTotal += $accountData['actual']; $periodVarianceTotal += $accountData['variance']; $grandBudgetTotal += $accountData['budgeted']; $grandActualTotal += $accountData['actual']; $grandVarianceTotal += $accountData['variance']; $variancePercent = $accountData['budgeted'] != 0 ? ($accountData['variance'] / $accountData['budgeted']) * 100 : 0; @endphp @if($currentItem % $itemsPerPage == 0)
Account Budget Amount Actual Amount Variance Variance %
@endif @endforeach @php $periodVariancePercent = $periodBudgetTotal != 0 ? ($periodVarianceTotal / $periodBudgetTotal) * 100 : 0; @endphp
Account Budget Amount Actual Amount Variance Variance %
{{ $accountData['account_name'] }} {{ number_format($accountData['budgeted'], 2) }} {{ number_format($accountData['actual'], 2) }} {{ number_format($accountData['variance'], 2) }} {{ number_format(abs($variancePercent), 2) }}%
Period Total {{ number_format($periodBudgetTotal, 2) }} {{ number_format($periodActualTotal, 2) }} {{ number_format($periodVarianceTotal, 2) }} {{ number_format(abs($periodVariancePercent), 2) }}%
@if(!$loop->last)
@endif @endforeach @php $grandVariancePercent = $grandBudgetTotal != 0 ? ($grandVarianceTotal / $grandBudgetTotal) * 100 : 0; @endphp
Grand Totals (All Periods Combined)
Summary Budget Amount Actual Amount Variance Variance %
All Accounts {{ number_format($grandBudgetTotal, 2) }} {{ number_format($grandActualTotal, 2) }} {{ number_format($grandVarianceTotal, 2) }} {{ number_format(abs($grandVariancePercent), 2) }}%