<table width="100%" style="margin-bottom: 10px;">
    <tr>
        <td width="20%" style="text-align: center;">
            <img src="{{ public_path('img/ptbss-removebg-preview.png') }}" style="height: 70px;">
        </td>
        <td style="text-align: left;">
            <h2 style="margin: 0;">PT. BERKAH SEMANGAT SENTOSA</h2>
            <h4 style="margin: 0;">Neraca Saldo - {{ $year }}</h4>
        </td>
    </tr>
</table>
<table border="1" width="100%" cellspacing="0" cellpadding="4">
    <thead>
        <tr>
            <th>No</th>
            <th>Nomor Akun</th>
            <th>Nama Akun</th>
            <th>Debet</th>
            <th>Kredit</th>
        </tr>
    </thead>
    <tbody>
        @php
            $i = 1;
            $total_debet = 0;
            $total_kredit = 0;
        @endphp

        @foreach ($master_akun as $akun)
            @php
                $no_akun = $akun->no_akun;

                $debet =
                    ($data[$no_akun]->debet ?? 0) +
                    ($penerimaan[$no_akun]->debet ?? 0) +
                    ($pengeluaran[$no_akun]->debet ?? 0) +
                    ($jurnal_umum[$no_akun]->debet ?? 0) +
                    ($neraca_awal_sebelumnya[$no_akun]->debet ?? 0);

                $kredit =
                    ($data[$no_akun]->kredit ?? 0) +
                    ($penerimaan[$no_akun]->kredit ?? 0) +
                    ($pengeluaran[$no_akun]->kredit ?? 0) +
                    ($jurnal_umum[$no_akun]->kredit ?? 0) +
                    ($neraca_awal_sebelumnya[$no_akun]->kredit ?? 0);

                $total_debet += $debet;
                $total_kredit += $kredit;
            @endphp

            <tr>
                <td>{{ $i++ }}</td>
                <td>{{ $akun->no_akun }}</td>
                <td>{{ $akun->nama_akun }}</td>
                <td>{{ number_format($debet, 0, ',', '.') }}</td>
                <td>{{ number_format($kredit, 0, ',', '.') }}</td>
            </tr>
        @endforeach
    </tbody>
    <tfoot>
        <tr class="font-weight-bold">
            <td colspan="3" class="text-center">Total</td>
            <td>{{ number_format($total_debet, 0, ',', '.') }}</td>
            <td>{{ number_format($total_kredit, 0, ',', '.') }}</td>
        </tr>
    </tfoot>
</table>
