@extends('layouts.app')
@section('title', __('medaccounting::lang.income_statement'))
@section('content')
<section class="content-header"><h1>@lang('medaccounting::lang.income_statement')</h1></section>
<section class="content">
    @include('medaccounting::reports.partials.filter', ['action' => route('medacc.reports.income_statement')])
    <div class="row">
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-success', 'title' => __('medaccounting::lang.revenue')])
                <table class="table table-bordered table-striped">
                    @forelse($revenue as $r)
                        <tr><td>{{ $r['code'] }} — {{ $r['name'] }}</td><td class="text-right">{{ number_format($r['amount'], 2) }}</td></tr>
                    @empty
                        <tr><td colspan="2" class="text-center text-muted">@lang('medaccounting::lang.no_data')</td></tr>
                    @endforelse
                    <tr><th>@lang('medaccounting::lang.total_revenue')</th><th class="text-right">{{ number_format($totalRevenue, 2) }}</th></tr>
                </table>
            @endcomponent
        </div>
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-danger', 'title' => __('medaccounting::lang.expenses')])
                <table class="table table-bordered table-striped">
                    @forelse($expense as $r)
                        <tr><td>{{ $r['code'] }} — {{ $r['name'] }}</td><td class="text-right">{{ number_format($r['amount'], 2) }}</td></tr>
                    @empty
                        <tr><td colspan="2" class="text-center text-muted">@lang('medaccounting::lang.no_data')</td></tr>
                    @endforelse
                    <tr><th>@lang('medaccounting::lang.total_expenses')</th><th class="text-right">{{ number_format($totalExpense, 2) }}</th></tr>
                </table>
            @endcomponent
        </div>
    </div>
    @component('components.widget', ['class' => 'box-primary'])
        <h4 class="text-right">
            @lang('medaccounting::lang.net_income'):
            <strong class="{{ $netIncome >= 0 ? 'text-green' : 'text-red' }}">{{ number_format($netIncome, 2) }}</strong>
        </h4>
    @endcomponent
</section>
@endsection
