{{ $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); $selected_customer = \App\Models\Customer::where('is_active', 1) ->where('id', $id) ->first(); if ($selected_customer) { foreach ($period as $row) { $invoice = \App\Models\Invoice::whereDate('date', $row->toDateString()) ->where('customer_id', $selected_customer->id) ->latest() ->get(); $payment = \App\Models\InvoicePayment::whereDate('date', $row->toDateString()) ->where('customer_id', $selected_customer->id) ->latest() ->get(); $discount = \App\Models\CustomerPaymentDiscount::whereDate('date', $row->toDateString()) ->where('customer_id', $selected_customer->id) ->latest() ->get(); if (count($invoice) > 0 || count($payment) > 0 || count($discount) > 0) { $items = [ 'invoice' => $invoice, 'payment' => $payment, 'discount' => $discount, ]; $mycollection[$row->format('d/m/Y')] = $items; } } $mycollection = array_reverse($mycollection); } @endphp

Customer Report

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


@if ($selected_customer)
Customer File Number Customer Name Customer Email Customer Adrress
{{ $selected_customer->file_number }} {{ getCountryCode() }} {{ $selected_customer->phone_number_1 }} @if ($selected_customer->phone_number_2) , {{ getCountryCode() }} {{ $selected_customer->phone_number_2 }} @endif {{ $selected_customer->email ?? '-' }} {{ $selected_customer->address ?? '-' }}



@php $total = \App\Models\Invoice::where('customer_id', $selected_customer->id)->sum('total'); $paid = \App\Models\InvoicePayment::where('customer_id', $selected_customer->id)->sum('paid_amount'); $invoice_paid = \App\Models\InvoicePayment::where('customer_id', $selected_customer->id) ->where('payment_type', 1) ->sum('paid_amount'); $opening_received = \App\Models\InvoicePayment::where('customer_id', $selected_customer->id) ->where('payment_type', 2) ->sum('paid_amount'); $opening_balance = $selected_customer->opening_balance != '' ? $selected_customer->opening_balance : 0; $discount = \App\Models\CustomerPaymentDiscount::where('customer_id', $selected_customer->id)->sum('amount'); @endphp
Opening Balance Total Invoices Total Amount Paid Amount Payment Discount Balance Amount
{{ getFormattedCurrency($opening_balance) }} {{ \App\Models\Invoice::where('customer_id', $selected_customer->id)->count() }} {{ getFormattedCurrency($total) }} {{ getFormattedCurrency($paid) }} {{ getFormattedCurrency($discount) }} {{ getFormattedCurrency($total + $selected_customer->opening_balance - ($paid + $discount)) }}



@php $total_invoices = 0; $total_sales = 0; $total_payments = 0; $total_discounts = 0; @endphp @foreach ($mycollection as $key => $value) @foreach ($value['invoice'] as $item) @php $total_invoices++; $total_sales += $item->total; @endphp @endforeach @foreach ($value['payment'] as $item) @php $total_payments += $item->paid_amount; @endphp @endforeach @foreach ($value['discount'] as $item) @php $total_discounts += $item->amount; @endphp @endforeach @endforeach
Date Particulars Debit Credit
{{ $key }} Sales - #{{ $item->invoice_number }} {{ getFormattedCurrency($item->total) }}
{{ $key }} Payment - #{{ $item->voucher_no }} {{ getFormattedCurrency($item->paid_amount) }}
{{ $key }} Payment Discount {{ getFormattedCurrency($item->amount) }}



Total Invoices: {{ $total_invoices }}
Total Sales: {{ getFormattedCurrency($total_sales) }}
Total Payments: {{ getFormattedCurrency($total_payments) }}
Payment Discounts: {{ getFormattedCurrency($total_discounts) }}
@endif