@extends('layouts.app')
@section('title', __('medaccounting::lang.balance_sheet'))
@section('content')
<section class="content-header"><h1>@lang('medaccounting::lang.balance_sheet')</h1>
    <p>@lang('medaccounting::lang.as_of') {{ $asOf }}</p>
</section>
<section class="content">
    @include('medaccounting::reports.partials.filter', ['action' => route('medacc.reports.balance_sheet')])
    <div class="row">
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-primary', 'title' => __('medaccounting::lang.assets')])
                <table class="table table-bordered table-striped">
                    @forelse($assets 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_assets')</th><th class="text-right">{{ number_format($totalAssets, 2) }}</th></tr>
                </table>
            @endcomponent
        </div>
        <div class="col-md-6">
            @component('components.widget', ['class' => 'box-primary', 'title' => __('medaccounting::lang.liabilities')])
                <table class="table table-bordered table-striped">
                    @forelse($liabilities 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_liabilities')</th><th class="text-right">{{ number_format($totalLiabilities, 2) }}</th></tr>
                </table>
            @endcomponent
            @component('components.widget', ['class' => 'box-primary', 'title' => __('medaccounting::lang.equity')])
                <table class="table table-bordered table-striped">
                    @forelse($equity 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_equity')</th><th class="text-right">{{ number_format($totalEquity, 2) }}</th></tr>
                </table>
            @endcomponent
        </div>
    </div>
    @component('components.widget', ['class' => 'box-primary'])
        <div class="row">
            <div class="col-md-6"><strong>@lang('medaccounting::lang.total_assets'):</strong> {{ number_format($totalAssets, 2) }}</div>
            <div class="col-md-6 text-right">
                <strong>@lang('medaccounting::lang.liabilities_equity'):</strong> {{ number_format($totalLiabilities + $totalEquity, 2) }}
                @if($balanced)
                    <span class="label label-success">@lang('medaccounting::lang.balanced')</span>
                @else
                    <span class="label label-danger">@lang('medaccounting::lang.not_balanced')</span>
                @endif
            </div>
        </div>
    @endcomponent
</section>
@endsection
