@extends('Core.Sidebar') @section('content') @php function getAccountTypePHP($kodeAkun) { $kode = (string)$kodeAkun; if (str_starts_with($kode, '111') || str_starts_with($kode, '112')) { return 'AKTIVA'; } else if (str_starts_with($kode, '121') || str_starts_with($kode, '122') || str_starts_with($kode, '131')) { return 'PASIVA'; } else if (str_starts_with($kode, '241') || str_starts_with($kode, '242')) { return 'PENDAPATAN'; } else if (str_starts_with($kode, '251') || str_starts_with($kode, '252')) { return 'BEBAN'; } return 'UNKNOWN'; } function calculateBalancePHP($previousBalance, $debit, $kredit, $accountType) { $balance = $previousBalance; switch($accountType) { case 'AKTIVA': // Aktiva: bertambah di debit, berkurang di kredit $balance = $balance + $debit - $kredit; break; case 'PASIVA': case 'PENDAPATAN': // Pasiva & Pendapatan: bertambah di kredit, berkurang di debit $balance = $balance - $debit + $kredit; break; case 'BEBAN': // Beban: bertambah di debit, berkurang di kredit $balance = $balance + $debit - $kredit; break; default: $balance = $balance + $debit - $kredit; } return $balance; } @endphp Buku Besar Perusahaan Dagang

Buku Besar Perusahaan Dagang

Buku Besar Budivespaendut

Periode: {{ date('F Y', strtotime($startDate)) }}

Tanggal Awal
Tanggal Akhir
@foreach($groupedLaporan as $kategori => $items) @php $kodeAkun = $items->first()->kode ?? '-'; $runningBalance = 0; $accountType = substr($kodeAkun, 0, 3); @endphp
Nama Akun: {{ $kategori }}
Kode Akun: {{ $kodeAkun }}
@php $runningBalance = 0; $accountType = getAccountTypePHP($kodeAkun); $transaksiPerHari = []; // Array untuk menyimpan transaksi per hari @endphp @foreach($items->sortBy('Tanggal') as $item) @php $tanggalTransaksi = date('Y-m-d', strtotime($item->Tanggal)); if (!isset($transaksiPerHari[$tanggalTransaksi])) { $transaksiPerHari[$tanggalTransaksi] = []; // Inisialisasi array untuk tanggal ini } $transaksiPerHari[$tanggalTransaksi][] = $item; // Tambahkan item ke tanggal yang sesuai @endphp @endforeach @foreach($transaksiPerHari as $tanggal => $transaksis) @php $nomorUrut = 1; // Reset nomor urut untuk setiap tanggal @endphp @foreach($transaksis as $item) @php // Format Ref $ref = 'JU/' . date('Y-m-d', strtotime($tanggal)) . '/' . str_pad($nomorUrut++, 3, '0', STR_PAD_LEFT); // Hitung total untuk baris ini $rowDebit = $item->debit ?? 0; $rowKredit = $item->kredit ?? 0; @endphp @endforeach @endforeach
Tanggal Keterangan Ref Debit (Rp) Kredit (Rp) Saldo
{{ date('d/m/Y', strtotime($item->Tanggal)) }} {{ $item->keterangan }} {{ $ref }} @if($item->debit > 0) {{ number_format($item->debit, 0, ',', '.') }} @else - @endif @if($item->kredit > 0) {{ number_format($item->kredit, 0, ',', '.') }} @else - @endif @php $runningBalance = calculateBalancePHP($runningBalance, $item->debit ?? 0, $item->kredit ?? 0, $accountType); $displayBalance = $runningBalance < 0 ? '-' . number_format(abs($runningBalance), 0, ',', '.') : number_format($runningBalance, 0, ',', '.'); @endphp {{ $displayBalance }}
Rows per page:
Page 1 of 14
@endforeach
@endsection