<table border="1">
    @php
        $formatRupiah = fn ($value) => number_format((float) $value, 0, ',', '.');
        $entries = $entries ?? collect();
        $summary = $summary ?? [];
    @endphp

    <tr>
        <th colspan="6" style="font-size:16px;">JURNAL UMUM</th>
    </tr>
    <tr>
        <td colspan="6">Periode {{ \Carbon\Carbon::parse($startDate)->format('d/m/Y') }} s.d. {{ \Carbon\Carbon::parse($endDate)->format('d/m/Y') }}</td>
    </tr>
    <tr>
        <td colspan="2">Total Jurnal</td>
        <td colspan="4">{{ $summary['total_journals'] ?? 0 }}</td>
    </tr>
    <tr>
        <td colspan="2">Total Debit</td>
        <td colspan="4">{{ $formatRupiah($summary['total_debit'] ?? 0) }}</td>
    </tr>
    <tr>
        <td colspan="2">Total Kredit</td>
        <td colspan="4">{{ $formatRupiah($summary['total_kredit'] ?? 0) }}</td>
    </tr>
    <tr></tr>
    <tr>
        <th>Tanggal</th>
        <th>Ref</th>
        <th>Keterangan</th>
        <th>Akun</th>
        <th>Debit</th>
        <th>Kredit</th>
    </tr>
    @forelse($entries as $entry)
        <tr>
            <td>{{ \Carbon\Carbon::parse($entry['tanggal'])->format('d/m/Y') }}</td>
            <td>{{ $entry['reference'] }}</td>
            <td>{{ $entry['description'] }}</td>
            <td>{{ $entry['account'] }}</td>
            <td>{{ ($entry['debit'] ?? 0) > 0 ? $formatRupiah($entry['debit']) : '' }}</td>
            <td>{{ ($entry['kredit'] ?? 0) > 0 ? $formatRupiah($entry['kredit']) : '' }}</td>
        </tr>
    @empty
        <tr>
            <td colspan="6">Tidak ada data</td>
        </tr>
    @endforelse
    @if($entries->isNotEmpty())
        <tr>
            <td colspan="4" align="right"><strong>Total</strong></td>
            <td><strong>{{ $formatRupiah($summary['total_debit'] ?? 0) }}</strong></td>
            <td><strong>{{ $formatRupiah($summary['total_kredit'] ?? 0) }}</strong></td>
        </tr>
    @endif
</table>