{{-- resources/views/exports/trial-balance-pdf.blade.php Rendered by ReportsController::exportTrialBalance(), which spreads getTrialBalanceData() into the view — so $data here is the inner array: trial_balance (nested groups), grand_totals, is_balanced, from_date, to_date, active_year. Groups nest through 'children' and carry 'ledgers'; the same recursive shape TrialBalanceExport walks for the spreadsheet version. --}} Trial Balance @include('exports._report-styles')

{{ config('accounts.organisation.name') }}

Trial Balance

{{ \Carbon\Carbon::parse($data['from_date'])->format('d/m/Y') }} to {{ \Carbon\Carbon::parse($data['to_date'])->format('d/m/Y') }}
@php /** * Flattens a group and everything under it into printable rows. * * Written as a closure taking itself, because Blade has no clean way to * recurse without a partial, and a partial per level would re-include the * styles. $level only drives indentation. */ $flatten = function ($group, $level, $flatten) { $rows = []; $rows[] = [ 'type' => 'group', 'level' => $level, 'code' => $group['code'] ?? '', 'name' => $group['name'] ?? '', 'values' => [ $group['total_opening_debit'] ?? 0, $group['total_opening_credit'] ?? 0, $group['total_closing_debit'] ?? 0, $group['total_closing_credit'] ?? 0, ], ]; foreach ($group['ledgers'] ?? [] as $ledger) { $rows[] = [ 'type' => 'ledger', 'level' => $level + 1, 'code' => $ledger['code'] ?? '', 'name' => $ledger['name'] ?? '', 'values' => [ $ledger['opening_debit'] ?? 0, $ledger['opening_credit'] ?? 0, $ledger['closing_debit'] ?? 0, $ledger['closing_credit'] ?? 0, ], ]; } foreach ($group['children'] ?? [] as $child) { $rows = array_merge($rows, $flatten($child, $level + 1, $flatten)); } return $rows; }; $rows = []; foreach ($data['trial_balance'] ?? [] as $group) { $rows = array_merge($rows, $flatten($group, 0, $flatten)); } @endphp @forelse ($rows as $row) @foreach ($row['values'] as $value) {{-- Zero on a ledger line is noise; on a group subtotal it is information, so only ledger zeros are blanked. --}} @endforeach @empty @endforelse @if (! empty($rows)) @endif
Code Particulars Opening Dr Opening Cr Closing Dr Closing Cr
{{ $row['code'] }} {{ $row['name'] }} @if ($row['type'] === 'ledger' && (float) $value == 0.0)   @else {{ number_format((float) $value, 2) }} @endif
No balances for this period.
GRAND TOTAL {{ number_format((float) ($data['grand_totals']['opening_debit'] ?? 0), 2) }} {{ number_format((float) ($data['grand_totals']['opening_credit'] ?? 0), 2) }} {{ number_format((float) ($data['grand_totals']['closing_debit'] ?? 0), 2) }} {{ number_format((float) ($data['grand_totals']['closing_credit'] ?? 0), 2) }}

Status: {{ ! empty($data['is_balanced']) ? 'BALANCED' : 'NOT BALANCED' }}