@include('templates.pdf_header', [ 'organisation' => $organisation, 'asOfDate' => $asOfDate, 'title' => APPROVED BUDGET ])

Budget Name: {{ $budget->name }}

Budget Period: {{ $budget_period }}

Approval Date: {{ $budget->approved_at?->format('F j, Y') ?? '—' }}

Currency: {{ $currency }}

Generated On: {{ $date }}

@php // Categorize allocations $incomeAllocations = $allocations->filter(fn($a) => str_contains(strtolower($a->name), 'income') || str_contains(strtolower($a->name), 'revenue') ); $expenseAllocations = $allocations->filter(fn($a) => !str_contains(strtolower($a->name), 'income') && !str_contains(strtolower($a->name), 'revenue') ); @endphp {{-- ===== INCOME SECTION ===== --}} @if($incomeAllocations->count())

INCOME

@foreach($incomeAllocations as $index => $allocation) @if($index > 0 && $index % 2 == 0)
@endif

{{ $allocation->name }} ({{ $allocation->code ?? 'N/A' }})

@foreach($allocation->items as $item) @endforeach
Item Description Code Previous Estimate Approved Amount Remarks
{{ $item->chartOfAccount->name ?? $item->description ?? 'N/A' }} {{ $item->chartOfAccount->code ?? '-' }} {{ number_format($item->previous_estimate, 2) }} {{ number_format($item->approved_amount, 2) }} {{ $item->remarks ?? '-' }}
Total {{ $allocation->name }} {{ number_format($allocation->items->sum('approved_amount'), 2) }}
@endforeach
@endif {{-- ===== EXPENSES SECTION ===== --}} @if($expenseAllocations->count())

EXPENSES

@foreach($expenseAllocations as $index => $allocation) @if($index > 0 && $index % 2 == 0)
@endif

{{ $allocation->name }} ({{ $allocation->code ?? 'N/A' }})

@foreach($allocation->items as $item) @endforeach
Item Description Code Previous Estimate Approved Amount Remarks
{{ $item->chartOfAccount->name ?? $item->description ?? 'N/A' }} {{ $item->chartOfAccount->code ?? '-' }} {{ number_format($item->previous_estimate, 2) }} {{ number_format($item->approved_amount, 2) }} {{ $item->remarks ?? '-' }}
Total {{ $allocation->name }} {{ number_format($allocation->items->sum('approved_amount'), 2) }}
@endforeach
@endif {{-- ===== SUMMARY SECTION ===== --}}

Total Income: {{ number_format($total_income, 2) }}

Total Expenses: {{ number_format($total_expenses, 2) }}

Net Total: {{ number_format($net_total, 2) }}

Grand Total (Approved Budget): {{ number_format($total_income + $total_expenses, 2) }}