{{define "content"}}
<div class="space-y-6">
    <div class="sm:flex sm:items-center sm:justify-between">
        <h1 class="text-2xl font-bold text-gray-900">Journal Entries</h1>
        <div class="flex space-x-3">
            <a href="/ledger/accounts" class="text-sm text-indigo-600 hover:text-indigo-500">Chart of Accounts</a>
            <a href="/ledger/trial-balance" class="text-sm text-indigo-600 hover:text-indigo-500">Trial Balance</a>
            <a href="/ledger/journal/new" class="inline-flex items-center rounded-md bg-indigo-600 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-indigo-500">
                + New Entry
            </a>
        </div>
    </div>

    <div class="overflow-hidden bg-white shadow ring-1 ring-black ring-opacity-5 sm:rounded-lg">
        <table class="min-w-full divide-y divide-gray-300">
            <thead class="bg-gray-50">
                <tr>
                    <th class="py-3.5 pl-4 pr-3 text-left text-sm font-semibold text-gray-900">#</th>
                    <th class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Date</th>
                    <th class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Description</th>
                    <th class="px-3 py-3.5 text-left text-sm font-semibold text-gray-900">Reference</th>
                    <th class="px-3 py-3.5 text-right text-sm font-semibold text-gray-900">Debit</th>
                    <th class="px-3 py-3.5 text-right text-sm font-semibold text-gray-900">Credit</th>
                </tr>
            </thead>
            <tbody class="divide-y divide-gray-200 bg-white">
                {{if .Entries}}
                    {{range .Entries}}
                    <tr class="hover:bg-gray-50">
                        <td class="whitespace-nowrap py-4 pl-4 pr-3 text-sm font-medium text-indigo-600">
                            <a href="/ledger/journal/{{.ID}}">{{.ID}}</a>
                        </td>
                        <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{formatDate .EntryDate}}</td>
                        <td class="px-3 py-4 text-sm text-gray-900">{{.Description}}</td>
                        <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-500">{{.Reference}}</td>
                        <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-900 text-right font-mono">{{formatMoney .TotalDebit}}</td>
                        <td class="whitespace-nowrap px-3 py-4 text-sm text-gray-900 text-right font-mono">{{formatMoney .TotalCredit}}</td>
                    </tr>
                    {{end}}
                {{else}}
                    <tr>
                        <td colspan="6" class="px-3 py-8 text-center text-sm text-gray-500">No journal entries yet. <a href="/ledger/journal/new" class="text-indigo-600 hover:text-indigo-500">Create one</a>.</td>
                    </tr>
                {{end}}
            </tbody>
        </table>
    </div>
</div>
{{end}}
