@extends('layouts.user_type.auth') @php $money = fn($v) => $currency . number_format((float) $v, 2); $short = function ($v) use ($currency) { $v = (float) $v; if ($v >= 10000000) return $currency . round($v / 10000000, 1) . 'Cr'; if ($v >= 100000) return $currency . round($v / 100000, 1) . 'L'; if ($v >= 1000) return $currency . round($v / 1000, 1) . 'k'; return $currency . round($v); }; $pmStatus = request('status'); $pmTabs = ['' => 'All', 'success' => 'Paid', 'pending' => 'Pending', 'failed' => 'Failed']; $pmTones = ['success' => 'z-badge--success', 'pending' => 'z-badge--warning', 'failed' => 'z-badge--danger']; $pmLabels = ['success' => 'Paid', 'pending' => 'Pending', 'failed' => 'Failed']; $pmIcons = ['Credit Card' => 'ri-bank-card-line', 'Debit Card' => 'ri-bank-card-2-line', 'UPI' => 'ri-qr-code-line', 'Cash Payment' => 'ri-money-rupee-circle-line']; $pmFiltered = request()->hasAny(['search', 'method', 'from', 'to', 'status']) && collect(request()->only(['search', 'method', 'from', 'to', 'status']))->filter()->isNotEmpty(); $chartMax = max(1, $months->max('amount')); $chartTotal = $months->sum('amount'); $trend = $kpi->last_month > 0 ? round(($kpi->this_month - $kpi->last_month) / $kpi->last_month * 100) : null; $canEdit = hasPermission('payments', 'insert'); @endphp @section('pageActions') Export CSV @if (hasPermission('subscriptionPackage', 'view')) Subscriptions @endif @endsection @section('payments')
@include('components.alert') {{-- KPIs (all time / this month — not affected by the filters below) --}}
Collected
{{ $money($kpi->collected) }}
{{ $kpi->collected_count }} {{ \Illuminate\Support\Str::plural('payment', $kpi->collected_count) }} received · all time
This month
{{ $money($kpi->this_month) }}
@if ($trend === null) No payments last month @else {{ abs($trend) }}% vs last month @endif
Outstanding
{{ $money($kpi->outstanding) }}
{{ $kpi->outstanding_count ? $kpi->outstanding_count . ' waiting for payment' : 'Nothing waiting — all paid' }}
Failed
{{ $money($kpi->failed) }}
{{ $kpi->failed_count }} {{ \Illuminate\Support\Str::plural('payment', $kpi->failed_count) }} failed · all time
{{-- Revenue, last 12 months --}}
Revenue
Collected per month, last 12 months
12-month total{{ $money($chartTotal) }}
@if ($chartTotal > 0)
{{ $short($chartMax) }}{{ $short($chartMax / 2) }}{{ $currency }}0
@foreach ($months as $m)
{{ $m['label'] }}
@endforeach
@else
No revenue in the last 12 months
Paid subscriptions will show up here month by month.
@endif
{{-- List --}}
@forelse ($payments as $p) @php $sp = $p->subscriptionPackage; $co = $sp?->companyProfile; $cName = $co->company_name ?? 'Unknown company'; $cWords = preg_split('/\s+/', trim($cName)); $cInit = strtoupper(substr($cWords[0] ?? '', 0, 1) . substr($cWords[1] ?? '', 0, 1)); $pDate = \Carbon\Carbon::parse($p->payment_date); $pmRow = [ 'id' => $p->id, 'invoice' => $p->invoice_number, 'company' => $cName, 'email' => $co->email ?? '', 'package' => $sp?->package->package_name ?? '—', 'cycle' => $sp?->package->billing_cycle ?? '', 'expires' => $sp && $sp->expires_at ? \Carbon\Carbon::parse($sp->expires_at)->format('d M Y') : '—', 'sub_status' => $sp?->effective_status ?? '', 'date' => $pDate->format('d M Y, h:i A'), 'method' => $p->payment_method, 'txn' => $p->transaction_id ?: '', 'amount' => $money($p->amount), 'status' => $p->payment_status, 'notes' => $p->notes ?: '', 'invoice_url' => route('payments.invoice.show', $p->id), ]; @endphp @empty @endforelse @if ($totals->cnt) @endif
Invoice Client Plan Method Amount Status
{{ $p->invoice_number }} {{ $pDate->format('d M Y') }}
{{ $cInit }} {{ $cName }} {{ $co->email ?? ($co->city ?? '—') }}
{{ $sp?->package->package_name ?? '—' }} {{ $p->payment_method }} @if ($p->transaction_id){{ $p->transaction_id }}@endif {{ $money($p->amount) }} {{ $pmLabels[$p->payment_status] ?? ucfirst($p->payment_status) }}
@if ($canEdit && in_array($p->payment_status, ['pending', 'failed'])) @endif
{{ $pmFiltered ? 'No payments match' : 'No payments yet' }}
{{ $pmFiltered ? 'Try another status, method, date range or search.' : 'Payments are recorded when you add or renew a subscription.' }}
@if ($pmFiltered) @endif
{{ $totals->cnt }} {{ \Illuminate\Support\Str::plural('payment', $totals->cnt) }} {{ $pmFiltered ? 'matching the filters' : 'in total' }} {{ $money($totals->total) }} {{ $money($totals->collected) }} paid @if ($totals->pending > 0){{ $money($totals->pending) }} pending@endif
@include('components.pagination', ['paginator' => $payments])
{{-- Payment details --}} {{-- Status change --}} @if ($canEdit) @endif
@endsection