@extends('admin.layouts.app') @section('page-title', 'Customers') @section('content')

Customer List

{{ $allCustomers->count() }}
Total Customers
@php $newThisMonth = $allCustomers->filter(function($customer) { return $customer->created_at->format('Y-m') === now()->format('Y-m'); })->count(); @endphp {{ $newThisMonth }}
New This Month
@php $activeCustomers = $allCustomers->where('status', 'active')->count(); @endphp {{ $activeCustomers }}
Active Customers
@php $premiumCount = $allCustomers->where('customer_type', 'premium')->count(); @endphp {{ $premiumCount }}
Premium Customers
@if(!empty($status)) @endif
Active Inactive All @can('customer.create') Add Customer @endcan
@forelse($customers as $c) @php // 1) Orders = total invoice count $ordersCount = $c->invoices->count(); // 2) Order Total = सर्व invoices च्या charge groups चा base total (without GST) $orderTotal = $c->invoices->sum(function($invoice) { return $invoice->chargeGroups->sum('total_charge'); }); // 3) GST Amount = सर्व invoices च्या gst_amount चा sum $gstTotal = $c->invoices->sum('gst_amount'); // 3) Total Payable = customer ने किती paid केले (installments sum) $totalPaid = $c->invoices->flatMap->installments->sum('amount'); // 4) Remaining = grand_total_with_charges - paid $grandTotal = $c->invoices->sum(function($invoice) { $base = $invoice->chargeGroups->sum('total_charge'); $gst = (float)($invoice->gst_amount ?? 0); return $base + $gst; }); $remainingAmount = max($grandTotal - $totalPaid, 0); @endphp @empty @endforelse
Customer Info Customer ID Orders Order Total GST Amount Total Paid Remaining Create Date Status Actions
{{ strtoupper(substr($c->customer_name,0,1)) }}
{{ $c->customer_name }}
@if($c->customer_type == 'premium') Premium Customer @else Regular Customer @endif
{{ $c->email }}
{{ $c->mobile_no }}
{{ $c->customer_id }} {{ $ordersCount }} ₹{{ number_format($orderTotal, 2) }} ₹{{ number_format($gstTotal, 2) }} ₹{{ number_format($totalPaid, 2) }} @if($remainingAmount > 0) ₹{{ number_format($remainingAmount, 2) }} @else ₹0.00 @endif {{ $c->created_at ? $c->created_at->format('d-m-Y') : '-' }} @if($c->status === 'active') Active @else Inactive @endif
@csrf
No customers found.
Showing {{ $customers->firstItem() ?? 0 }} to {{ $customers->lastItem() ?? 0 }} of {{ $customers->total() }} entries
@for ($i = 1; $i <= $customers->lastPage(); $i++) {{ $i }} @endfor
@endsection