@php $lang = $filters['lang'] ?? 'en'; $name = function($x) use ($lang){ if(!$x) return ''; if($lang==='ps') return $x->title_ps ?: ($x->title_en ?: ''); if($lang==='dr') return $x->title_dr ?: ($x->title_en ?: ''); return $x->title_en ?: ($x->title_ps ?: ''); }; $diff = (float)($totals['diff'] ?? 0); $ok = abs($diff) < 0.01; $sections = [ ['label'=>'Assets', 'rows'=>$assets], ['label'=>'Liabilities', 'rows'=>$liabilities], ['label'=>'Equity', 'rows'=>$equity], ]; @endphp

Balance Sheet

As of: {{ $asOf }} • Printed: {{ now()->format('Y-m-d H:i') }}
Lang: {{ strtoupper($lang) }}
Status: {{ $ok ? 'Balanced' : 'Not Balanced' }}
@foreach($sections as $s)
{{ $s['label'] }}
@foreach($s['rows'] as $g) @foreach($g->children as $c) @endforeach @endforeach
Name Amount
{{ $name($g) }} {{ number_format((float)$g->total,2) }}
— {{ $c->key }} / {{ $name($c) }} {{ number_format((float)$c->amount,2) }}
@endforeach
Total Assets {{ number_format((float)($totals['assets'] ?? 0),2) }}
Total Liabilities {{ number_format((float)($totals['liabilities'] ?? 0),2) }}
Total Equity {{ number_format((float)($totals['equity'] ?? 0),2) }}
Total (Liabilities + Equity) {{ number_format((float)($totals['liabilities_equity'] ?? 0),2) }}
Difference (Assets - (L+E)) {{ number_format($diff,2) }}