@include('templates.pdf_header', [ 'organisation' => $organisation, 'asOfDate' => $asOfDate, 'currency' => $currency, 'title' => 'BALANCE SHEET (SUMMARY)' ]) @php $totals = [ 'revenue' => 0, 'other_income' => 0, 'direct_costs' => 0, 'operating_expenses' => 0, 'interest_expenses' => 0, 'tax_expenses' => 0 ]; function renderItem($item, $key, &$totals, $level = 0) { $padding = $level * 15; $totals[$key] += $item->total ?? 0; @endphp @php if(!empty($item->children)){ foreach($item->children as $child){ renderItem($child, $key, $totals, $level+1); } } } @endphp @foreach([ ['section'=>'REVENUE','items'=>$sales_revenue,'key'=>'revenue'], ['section'=>'OTHER INCOME','items'=>$other_income,'key'=>'other_income'], ['section'=>'DIRECT COSTS','items'=>$direct_costs,'key'=>'direct_costs'], ['section'=>'OPERATING EXPENSES','items'=>$operating_expenses,'key'=>'operating_expenses'], ['section'=>'INTEREST EXPENSES','items'=>$interest_expenses,'key'=>'interest_expenses'], ['section'=>'TAX EXPENSES','items'=>$tax_expenses,'key'=>'tax_expenses'] ] as $group) @foreach($group['items'] as $item) @php renderItem($item, $group['key'], $totals); @endphp @endforeach @endforeach
Description Debit Credit
{{ $item->name }} {{ number_format($item->total_debit ?? 0, 2) }} {{ number_format($item->total_credit ?? 0, 2) }}
{{ $group['section'] }}
Total {{ $group['section'] }} {{ number_format($totals[$group['key']], 2) }}
Gross Profit {{ number_format($totals['revenue'] + $totals['other_income'], 2) }}
Operating Income {{ number_format(($totals['revenue'] + $totals['other_income']) - $totals['direct_costs'] - $totals['operating_expenses'], 2) }}
Net Income {{ number_format(($totals['revenue'] + $totals['other_income']) - $totals['direct_costs'] - $totals['operating_expenses'] - $totals['interest_expenses'] - $totals['tax_expenses'], 2) }}