{{$lang->data['print_sales_report'] ?? 'Print Sales Report'}} @php $mycollection = []; $expensecollect = []; $start_date = \Carbon\Carbon::parse($start_date); $end_date = \Carbon\Carbon::parse($end_date); $period = \Carbon\CarbonPeriod::create($start_date,$end_date); $gross_expense = 0; $gross_sales = 0; $net_income = 0; foreach($period as $row) { $no_of_invoices = \App\Models\Invoice::whereDate('date',$row->toDateString())->latest(); $total_sales = \App\Models\Invoice::whereDate('date',$row->toDateString())->latest(); $total_expense = \App\Models\Expense::whereDate('date',$row->toDateString())->latest(); $no_of_expense = \App\Models\Expense::whereDate('date',$row->toDateString())->latest()->count(); $no_of_invoices1 = $no_of_invoices->count(); $total_sales1 = $total_sales->sum('total'); $total_expense1 = $total_expense->sum('amount'); $gross_expense += $total_expense1; $gross_sales += $total_sales1; if($no_of_expense!= 0 || $total_expense1 != 0 ) { $items = [ 'no' => $no_of_expense, 'expense' => getFormattedCurrency($total_expense1) ]; $expensecollect[$row->format('d/m/Y')] = $items; } if($no_of_invoices1!= 0 || $total_sales1 != 0 ) { $items = [ 'invoices' => $no_of_invoices1, 'sales' => getFormattedCurrency($total_sales1), 'expense' => getFormattedCurrency($total_expense1) ]; $mycollection[$row->format('d/m/Y')] = $items; } } $net_income = $gross_sales - $gross_expense; @endphp

Income Report

@if($branch != '') @php $branchUser = \App\Models\User::where('id',$branch)->first(); @endphp

[{{ $branchUser->name; }}]

@endif
Net Sales
{{ \Carbon\Carbon::parse($start_date)->format('d/m/Y') }} {{ \Carbon\Carbon::parse($end_date)->format('d/m/Y') }}


@if(count($mycollection) > 0) @foreach ($mycollection as $key => $item) @endforeach @else @endif
Date No. of Invoices Invoice Total
{{$key}} {{$item['invoices']}} {{$item['sales']}}
- - -


Net Expense
{{ \Carbon\Carbon::parse($start_date)->format('d/m/Y') }} {{ \Carbon\Carbon::parse($end_date)->format('d/m/Y') }}


@if(count($expensecollect) > 0) @foreach ($expensecollect as $key => $item) @endforeach @else @endif
Date No. of Expense Expense Total
{{$key}} {{$item['no']}} {{$item['expense']}}
- - -


Total Sales: {{getFormattedCurrency($gross_sales)}} Total Expense: {{getFormattedCurrency($gross_expense)}} Net Income: {{getFormattedCurrency($net_income)}}