@php function formatNumber($number) { // Check if the number has a decimal part if (floor($number) == $number) { // If it's a whole number, format without decimals return number_format($number, 0); } else { // If it has a decimal part, format with 2 decimal places return number_format($number, 2); } } $check = array_keys(get_object_vars($data)); $sales = [];$revenue = [];$expense = [];$otherRevenue = [];$otherExpenses = [];$cogs = []; if(in_array("Sales",$check)){ $sales = array_keys(get_object_vars($data->Sales)); } if(in_array("Revenue",$check)){ $revenue = array_keys(get_object_vars($data->Revenue)); } if(in_array("Expense",$check)){ $expense = array_keys(get_object_vars($data->Expense)); } if(in_array("Other Revenue",$check)){ $otherRevenue = array_keys(get_object_vars($data->{"Other Revenue"})); } if(in_array("Other Expenses",$check)){ $otherExpenses = array_keys(get_object_vars($data->{"Other Expenses"})); } if(in_array("COGS",$check)){ $cogs = array_keys(get_object_vars($data->COGS)); } $ctr = 0;$totalLabarugi = 0; @endphp
Yulia Mega Hasta                                                                                                 Laporan Laba Rugi
@if(count($sales)>0) @php $ctr++;$totalIni = 0; @endphp @foreach($data->Sales as $jual) @foreach($jual as $j) @php $totalLabarugi+=$j->balance; $totalIni += $j->balance; @endphp @endforeach @endforeach @endif @if(count($revenue)>0) @php $ctr++;$totalIni = 0; @endphp @foreach($data->Revenue as $jual) @foreach($jual as $j) @php $totalLabarugi+=$j->balance; $totalIni += $j->balance; @endphp @endforeach @endforeach @endif @if(count($expense)>0) @php $ctr++;$totalIni = 0; @endphp @foreach($data->Expense as $jual) @foreach($jual as $j) @php $totalLabarugi+=$j->balance; $totalIni += $j->balance; @endphp @endforeach @endforeach @endif @if(count($otherRevenue)>0) @php $ctr++;$totalIni = 0; @endphp @foreach($data->{"Other Revenue"} as $jual) @foreach($jual as $j) @php $totalLabarugi+=$j->balance; $totalIni += $j->balance; @endphp @endforeach @endforeach @endif @if(count($otherExpenses)>0) @php $ctr++;$totalIni = 0; @endphp @foreach($data->{"Other Expenses"} as $jual) @foreach($jual as $j) @php $totalLabarugi+=$j->balance; $totalIni += $j->balance; @endphp @endforeach @endforeach @endif @if(count($cogs)>0) @php $ctr++;$totalIni = 0; @endphp @foreach($data->COGS as $jual) @foreach($jual as $j) @php $totalLabarugi+=$j->balance; $totalIni += $j->balance; @endphp @endforeach @endforeach @endif
{{ $ctr.". ".$sales[0] }}
KODE AKUN NAMA AKUN JUMLAH
{{ $j->account_number }} {{ $j->account_name }} {{ formatNumber($j->balance,2) }}
{{ "Total ".$sales[0] }} {{ formatNumber($totalIni,2) }}
{{ $ctr.". ".$revenue[0] }}
KODE AKUN NAMA AKUN JUMLAH
{{ $j->account_number }} {{ $j->account_name }} {{ formatNumber($j->balance,2) }}
{{ "Total ".$revenue[0] }} {{ formatNumber($totalIni,2) }}
{{ $ctr.". ".$expense[0] }}
KODE AKUN NAMA AKUN JUMLAH
{{ $j->account_number }} {{ $j->account_name }} {{ formatNumber($j->balance,2) }}
{{ "Total ".$expense[0] }} {{ formatNumber($totalIni,2) }}
{{ $ctr.". ".$otherRevenue[0] }}
KODE AKUN NAMA AKUN JUMLAH
{{ $j->account_number }} {{ $j->account_name }} {{ formatNumber($j->balance,2) }}
{{ "Total ".$otherRevenue[0] }} {{ formatNumber($totalIni,2) }}
{{ $ctr.". ".$otherExpenses[0] }}
KODE AKUN NAMA AKUN JUMLAH
{{ $j->account_number }} {{ $j->account_name }} {{ formatNumber($j->balance,2) }}
{{ "Total ".$otherExpenses[0] }} {{ formatNumber($totalIni,2) }}
{{ $ctr.". ".$cogs[0] }}
KODE AKUN NAMA AKUN JUMLAH
{{ $j->account_number }} {{ $j->account_name }} {{ formatNumber($j->balance,2) }}
{{ "Total ".$cogs[0] }} {{ formatNumber($totalIni,2) }}
{{ "Total Laba Rugi" }} {{ formatNumber($totalLabarugi,2) }}
Dicetak oleh : {{ $username }}