@extends('layouts.master') @section('page_title', 'Income Statement (Profit & Loss)') @section('content')

Income Statement

Print PDF
Income Statement
For the period from {{ \Carbon\Carbon::parse($startDate ?? date('Y-01-01'))->format('F j, Y') }} to {{ \Carbon\Carbon::parse($endDate ?? date('Y-m-d'))->format('F j, Y') }}
@php $totalRevenue = 0; $revenueCategories = [ 'Student Fees' => [], 'Grants & Donations' => [], 'Other Revenue' => [] ]; // Group revenue accounts foreach ($revenue ?? [] as $revenueAccount) { if (stripos($revenueAccount->name, 'fee') !== false || stripos($revenueAccount->name, 'tuition') !== false) { $revenueCategories['Student Fees'][] = $revenueAccount; } elseif (stripos($revenueAccount->name, 'grant') !== false || stripos($revenueAccount->name, 'donation') !== false) { $revenueCategories['Grants & Donations'][] = $revenueAccount; } else { $revenueCategories['Other Revenue'][] = $revenueAccount; } $totalRevenue += $revenueAccount->balance ?? 0; } @endphp @foreach($revenueCategories as $categoryName => $categoryRevenue) @if(count($categoryRevenue) > 0) @php $categoryTotal = 0; @endphp @foreach($categoryRevenue as $revenue) @php $categoryTotal += $revenue->balance ?? 0; @endphp @endforeach @endif @endforeach @php $totalExpenses = 0; $expenseCategories = [ 'Personnel Expenses' => [], 'Administrative Expenses' => [], 'Facilities & Utilities' => [], 'Educational Expenses' => [], 'Other Expenses' => [] ]; // Group expense accounts foreach ($expenses ?? [] as $expenseAccount) { if (stripos($expenseAccount->name, 'salary') !== false || stripos($expenseAccount->name, 'wage') !== false || stripos($expenseAccount->name, 'payroll') !== false) { $expenseCategories['Personnel Expenses'][] = $expenseAccount; } elseif (stripos($expenseAccount->name, 'admin') !== false || stripos($expenseAccount->name, 'office') !== false) { $expenseCategories['Administrative Expenses'][] = $expenseAccount; } elseif (stripos($expenseAccount->name, 'utilities') !== false || stripos($expenseAccount->name, 'maintenance') !== false || stripos($expenseAccount->name, 'rent') !== false) { $expenseCategories['Facilities & Utilities'][] = $expenseAccount; } elseif (stripos($expenseAccount->name, 'supplies') !== false || stripos($expenseAccount->name, 'book') !== false || stripos($expenseAccount->name, 'educational') !== false) { $expenseCategories['Educational Expenses'][] = $expenseAccount; } else { $expenseCategories['Other Expenses'][] = $expenseAccount; } $totalExpenses += $expenseAccount->balance ?? 0; } @endphp @foreach($expenseCategories as $categoryName => $categoryExpenses) @if(count($categoryExpenses) > 0) @php $categoryTotal = 0; @endphp @foreach($categoryExpenses as $expense) @php $categoryTotal += $expense->balance ?? 0; @endphp @endforeach @endif @endforeach @php $netIncome = $totalRevenue - $totalExpenses; $netIncomeClass = $netIncome >= 0 ? 'text-success' : 'text-danger'; $netIncomeLabel = $netIncome >= 0 ? 'NET INCOME (SURPLUS)' : 'NET LOSS (DEFICIT)'; @endphp

REVENUE

{{ $categoryName }}
{{ $revenue->name }} {{ number_format($revenue->balance ?? 0, 2) }}
Total {{ $categoryName }} {{ number_format($categoryTotal, 2) }}
TOTAL REVENUE
{{ number_format($totalRevenue, 2) }}

EXPENSES

{{ $categoryName }}
{{ $expense->name }} {{ number_format($expense->balance ?? 0, 2) }}
Total {{ $categoryName }} {{ number_format($categoryTotal, 2) }}
TOTAL EXPENSES
{{ number_format($totalExpenses, 2) }}

{{ $netIncomeLabel }}

{{ number_format($netIncome, 2) }}

@if($netIncome >= 0) School is operating at a surplus!
The school's revenue exceeds its expenses. @else School is operating at a deficit!
The school's expenses exceed its revenue. @endif
Financial Summary:
Total Revenue: {{ number_format($totalRevenue, 2) }}
Total Expenses: {{ number_format($totalExpenses, 2) }}
Net Margin: {{ $totalRevenue > 0 ? number_format(($netIncome / $totalRevenue) * 100, 1) : '0' }}%
@endsection