@if (request()->filled('periode')) @endif @php $periodeSelections = !empty($selected_neraca_baru_periodes ?? []) ? array_values($selected_neraca_baru_periodes) : []; $selectedStartPeriod = request('neraca_start_period', $neraca_baru_start_period ?? '2025-11'); $selectedEndPeriod = request('neraca_end_period', $neraca_baru_end_period ?? now()->format('Y-m')); if ($selectedStartPeriod && $selectedEndPeriod && $selectedEndPeriod < $selectedStartPeriod) { $selectedEndPeriod = $selectedStartPeriod; } $selectedRangeText = $selectedStartPeriod ? ($selectedEndPeriod ? $selectedStartPeriod . ' s/d ' . $selectedEndPeriod : $selectedStartPeriod) : '-'; @endphp

Neraca Baru

Template Neraca: {{ optional(collect($neracanew_templates ?? [])->firstWhere('id_template_laporan', $selected_neraca_template ?? null))->nama ?? '-' }}
Periode: {{ $selectedEndPeriod }}

{{ session('nama_perusahaan', 'PT MULTI SPUNINDO JAYA Tbk') }}

Periode: {{ $selectedEndPeriod ?: '-' }}

@if (!request()->has('execute_neraca'))
Pilih template laporan Neraca dan periode, lalu klik Execute.
@elseif(empty($neraca_baru_result))
Data Neraca tidak ditemukan untuk pilihan tersebut.
@else @php $formatAmount = function ($amount) { $amount = (float) $amount; return $amount < 0 ? '(' . number_format(abs($amount), 2, ',', '.') . ')' : number_format($amount, 2, ',', '.'); }; $makeSummaryRow = function ($row, $depth = 0) { $kode = $row->kode ?? ''; $label = trim(($kode ? $kode . ' - ' : '') . ($row->nama ?? '')); return (object) [ 'type' => 'detail', 'label' => $label, 'amount' => (float) ($row->amount ?? 0), 'depth' => $depth, ]; }; $collectCategory = function ($sections, $matcher) use (&$collectCategory, $makeSummaryRow) { $items = []; $total = 0.0; $scanRows = function ($rows, $depth = 0) use (&$scanRows, $matcher, $makeSummaryRow, &$items, &$total) { foreach ($rows ?? [] as $row) { $kode = (string) ($row->kode ?? ''); $idCoa = (string) ($row->id_coa ?? ''); if ($matcher($kode) || $matcher($idCoa)) { $items[] = $makeSummaryRow($row, 0); $total += (float) ($row->amount ?? 0); continue; } if (!empty($row->children)) { $scanRows($row->children, $depth); } } }; foreach ($sections ?? [] as $section) { $scanRows($section->rows ?? [], 0); } return (object) [ 'items' => $items, 'total' => $total, ]; }; $makeSectionRow = function ($label) { return (object) [ 'type' => 'section', 'label' => $label, 'amount' => null, 'depth' => 0, ]; }; $makeTotalRow = function ($label, $amount, $type = 'total') { return (object) [ 'type' => $type, 'label' => $label, 'amount' => (float) $amount, 'depth' => 0, ]; }; $buildPairedRows = function ($leftGroups, $rightGroups, $leftGrandLabel, $rightGrandLabel) use ( $makeSectionRow, $makeTotalRow, ) { $rows = []; $leftGrandTotal = 0.0; $rightGrandTotal = 0.0; $pairCount = max(count($leftGroups), count($rightGroups)); for ($pairIndex = 0; $pairIndex < $pairCount; $pairIndex++) { $leftGroup = $leftGroups[$pairIndex] ?? null; $rightGroup = $rightGroups[$pairIndex] ?? null; $leftItems = $leftGroup ? $leftGroup['data']->items : []; $rightItems = $rightGroup ? $rightGroup['data']->items : []; $leftTotal = $leftGroup ? (float) $leftGroup['data']->total : 0.0; $rightTotal = $rightGroup ? (float) $rightGroup['data']->total : 0.0; $rows[] = [ 'left' => $leftGroup ? $makeSectionRow($leftGroup['label']) : null, 'right' => $rightGroup ? $makeSectionRow($rightGroup['label']) : null, ]; $detailRows = max(count($leftItems), count($rightItems)); for ($detailIndex = 0; $detailIndex < $detailRows; $detailIndex++) { $rows[] = [ 'left' => $leftItems[$detailIndex] ?? null, 'right' => $rightItems[$detailIndex] ?? null, ]; } $rows[] = [ 'left' => $leftGroup ? $makeTotalRow('TOTAL ' . $leftGroup['label'], $leftTotal) : null, 'right' => $rightGroup ? $makeTotalRow('TOTAL ' . $rightGroup['label'], $rightTotal) : null, ]; $leftGrandTotal += $leftTotal; $rightGrandTotal += $rightTotal; } $rows[] = [ 'left' => $makeTotalRow($leftGrandLabel, $leftGrandTotal, 'grand'), 'right' => $makeTotalRow($rightGrandLabel, $rightGrandTotal, 'grand'), ]; return $rows; }; @endphp @foreach ($neraca_baru_result as $result) @php $sections = $result->sections ?? []; $reverseCategory = function ($category) { if (isset($category->items)) { foreach ($category->items as $item) { $item->amount = ($item->amount ?? 0) * -1; } } $category->total = ($category->total ?? 0) * -1; return $category; }; $asetLancar = $collectCategory($sections, fn($kode) => str_starts_with($kode, '11')); $asetTidakLancar = $collectCategory( $sections, fn($kode) => str_starts_with($kode, '12') || str_starts_with($kode, '13') || str_starts_with($kode, '14'), ); $kewajiban = $reverseCategory($collectCategory($sections, fn($kode) => str_starts_with($kode, '2'))); $ekuitas = $reverseCategory($collectCategory($sections, fn($kode) => str_starts_with($kode, '3'))); $pairedRows = $buildPairedRows( [ ['label' => 'ASET LANCAR', 'data' => $asetLancar], ['label' => 'ASET TIDAK LANCAR', 'data' => $asetTidakLancar], ], [['label' => 'KEWAJIBAN', 'data' => $kewajiban], ['label' => 'EKUITAS', 'data' => $ekuitas]], 'TOTAL ASET', 'TOTAL KEWAJIBAN DAN EKUITAS', ); @endphp
JURNAL NERACA (T)
{{ session('nama_perusahaan', 'PT MULTI SPUNINDO JAYA Tbk') }}
Periode {{ $selectedEndPeriod }}
@foreach ($pairedRows as $pairedRow) @php $left = $pairedRow['left'] ?? null; $right = $pairedRow['right'] ?? null; $leftCellClass = $left ? 'neraca-baru-cell-' . $left->type : 'neraca-baru-empty'; $rightCellClass = $right ? 'neraca-baru-cell-' . $right->type : 'neraca-baru-empty'; @endphp @if ($left) @if ($left->type === 'section') @else @endif @else @endif @if ($right) @if ($right->type === 'section') @else @endif @else @endif @endforeach
ASET KEWAJIBAN DAN EKUITAS
Keterangan Saldo Keterangan Saldo
{{ $left->label }} {{ $left->label }} {{ $formatAmount($left->amount) }}    {{ $right->label }} {{ $right->label }} {{ $formatAmount($right->amount) }}    
@endforeach @endif