@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 ?: ''); }; $sections = [ ['label'=>'Revenue', 'sec'=>$revenue], ['label'=>'COGS', 'sec'=>$cogs], ['label'=>'OPEX', 'sec'=>$opex], ['label'=>'Taxes', 'sec'=>$taxes], ]; @endphp

Income Statement (P&L)

Period: {{ $from }} to {{ $to }}
Printed: {{ now()->format('Y-m-d H:i') }}
Lang: {{ strtoupper($lang) }}
@foreach($sections as $s) @php $sec = $s['sec']; @endphp
{{ $s['label'] }} — {{ $name($sec) }}
@foreach(($sec->lines ?? []) as $l) @endforeach
Key Name Amount
{{ $l->key ?? '' }} {{ $name($l) }} {{ number_format((float)($l->amount ?? 0),2) }}
Total {{ number_format((float)($sec->total ?? 0),2) }}
@endforeach
Revenue{{ number_format((float)($totals['revenue'] ?? 0),2) }}
COGS{{ number_format((float)($totals['cogs'] ?? 0),2) }}
Gross Profit{{ number_format((float)($totals['gross'] ?? 0),2) }}
Operating Expenses{{ number_format((float)($totals['opex'] ?? 0),2) }}
Operating Profit{{ number_format((float)($totals['op_profit'] ?? 0),2) }}
Taxes{{ number_format((float)($totals['tax'] ?? 0),2) }}
Net Profit / Loss{{ number_format((float)($totals['net'] ?? 0),2) }}