@extends('dashboard.layouts.app') @section('content') @include('components.alert') @php $money = function ($value, bool $dashZero = false) { $value = round((float) $value, 2); if (abs($value) < 0.00001) { return $dashZero ? '-' : '0.00'; } if ($value < 0) { return number_format(abs($value), 2) . '-'; } return number_format($value, 2); }; $amountClass = function ($value) { $value = round((float) $value, 2); if ($value > 0.00001) { return 'fr-money--positive'; } if ($value < -0.00001) { return 'fr-money--negative'; } return 'fr-money--muted'; }; $tabs = [ 'balance_sheet' => ['label' => 'Balance Sheet', 'icon' => 'ri:scale-3-line'], 'profit_loss' => ['label' => 'Profit & Loss', 'icon' => 'ri:line-chart-line'], 'cash_flow' => ['label' => 'Cash Position', 'icon' => 'ri:money-dollar-circle-line'], 'trial_balance' => ['label' => 'Trial Balance', 'icon' => 'ri:balance-line'], 'combined_report' => ['label' => 'Combined Report', 'icon' => 'ri:dashboard-line'], // 'financial_indicators' => ['label' => 'Financial Indicators', 'icon' => 'ri:funds-line', 'route' => 'financial_indicators.index'], 'custom_statement' => ['label' => 'Custom Statement', 'icon' => 'ri:edit-2-line'], ]; $queryFor = function ($report) { $query = request()->query(); unset($query['page']); return array_filter([ ...$query, 'report' => $report, ], fn($value) => $value !== null && $value !== ''); }; $queryWithoutReport = array_filter( request()->except(['report', 'page']), fn($value) => $value !== null && $value !== '' ); @endphp
@foreach($tabs as $key => $tab) {{ $tab['label'] }} @endforeach
Filters
Clear
@if($activeReport === 'balance_sheet')
{{ $balanceSheet['isBalanced'] ? 'Assets = Liabilities + Equity' : 'Difference ' . $money($balanceSheet['difference']) }}
Balance Sheet

Click any account to view movements.

@include('dashboard.financial_reports.partials.balance-section', [ 'sectionKey' => 'liability', 'section' => $balanceSheet['sections']['liability'], 'money' => $money, 'amountClass' => $amountClass, ])
@include('dashboard.financial_reports.partials.balance-section', [ 'sectionKey' => 'equity', 'section' => $balanceSheet['sections']['equity'], 'money' => $money, 'amountClass' => $amountClass, ])
@include('dashboard.financial_reports.partials.balance-section', [ 'sectionKey' => 'asset', 'section' => $balanceSheet['sections']['asset'], 'money' => $money, 'amountClass' => $amountClass, ])
Total Assets {{ $money($balanceSheet['assetsTotal']) }}
Total Liabilities + Equity {{ $money($balanceSheet['liabilityAndEquityTotal']) }}
{{ ($balanceSheet['periodResult'] ?? 0) >= 0 ? 'Net Profit' : 'Net Loss' }} {{ $money(abs($balanceSheet['periodResult'] ?? 0)) }}
@elseif($activeReport === 'profit_loss')
Profit & Loss

{{ $filters['from_date'] }} - {{ $filters['to_date'] }}. Click any account to view movements.

@include('dashboard.financial_reports.partials.profit-loss-section', [ 'sectionKey' => 'pl-income', 'title' => 'Revenue', 'rows' => $profitLoss['incomeRows'], 'total' => $profitLoss['totalIncome'], 'sign' => 1, 'amountLabel' => 'Revenue', 'emptyText' => 'No revenue accounts found.', 'money' => $money, 'amountClass' => $amountClass, ])
@include('dashboard.financial_reports.partials.profit-loss-section', [ 'sectionKey' => 'pl-expense', 'title' => 'Expenses', 'rows' => $profitLoss['expenseRows'], 'total' => $profitLoss['totalExpense'], 'sign' => -1, 'amountLabel' => 'Expense', 'emptyText' => 'No expense accounts found.', 'money' => $money, 'amountClass' => $amountClass, ])
{{ $profitLoss['netIncome'] >= 0 ? 'Net Profit' : 'Net Loss' }} {{ $money(abs($profitLoss['netIncome'])) }}
@elseif($activeReport === 'cash_flow')
Cash Position

Cash activity during {{ $filters['from_date'] }} - {{ $filters['to_date'] }}.

Beginning Cash {{ $money($cashFlow['beginningCash']) }}
Net Change {{ $money($cashFlow['netChange']) }}
Ending Cash {{ $money($cashFlow['endingCash']) }}
Cash Accounts {{ $cashFlow['cashAccountsCount'] }}
Operating Activities

{{ $cashFlow['operatingRows']->count() }} movement(s)

{{ $money($cashFlow['operatingTotal']) }}
@forelse($cashFlow['operatingRows'] as $row) @php $rowKey = 'cash-' . $row['payment_id']; @endphp @empty @endforelse
Movement Amount
Payment details
Date Payment Method Direction Cost Center Amount
{{ optional($row['date'])->format('Y-m-d') ?: '-' }} {{ $row['reference'] }} {{ $row['payment_method'] }} {{ $row['direction'] }} @if($row['cost_center']) {{ $row['cost_center']->title }} @else - @endif {{ $row['amount'] >= 0 ? '+' : '' }}{{ $money($row['amount']) }}
No cash movements found.
Net Cash From Operating Activities {{ $money($cashFlow['operatingTotal']) }}
Ending Cash {{ $money($cashFlow['endingCash']) }}
@elseif($activeReport === 'combined_report')
Combined Financial Report

Activity from {{ $filters['from_date'] }} to {{ $filters['to_date'] }}.

Total Assets {{ $money($combinedReport['totalAssets']) }}
Total Liabilities {{ $money($combinedReport['totalLiabilities']) }}
Equity {{ $money($combinedReport['totalEquity']) }}
Period Result {{ $money($combinedReport['netResult']) }}
Period Activity

Revenue, expenses, and net result during the selected period.

Revenue {{ $money($combinedReport['totalRevenue']) }}
Expenses ({{ $money($combinedReport['totalExpenses']) }})
{{ $combinedReport['netResult'] >= 0 ? 'Net Profit' : 'Net Loss' }} {{ $money($combinedReport['netResult']) }}
Financial Position

Totals from the balance sheet.

Total Assets {{ $money($combinedReport['totalAssets']) }}
Total Liabilities {{ $money($combinedReport['totalLiabilities']) }}
Equity {{ $money($combinedReport['totalEquity']) }}
Net Assets {{ $money($combinedReport['netAssets']) }}
@forelse($combinedReport['entityRows'] as $entityRow)
{{ $entityRow['title'] }} {{ $entityRow['code'] }}
@forelse(collect($entityRow['movements'] ?? [])->take(3) as $movement) @empty @endforelse
{{ $movement['description'] }}
{{ $movement['entry_reference'] }}
{{ $money(($movement['debit'] ?? 0) - ($movement['credit'] ?? 0)) }}
No movements {{ $money($entityRow['amount']) }}
Total {{ $money($entityRow['amount']) }}
@empty
No entity balances found.

Try changing filters or date range.

@endforelse
Cost Center Result

Revenue, direct cost, and result by cost center.

@forelse($combinedReport['costCenterRows'] as $row) @php $detailKey = 'combined-cc-' . $row['cost_center_id']; $details = ($combinedReport['costCenterDetails'] ?? collect())->get($row['cost_center_id'], ['accounts' => collect(), 'movements' => collect()]); $movements = collect($details['movements'] ?? []); $revenue = (float) $row['revenue']; $directCost = (float) $row['direct_cost']; $result = (float) $row['result']; @endphp {{ $money($revenue, true) }} {{ $money($directCost, true) }} {{ $money($result) }}
Movements ({{ $movements->count() }})
@forelse($movements as $movement) @empty @endforelse
Date Entry Account Section Description Amount
{{ optional($movement['date'])->format('Y-m-d') ?: '-' }} #{{ $movement['journal_entry_id'] }} {{ $movement['account_title'] }} {{ $movement['account_code'] }} {{ $movement['section'] }} {{ $movement['description'] }} {{ $money($movement['amount'], true) }}
No movements found.
@empty
No cost center results found.

Try changing filters or date range.

@endforelse Total {{ $money($combinedReport['costCenterTotals']['revenue']) }} {{ $money($combinedReport['costCenterTotals']['direct_cost']) }} {{ $money($combinedReport['costCenterTotals']['result']) }}
@elseif($activeReport === 'custom_statement')
Custom Financial Statement

Select accounts and choose how the balance should be calculated.

Select accounts to include {{ count($customStatement['selectedAccountIds']) }} selected account(s)
@php $selectedCustomAccountIds = collect($customStatement['selectedAccountIds']) ->map(fn($id) => (int) $id) ->all(); @endphp
Custom Statement ({{ $customStatement['rows']->count() }} accounts)

@if($customStatement['basis'] === 'period') Period movement from {{ $filters['from_date'] }} to {{ $filters['to_date'] }}. @else Period movement. @endif

@forelse($customStatement['rows'] as $row) @empty @endforelse
{{ $row['title'] }} {{ $row['code'] }} {{ $row['classification'] }}
{{ $money($row['amount']) }}
No selected accounts.

Choose at least one account and apply the statement.

Net Balance Debit positive / Credit negative {{ $money($customStatement['total']) }}
@elseif($activeReport === 'trial_balance')
Trial Balance

Posted journal entries from {{ $filters['from_date'] }} to {{ $filters['to_date'] }}. Click parent accounts to show children.

Total Debit {{ $money($trialBalance['totalDebit']) }}
Total Credit {{ $money($trialBalance['totalCredit']) }}
Balance Check {{ $trialBalance['isBalanced'] ? 'Balanced' : $money($trialBalance['difference']) }}
@forelse($trialBalance['rows'] as $row) {{ $row['code'] }} {{ $row['classification'] }} {{ $money($row['debit'], true) }} {{ $money($row['credit'], true) }} @empty
No accounts found.

Try changing filters or search keyword.

@endforelse Total {{ $money($trialBalance['totalDebit']) }} {{ $money($trialBalance['totalCredit']) }}
@endif
@endsection @push('styles') @endpush @push('scripts') @endpush