@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 Budivespaendut
Periode: {{ date('F Y', strtotime($startDate)) }}
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 }} |