Income Statement

For the Period: {{ \Carbon\Carbon::parse($startDate)->format('F d, Y') }} to {{ \Carbon\Carbon::parse($endDate)->format('F d, Y') }}

@php $revenue = $groupedAccounts->filter(function($items, $type) { return str_contains(strtolower($type), 'revenue') || str_contains(strtolower($type), 'income'); }); $expenses = $groupedAccounts->filter(function($items, $type) { return str_contains(strtolower($type), 'expense') || str_contains(strtolower($type), 'cost'); }); $totalRevenue = $accounts->filter(function($item) { return str_contains(strtolower($item->account_type), 'revenue') || str_contains(strtolower($item->account_type), 'income'); })->sum('balance'); $totalExpenses = $accounts->filter(function($item) { return str_contains(strtolower($item->account_type), 'expense') || str_contains(strtolower($item->account_type), 'cost'); })->sum('balance'); $netIncome = $totalRevenue - $totalExpenses; @endphp

REVENUE

@foreach($revenue as $accountType => $items)

{{ $accountType }}

@foreach($items as $account)
{{ $account->account_code }} - {{ $account->account_name }} {{ number_format((float) $account->balance, 2) }}
@endforeach
Total {{ $accountType }} {{ number_format((float) $items->sum('balance'), 2) }}
@endforeach
TOTAL REVENUE {{ number_format($totalRevenue, 2) }}

EXPENSES

@foreach($expenses as $accountType => $items)

{{ $accountType }}

@foreach($items as $account)
{{ $account->account_code }} - {{ $account->account_name }} {{ number_format((float) $account->balance, 2) }}
@endforeach
Total {{ $accountType }} {{ number_format((float) $items->sum('balance'), 2) }}
@endforeach
TOTAL EXPENSES {{ number_format($totalExpenses, 2) }}
NET {{ $netIncome >= 0 ? 'INCOME' : 'LOSS' }} {{ number_format($netIncome, 2) }}