@php $saldo = $saldoAwalBulan->actual_balance ?? 0; $totalDebit = 0; $totalKredit = 0; $line = 1; $linePerPage = 23; @endphp @php // Hitung tanggal periode berdasarkan $period $periodDates = calculatePeriodDates($period); // Jika endPeriod ada, gunakan endPeriod sebagai batas akhir, jika tidak, gunakan period $endPeriodDate = $endPeriod ? calculatePeriodDates($endPeriod) : $periodDates; $startDate = $periodDates['start']; $endDate = $endPeriodDate['end'] ?? $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) > 30) { $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 ($linePerPage lines per page) $totalPages = ceil($totalLines / $linePerPage); $pageNumber = 0; $footerContent = ' '; @endphp
Watermark

{{ $branch->name }}

Kepada

{{ $customer->name }}

@if ($account->stmt_sent_type == 'BY.MAIL.TO.DOM.ADDR')

{{ $customer->l_dom_street ?? $customer->address }}

{{ $customer->district }} {{ ($customer->ktp_rt ?: $customer->home_rt) ? 'RT ' . ($customer->ktp_rt ?: $customer->home_rt) : '' }} {{ ($customer->ktp_rw ?: $customer->home_rw) ? 'RW ' . ($customer->ktp_rw ?: $customer->home_rw) : '' }}

{{ trim($customer->city . ' ' . ($customer->province ? getProvinceCoreName($customer->province) . ' ' : '') . ($customer->postal_code ?? '')) }} @else

{{ $customer->address }}

{{ $customer->district }} {{ ($customer->ktp_rt ?: $customer->home_rt) ? 'RT ' . ($customer->ktp_rt ?: $customer->home_rt) : '' }} {{ ($customer->ktp_rw ?: $customer->home_rw) ? 'RW ' . ($customer->ktp_rw ?: $customer->home_rw) : '' }}

{{ trim($customer->city . ' ' . ($customer->province ? getProvinceCoreName($customer->province) . ' ' : '') . ($customer->postal_code ?? '')) }} @endif

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) > 30) { $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 >= $linePerPage && !$loop->last) @php $line = 0; $pageNumber++; @endphp
Tanggal Tanggal
Valuta
Keterangan Referensi Debet Kredit Saldo
  Saldo Awal Bulan       {{ number_format((float) $saldoAwalBulan->actual_balance, 2, ',', '.') }}
{{ date('d/m/Y', strtotime($row->transaction_date)) }} {{ substr($row->actual_date, 0, 10) }} {{ str_replace(['[', ']'], ' ', $narrativeLines[0] ?? '') }} {{ $row->reference_number }} {{ $debit > 0 ? number_format((float) $debit, 2, ',', '.') : '' }} {{ $kredit > 0 ? number_format((float) $kredit, 2, ',', '.') : '' }} {{ number_format((float) $saldo, 2, ',', '.') }}
{{ str_replace(['[', ']'], ' ', $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->ktp_rt ?: $account->customer->home_rt) ? 'RT ' . ($account->customer->ktp_rt ?: $account->customer->home_rt) : '' }} {{ ($account->customer->ktp_rw ?: $account->customer->home_rw) ? 'RW ' . ($account->customer->ktp_rw ?: $account->customer->home_rw) : '' }}

{{ trim($account->customer->city . ' ' . ($account->customer->province ? getProvinceCoreName($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 < $linePerPage - $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 }}