@include('templates.pdf_header', [ 'organisation' => $organisation, 'title' => 'BALANCE SHEET COMPARISON', 'currency_code' => $currency ]) @php function fmtAmount($value) { return ($value ?? 0) != 0 ? number_format($value, 0) : ''; } function renderComparison($items, $level = 0) { static $closing_equity_current = 0; static $closing_equity_previous = 0; static $closing_liabilities_current = 0; static $closing_liabilities_previous = 0; foreach ($items as $item) { // ---------------- SPECIAL TOTALS ---------------- if (($item['total_key'] ?? '') === 'total_equity') continue; if (($item['total_key'] ?? '') === 'closing_equity') { $closing_equity_current = $item['value_current'] ?? 0; $closing_equity_previous = $item['value_previous'] ?? 0; } if (($item['total_key'] ?? '') === 'total_liabilities') { $closing_liabilities_current = $item['value_current'] ?? 0; $closing_liabilities_previous = $item['value_previous'] ?? 0; } if (($item['total_key'] ?? '') === 'total_equity_and_liability') { $item['value_current'] = $closing_equity_current + $closing_liabilities_current; $item['value_previous'] = $closing_equity_previous + $closing_liabilities_previous; } $current = $item['value_current'] ?? 0; $previous = $item['value_previous'] ?? 0; // ---------------- SKIP ZERO-VALUE ROWS (except headers) ---------------- if ( isset($item['row_type']) && $item['row_type'] !== 'header' && $current == 0 && $previous == 0 ) continue; // ---------------- SUBCATEGORY OVERRIDE ---------------- if (isset($item['level']) && ($item['level'] == "subcategory" || $item['level'] == "subcategory")) { $current = 0; $previous = 0; } // ---------------- RENDER ROW ---------------- $indentClass = $level > 0 ? "indent-{$level}" : ''; $boldClass = !empty($item['bold']) ? 'bold' : ''; echo ''; echo ''; echo ''; echo ''; echo ''; // ---------------- CHILDREN ---------------- if (!empty($item['children'])) { renderComparison($item['children'], $level + 1); } } } @endphp @php renderComparison($data); @endphp
Particulars Current Year ({{ $currentYear->financial_year ?? '' }}) Previous Year ({{ $previousYear->financial_year ?? '' }})
' . ($item['label'] ?? '') . '' . fmtAmount($current) . '' . fmtAmount($previous) . '
MWENYEKITI
MENEJA MKUU
MJUMBE