Balance sheet @php $paren = fn (float $value): string => $value < 0 ? '(' . money(abs($value), false) . ')' : money($value, false); $rows = collect(); foreach ($grossRows as $row) { $rows->push(['type' => 'account', 'account' => $row['account'], 'amount' => $row['net']]); } $rows->push(['type' => 'subtotal', 'label' => 'Gross patient service revenue', 'amount' => $grossRows->sum('net')]); if ($contraRows->isNotEmpty()) { $rows->push(['type' => 'header', 'label' => 'Less: contractual allowances & waivers']); foreach ($contraRows as $row) { $rows->push(['type' => 'account', 'account' => $row['account'], 'amount' => $row['net']]); } $rows->push(['type' => 'subtotal', 'label' => 'Net effect of allowances & waivers', 'amount' => $contraRows->sum('net')]); } if ($otherRows->isNotEmpty()) { $rows->push(['type' => 'header', 'label' => 'Other income']); foreach ($otherRows as $row) { $rows->push(['type' => 'account', 'account' => $row['account'], 'amount' => $row['net']]); } $rows->push(['type' => 'subtotal', 'label' => 'Total other income', 'amount' => $otherRows->sum('net')]); } $rows->push(['type' => 'total', 'label' => 'Total revenue', 'amount' => $totalRevenue]); foreach ($expenseSections as $section) { $rows->push(['type' => 'header', 'label' => $section['name']]); foreach ($section['rows'] as $row) { $rows->push(['type' => 'account', 'account' => $row['account'], 'amount' => $row['net']]); } $rows->push(['type' => 'subtotal', 'label' => 'Total ' . strtolower($section['name']), 'amount' => $section['rows']->sum('net')]); } $rows->push(['type' => 'total', 'label' => 'Total operating expenses', 'amount' => $totalExpenses]); @endphp
From {{ $from->format('d M Y') }} to {{ $to->format('d M Y') }}
Total revenue
{{ money($totalRevenue) }}
Total expenses
{{ money($totalExpenses) }}
Net result
{{ money($netResult) }}
@if (request()->hasAny(['from', 'to'])) Clear @endif
@foreach ($rows as $row) @if ($row['type'] === 'header')
{{ $row['label'] }}
@elseif ($row['type'] === 'account')
{{ $row['account']->name }} {{ $row['account']->code }}
{{ $paren($row['amount']) }}
@elseif ($row['type'] === 'subtotal')
{{ $row['label'] }} {{ $paren($row['amount']) }}
@else
{{ $row['label'] }} {{ $paren($row['amount']) }}
@endif @endforeach
Net result for the period {{ $paren($netResult) }}