@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 = []; foreach($dateRanges as $dr){ if(count($totalLabarugi) == 0){ $totalLabarugi = [$dr["month_key"] => 0]; }else{ $totalLabarugi[$dr["month_key"]] = 0; } } @endphp
Yulia Mega Hasta                                                                                         Laporan Laba Rugi Akumulasi
@if(count($sales)>0) @php $ctr++;$totalIni = []; foreach($dateRanges as $dr){ if(count($totalIni) == 0){ $totalIni = [$dr["month_key"] => 0]; }else{ $totalIni[$dr["month_key"]] = 0; } } @endphp @foreach($dateRanges as $dr) @endforeach @foreach($data->Sales as $jual) @foreach($jual as $ja) @foreach($dateRanges as $dr) @php $totalLabarugi[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; $totalIni[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; @endphp @endforeach @endforeach @endforeach @foreach($dateRanges as $dr) @endforeach @endif @if(count($revenue)>0) @php $ctr++;$totalIni = []; foreach($dateRanges as $dr){ if(count($totalIni) == 0){ $totalIni = [$dr["month_key"] => 0]; }else{ $totalIni[$dr["month_key"]] = 0; } } @endphp @foreach($dateRanges as $dr) @endforeach @foreach($data->Revenue as $jual) @foreach($jual as $ja) @foreach($dateRanges as $dr) @php $totalLabarugi[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; $totalIni[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; @endphp @endforeach @endforeach @endforeach @foreach($dateRanges as $dr) @endforeach @endif @if(count($expense)>0) @php $ctr++;$totalIni = []; foreach($dateRanges as $dr){ if(count($totalIni) == 0){ $totalIni = [$dr["month_key"] => 0]; }else{ $totalIni[$dr["month_key"]] = 0; } } @endphp @foreach($dateRanges as $dr) @endforeach @foreach($data->Expense as $jual) @foreach($jual as $ja) @foreach($dateRanges as $dr) @php $totalLabarugi[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; $totalIni[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; @endphp @endforeach @endforeach @endforeach @foreach($dateRanges as $dr) @endforeach @endif @if(count($otherRevenue)>0) @php $ctr++;$totalIni = []; foreach($dateRanges as $dr){ if(count($totalIni) == 0){ $totalIni = [$dr["month_key"] => 0]; }else{ $totalIni[$dr["month_key"]] = 0; } } @endphp @foreach($dateRanges as $dr) @endforeach @foreach($data->{"Other Revenue"} as $jual) @foreach($jual as $ja) @foreach($dateRanges as $dr) @php $totalLabarugi[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; $totalIni[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; @endphp @endforeach @endforeach @endforeach @foreach($dateRanges as $dr) @endforeach @endif @if(count($otherExpenses)>0) @php $ctr++;$totalIni = []; foreach($dateRanges as $dr){ if(count($totalIni) == 0){ $totalIni = [$dr["month_key"] => 0]; }else{ $totalIni[$dr["month_key"]] = 0; } } @endphp @foreach($dateRanges as $dr) @endforeach @foreach($data->{"Other Expenses"} as $jual) @foreach($jual as $ja) @foreach($dateRanges as $dr) @php $totalLabarugi[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; $totalIni[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; @endphp @endforeach @endforeach @endforeach @foreach($dateRanges as $dr) @endforeach @endif @if(count($cogs)>0) @php $ctr++;$totalIni = []; foreach($dateRanges as $dr){ if(count($totalIni) == 0){ $totalIni = [$dr["month_key"] => 0]; }else{ $totalIni[$dr["month_key"]] = 0; } } @endphp @foreach($dateRanges as $dr) @endforeach @foreach($data->COGS as $jual) @foreach($jual as $ja) @foreach($dateRanges as $dr) @php $totalLabarugi[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; $totalIni[$dr["month_key"]] += $ja->balances->{$dr["month_key"]}; @endphp @endforeach @endforeach @endforeach @foreach($dateRanges as $dr) @endforeach @endif @foreach($dateRanges as $dr) @endforeach
{{ $ctr.". ".$sales[0] }}
AKUN TANGGAL
KODE NAMA{{ $dr["month_key"] }}
{{ $ja->account_number }} {{ $ja->account_name }}{{ formatNumber($ja->balances->{$dr["month_key"]},2) }}
{{ "Total ".$sales[0] }}{{ formatNumber($totalIni[$dr["month_key"]],2) }}
{{ $ctr.". ".$revenue[0] }}
AKUN TANGGAL
KODE NAMA{{ $dr["month_key"] }}
{{ $ja->account_number }} {{ $ja->account_name }}{{ formatNumber($ja->balances->{$dr["month_key"]},2) }}
{{ "Total ".$revenue[0] }}{{ formatNumber($totalIni[$dr["month_key"]],2) }}
{{ $ctr.". ".$expense[0] }}
AKUN TANGGAL
KODE NAMA{{ $dr["month_key"] }}
{{ $ja->account_number }} {{ $ja->account_name }}{{ formatNumber($ja->balances->{$dr["month_key"]},2) }}
{{ "Total ".$expense[0] }}{{ formatNumber($totalIni[$dr["month_key"]],2) }}
{{ $ctr.". ".$otherRevenue[0] }}
AKUN TANGGAL
KODE NAMA{{ $dr["month_key"] }}
{{ $ja->account_number }} {{ $ja->account_name }}{{ formatNumber($ja->balances->{$dr["month_key"]},2) }}
{{ "Total ".$otherRevenue[0] }}{{ formatNumber($totalIni[$dr["month_key"]],2) }}
{{ $ctr.". ".$otherRevenue[0] }}
AKUN TANGGAL
KODE NAMA{{ $dr["month_key"] }}
{{ $ja->account_number }} {{ $ja->account_name }}{{ formatNumber($ja->balances->{$dr["month_key"]},2) }}
{{ "Total ".$otherRevenue[0] }}{{ formatNumber($totalIni[$dr["month_key"]],2) }}
{{ $ctr.". ".$cogs[0] }}
AKUN TANGGAL
KODE NAMA{{ $dr["month_key"] }}
{{ $ja->account_number }} {{ $ja->account_name }}{{ formatNumber($ja->balances->{$dr["month_key"]},2) }}
{{ "Total ".$cogs[0] }}{{ formatNumber($totalIni[$dr["month_key"]],2) }}
{{ "Total Laba Rugi" }}{{ formatNumber($totalLabarugi[$dr["month_key"]],2) }}
Dicetak oleh : {{ $username }}