{{-- resources/views/exports/income_statement_pdf.blade.php
Rendered by IncomeStatementController::exportIncomeStatement(), which
passes named variables rather than spreading an array:
data, displayType, organisation, fromDate, toDate, job, comparisonData,
comparisonMeta, mergedSections.
Note the underscored filename — the controller asks for
'exports.income_statement_pdf' while the other reports use hyphens. The
filename follows the controller rather than the convention, so the view
resolves without touching the call site.
displayType is 'monthly', 'comparison', or anything else meaning the plain
statement. --}}
Income Statement
@include('exports._report-styles')
{{ \Carbon\Carbon::parse($fromDate)->format('d/m/Y') }}
to
{{ \Carbon\Carbon::parse($toDate)->format('d/m/Y') }}
@if ($job)
— Fund: {{ $job->name ?? '' }}
@endif
@php $money = fn ($v) => number_format((float) $v, 2); @endphp
@if ($displayType === 'monthly')
@php
$months = $data['months'] ?? [];
$summary = $data['monthly_summary'] ?? [];
$totals = $data['totals'] ?? [];
$measures = [
'revenue' => 'Revenue',
'direct_cost' => 'Direct Cost',
'gross_surplus' => 'Gross Surplus',
'other_income' => 'Other Income',
'expenses' => 'Expenses',
'surplus_before_tax' => 'Surplus Before Tax',
'taxation' => 'Taxation',
'surplus_after_tax' => 'Surplus After Tax',
];
@endphp
| Particulars |
@foreach ($months as $month)
{{ $month['label'] ?? '' }} |
@endforeach
Total |
@foreach ($measures as $key => $label)
| {{ $label }} |
@foreach ($summary as $month)
{{ $money($month[$key] ?? 0) }} |
@endforeach
{{ $money($totals[$key] ?? 0) }} |
@endforeach
@elseif ($displayType === 'comparison' && ! empty($mergedSections))
| Code |
Particulars |
{{ $comparisonMeta['current_label'] ?? 'Current' }} |
{{ $comparisonMeta['comparison_label'] ?? 'Comparison' }} |
@foreach ($mergedSections as $sectionName => $section)
| {{ strtoupper(str_replace('_', ' ', $sectionName)) }} |
@foreach (($section['items'] ?? $section) as $item)
@if (is_array($item))
| {{ $item['code'] ?? '' }} |
{{ $item['name'] ?? '' }} |
{{ $money($item['current'] ?? ($item['balance'] ?? 0)) }} |
{{ $money($item['comparison'] ?? 0) }} |
@endif
@endforeach
@if (isset($section['total']) || isset($section['comparison_total']))
|
Total |
{{ $money($section['total'] ?? 0) }} |
{{ $money($section['comparison_total'] ?? 0) }} |
@endif
@endforeach
@else
@php
$sections = [
['key' => 'revenue', 'label' => 'REVENUE'],
['key' => 'direct_cost', 'label' => 'DIRECT COST'],
['key' => 'other_income', 'label' => 'OTHER INCOME'],
['key' => 'expenses', 'label' => 'EXPENSES'],
['key' => 'taxation', 'label' => 'TAXATION'],
];
// Running subtotals sit between specific sections, not after each one.
$after = [
'direct_cost' => ['Gross Surplus', $data['gross_surplus'] ?? 0],
'expenses' => ['Surplus Before Tax', $data['surplus_before_tax'] ?? 0],
'taxation' => ['Surplus After Tax', $data['surplus_after_tax'] ?? 0],
];
@endphp
| Code |
Particulars |
Amount |
@foreach ($sections as $section)
@php $block = $data[$section['key']] ?? ['items' => [], 'total' => 0]; @endphp
| {{ $section['label'] }} |
@forelse ($block['items'] ?? [] as $item)
| {{ $item['code'] ?? '' }} |
{{ $item['name'] ?? '' }} |
{{ $money($item['balance'] ?? 0) }} |
@empty
| No entries for this period. |
@endforelse
|
Total {{ ucfirst(strtolower($section['label'])) }} |
{{ $money($block['total'] ?? 0) }} |
@isset($after[$section['key']])
|
{{ $after[$section['key']][0] }} |
{{ $money($after[$section['key']][1]) }} |
@endisset
@endforeach
@endif