@php $saldo = $saldoAwalBulan->actual_balance ?? 0; $totalDebit = 0; $totalKredit = 0; $line = 1; @endphp @php // Hitung tanggal periode berdasarkan $period $periodDates = calculatePeriodDates($period); $startDate = $periodDates['start']; $endDate = $periodDates['end']; // Log hasil perhitungan \Log::info('Period dates calculated', [ 'period' => $period, 'start_date' => $startDate->format('d/m/Y'), 'end_date' => $endDate->format('d/m/Y'), ]); @endphp @php // Calculate total pages based on actual line count $totalLines = 0; foreach ($stmtEntries as $entry) { // Split narrative into multiple lines of approximately 35 characters, breaking at word boundaries $narrative = $entry->description ?? ''; $words = explode(' ', $narrative); $narrativeLineCount = 0; $currentLine = ''; foreach ($words as $word) { if (strlen($currentLine . ' ' . $word) > 35) { $narrativeLineCount++; $currentLine = $word; } else { $currentLine .= ($currentLine ? ' ' : '') . $word; } } if ($currentLine) { $narrativeLineCount++; } // Each entry takes at least one line for the main data + narrative lines + gap row $totalLines += $narrativeLineCount; // +1 for gap row } // Add 1 for the "Saldo Awal Bulan" row $totalLines += 1; // Calculate total pages (18 lines per page) $totalPages = ceil($totalLines / 18); $pageNumber = 0; $footerContent = ' '; @endphp
Watermark

{{ $branch->name }}

Kepada

{{ $account->customer->name }}

{{ $account->customer->address }}

{{ $account->customer->district }}

{{ ($account->customer->city ? $account->customer->city . ' ' : '') . ($account->customer->province ? $account->customer->province . ' ' : '') . ($account->customer->postal_code ?? '') }}

Periode Statement : {{ dateFormat($startDate) }} s/d {{ dateFormat($endDate) }}

Nomor Rekening: {{ $account->account_number }}

@foreach ($stmtEntries as $row) @php $debit = $row->transaction_amount < 0 ? abs($row->transaction_amount) : 0; $kredit = $row->transaction_amount > 0 ? $row->transaction_amount : 0; $saldo += $kredit - $debit; $totalDebit += $debit; $totalKredit += $kredit; // Split narrative into multiple lines of approximately 35 characters, breaking at word boundaries $narrative = $row->description ?? ''; $words = explode(' ', $narrative); $narrativeLines = []; $currentLine = ''; foreach ($words as $word) { if (strlen($currentLine . ' ' . $word) > 35) { $narrativeLines[] = trim($currentLine); $currentLine = $word; } else { $currentLine .= ($currentLine ? ' ' : '') . $word; } } if ($currentLine) { $narrativeLines[] = trim($currentLine); } @endphp @for ($i = 1; $i < count($narrativeLines); $i++) @endfor @php $line += count($narrativeLines); @endphp @if ($line >= 18 && !$loop->last) @php $line = 0; $pageNumber++; @endphp
Tanggal Tanggal
Valuta
Keterangan Referensi Debet Kredit Saldo
  Saldo Awal Bulan       {{ number_format($saldoAwalBulan->actual_balance, 2, ',', '.') }}
{{ date('d/m/Y', strtotime($row->transaction_date)) }} {{ date('d/m/Y', strtotime($row->actual_date)) }} {{ $narrativeLines[0] ?? '' }} {{ $row->reference_number }} {{ $debit > 0 ? number_format($debit, 2, ',', '.') : '' }} {{ $kredit > 0 ? number_format($kredit, 2, ',', '.') : '' }} {{ number_format($saldo, 2, ',', '.') }}
{{ $narrativeLines[$i] }}
Pindah ke Halaman Berikutnya    
{!! $footerContent !!}
Halaman {{ $pageNumber }} dari {{ $totalPages }}
Watermark

{{ $branch->name }}

Kepada

{{ $account->customer->name }}

{{ $account->customer->address }}

{{ $account->customer->district }}

{{ ($account->customer->city ? $account->customer->city . ' ' : '') . ($account->customer->province ? $account->customer->province . ' ' : '') . ($account->customer->postal_code ?? '') }}

Periode Statement : {{ dateFormat($startDate) }} s/d {{ dateFormat($endDate) }}

Nomor Rekening: {{ $account->account_number }}

@endif @endforeach @for ($i = 0; $i < 18 - $line; $i++) @endfor
Tanggal Tanggal
Valuta
Keterangan Referensi Debet Kredit Saldo
Total Akhir {{ number_format($totalDebit, 2, ',', '.') }} {{ number_format($totalKredit, 2, ',', '.') }} {{ number_format($saldo, 2, ',', '.') }}
{!! $footerContent !!}
Halaman {{ $pageNumber + 1 }} dari {{ $totalPages }}