@if (request()->filled('periode')) @endif @php $periodeSelections = !empty($selected_neraca_periodes ?? []) ? array_values($selected_neraca_periodes) : []; $selectedStartPeriod = request('neraca_start_period', ''); $selectedEndPeriod = request('neraca_end_period', ''); if ($selectedStartPeriod && $selectedEndPeriod && $selectedEndPeriod < $selectedStartPeriod) { $selectedEndPeriod = ''; } $selectedRangeText = $selectedStartPeriod ? ($selectedEndPeriod ? $selectedStartPeriod . ' s/d ' . $selectedEndPeriod : $selectedStartPeriod) : '-'; @endphp

Laporan Neraca

Rentang Periode: {{ $selectedRangeText }}

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

Periode: {{ implode(', ', $selected_neraca_periodes ?? []) ?: '-' }}

@if (!request()->has('execute_neraca'))
Pilih template laporan Neraca dan periode, lalu klik Execute.
@elseif(empty($neraca_result))
Data Neraca tidak ditemukan untuk pilihan tersebut.
@else @php $basePeriod = $neraca_result[0] ?? null; @endphp {{--
@foreach ($neraca_result as $result) {{ $result->periode }} - {{ strtoupper($result->profit_loss->label) }}: {{ number_format(abs($result->profit_loss->amount), 2, ',', '.') }} @endforeach
--}} @if ($basePeriod)
@foreach ($neraca_result as $result) @endforeach @foreach ($basePeriod->sections as $baseField) @php $periodAmountMaps = []; $sectionTotals = []; $isDetailField = ($baseField->field_type ?? 'Details') === 'Details'; foreach ($neraca_result as $resultIndex => $periodResult) { $section = collect($periodResult->sections)->firstWhere( 'id_field', $baseField->id_field, ); $map = []; $collectAmountByKode = function ($rows) use ( &$collectAmountByKode, &$map, ) { foreach ($rows as $row) { $kode = (string) $row->kode; $amount = (float) $row->amount; if ( str_starts_with($kode, '2') || str_starts_with($kode, '3') ) { $amount *= -1; } $map[$kode] = $amount; if (!empty($row->children)) { $collectAmountByKode($row->children); } } }; if ($section && !empty($section->rows)) { $collectAmountByKode($section->rows); } $periodAmountMaps[$resultIndex] = $map; $total = (float) ($section->total ?? 0); if (!empty($section->rows)) { $firstKode = (string) ($section->rows[0]->kode ?? ''); if ( str_starts_with($firstKode, '2') || str_starts_with($firstKode, '3') ) { $total *= -1; } } $sectionTotals[$resultIndex] = $total; } $formatAmount = function ($amount) { $amount = (float) $amount; return $amount < 0 ? '(' . number_format(abs($amount), 2, ',', '.') . ')' : number_format($amount, 2, ',', '.'); }; $hasNegativeTotal = !$isDetailField && collect($sectionTotals)->contains(fn($total) => (float) $total < 0); $sectionBgColor = $isDetailField ? '#eff3f8ff' : '#eafceaff'; $sectionTextClass = $isDetailField ? 'text-dark' : ($hasNegativeTotal ? 'text-danger' : 'text-dark'); $sectionLabelColor = $isDetailField ? '#5f7c8a' : ($hasNegativeTotal ? '#b02a37' : '#5f7c8a'); $sectionFontWeight = $isDetailField ? 'font-weight-normal' : 'font-weight-bold'; @endphp {{-- Section Header with Toggle --}} @foreach ($sectionTotals as $resultIndex => $total) @php $total = (float) $total; $isNegativeTotalCell = !$isDetailField && $total < 0; $totalTextClass = $isNegativeTotalCell ? 'text-danger' : $sectionTextClass; $totalBgColor = $sectionBgColor; @endphp @endforeach @php $sectionGrandTotal = collect($sectionTotals)->sum( fn($total) => (float) $total, ); $isNegativeGrandTotalCell = !$isDetailField && $sectionGrandTotal < 0; $grandTotalTextClass = $isNegativeGrandTotalCell ? 'text-danger' : $sectionTextClass; @endphp @if ($isDetailField) @include('report.rptlpr.partials.neraca_rows', [ 'rows' => $baseField->rows, 'depth' => 0, 'period_amount_maps' => $periodAmountMaps, 'section_id' => $baseField->id_field, 'default_hidden' => true, ]) @endif @endforeach
No. COA Keterangan / Description {{ $result->periode }} Total
@if ($isDetailField) @endif {{ $baseField->field_name }} @if ($isDetailField) (Detail) @else (Total) @endif {{ $formatAmount($total) }} {{ $formatAmount($sectionGrandTotal) }}
@endif @endif