@extends('layouts.admin')

@section('title', 'Income Report')

@section('content')
@include('admin.reports._nav', ['active' => 'income'])

<div class="fundi-stats">
    <div class="fundi-stat fundi-stat--accent">
        <div class="fundi-stat__label">Total Income</div>
        <div class="fundi-stat__value">{{ money($summary['total_income']) }}</div>
    </div>
    <div class="fundi-stat">
        <div class="fundi-stat__label">Total Expenses</div>
        <div class="fundi-stat__value">{{ money($summary['total_expenses']) }}</div>
    </div>
    <div class="fundi-stat {{ $summary['net_income'] >= 0 ? 'fundi-stat--accent' : 'fundi-stat--warning' }}">
        <div class="fundi-stat__label">Net Income</div>
        <div class="fundi-stat__value">{{ money($summary['net_income']) }}</div>
    </div>
</div>

<div class="fundi-grid-2">
    <div class="fundi-card">
        <div class="fundi-card__header"><h3>Interest Income (4xx)</h3></div>
        <div class="fundi-card__body">
            <div class="fundi-table-wrap">
                <table class="fundi-table">
                    <thead><tr><th>Code</th><th>Account</th><th class="num">Balance</th></tr></thead>
                    <tbody>
                        @forelse($interestIncome as $account)
                            <tr>
                                <td><code>{{ $account->code }}</code></td>
                                <td>{{ $account->name }}</td>
                                <td class="num">{{ money($account->balance) }}</td>
                            </tr>
                        @empty
                            <tr><td colspan="3" class="fundi-empty">No income accounts.</td></tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>

    <div class="fundi-card">
        <div class="fundi-card__header"><h3>Expenses</h3></div>
        <div class="fundi-card__body">
            <div class="fundi-table-wrap">
                <table class="fundi-table">
                    <thead><tr><th>Code</th><th>Account</th><th class="num">Balance</th></tr></thead>
                    <tbody>
                        @forelse($expenses as $account)
                            <tr>
                                <td><code>{{ $account->code }}</code></td>
                                <td>{{ $account->name }}</td>
                                <td class="num">{{ money($account->balance) }}</td>
                            </tr>
                        @empty
                            <tr><td colspan="3" class="fundi-empty">No expense accounts.</td></tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@endsection
