{{$lang->data['print_sales_report'] ?? 'Print Sales Report'}} @php $mycollection = []; $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_payments = 0; $gross_sales = 0; $gross_invoices = 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(); $payment_received = \App\Models\InvoicePayment::whereDate('date',$row->toDateString())->latest(); $total_expense = \App\Models\Expense::whereDate('date',$row->toDateString())->latest(); if($branch != '') { $no_of_invoices->where('created_by',$branch); $total_sales->where('created_by',$branch); $payment_received->where('created_by',$branch); $total_expense->where('created_by',$branch); } $no_of_invoices = $no_of_invoices->count(); $total_sales = $total_sales->sum('total'); $payment_received = $payment_received->sum('paid_amount'); $total_expense = $total_expense->sum('amount'); $gross_expense += $total_expense; $gross_payments += $payment_received; $gross_sales += $total_sales; $gross_invoices += $no_of_invoices; if($no_of_invoices!= 0 || $total_sales != 0 || $payment_received != 0 || $total_expense != 0 ) { $items = [ 'invoices' => $no_of_invoices, 'sales' => getFormattedCurrency($total_sales), 'payments' => getFormattedCurrency($payment_received), 'expense' => getFormattedCurrency($total_expense) ]; $mycollection[$row->format('d/m/Y')] = $items; } } @endphp

Day-Wise Report

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

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

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


@foreach ($mycollection as $key => $item) @endforeach
Date Invoices Sales Total Payments Received Expense Total
{{$key}} {{$item['invoices']}} {{$item['sales']}} {{$item['payments']}} {{$item['expense']}}


Total Invoices: {{$gross_invoices}} Total Sales: {{getFormattedCurrency($gross_sales)}} Total Payments: {{getFormattedCurrency($gross_payments)}} Total Expenses: {{getFormattedCurrency($gross_expense)}}