@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

Kebun Anggrek

@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); @endphp @foreach($items->sortBy('Tanggal') as $item) @endforeach
Tanggal Keterangan Ref Debit (Rp) Kredit (Rp) Saldo
{{ date('d/m/Y', strtotime($item->Tanggal)) }} {{ $item->keterangan }} - @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 }}
@endforeach
@endsection