@extends('layouts.app')
@section('title', __('Chart of Accounts'))
@section('content')
<div class="card">
    <div class="card-body p-4">
        @include('reports.partials.header', ['title' => __('Chart of Accounts'), 'period' => __('As of').' '.\App\Support\DualDate::format(now(), 'Y-m-d')])
        <div class="text-end mb-3 no-print"><button onclick="window.print()" class="btn btn-light btn-sm"><i class="fa-solid fa-print me-1"></i>{{ __('Print') }}</button></div>
        <div class="table-responsive">
            <table class="table align-middle">
                <thead><tr><th>{{ __('Group') }}</th><th>{{ __('Account Name') }}</th><th>{{ __('Type') }}</th><th class="text-end">{{ __('Debit') }}</th><th class="text-end">{{ __('Credit') }}</th></tr></thead>
                <tbody>
                    @foreach($accounts as $account)
                        <tr><td>{{ $account['group'] }}</td><td>{{ $account['name'] }}</td><td>{{ $account['type'] }}</td><td class="text-end money">{{ $account['debit'] ? number_format($account['debit'], 2).' '.$moneyCode : '-' }}</td><td class="text-end money">{{ $account['credit'] ? number_format($account['credit'], 2).' '.$moneyCode : '-' }}</td></tr>
                    @endforeach
                </tbody>
                <tfoot><tr><th colspan="3">{{ __('Total') }}</th><th class="text-end money">{{ number_format($accounts->sum('debit'), 2) }} {{ $moneyCode }}</th><th class="text-end money">{{ number_format($accounts->sum('credit'), 2) }} {{ $moneyCode }}</th></tr></tfoot>
            </table>
        </div>
    </div>
</div>
@if(!empty($appSettings['report_footer']))<p class="text-center text-muted small mt-3">{{ $appSettings['report_footer'] }}</p>@endif
@endsection
