@extends('layouts.portal') @section('title', 'Finance Dashboard') @section('page_title', 'Finance Dashboard') @section('page_subtitle', 'Real-time Financial Overview & Performance Metrics') @section('sidebar') @include('admin.partials.sidebar', ['active' => 'finance-dashboard']) @endsection @section('content')
Comprehensive Financial Overview & Reporting
Client Income
RM {{ number_format($dashStats['total_client_paid'], 0) }}
{{ $dashStats['completed_payments'] }} completed
Agent Commission
RM {{ number_format($dashStats['total_agent_paid'], 0) }}
{{ $dashStats['total_agents'] }} agents active
Lawyer Invoices
RM {{ number_format($dashStats['total_lawyer_paid'], 0) }}
{{ $dashStats['total_lawyers'] }} lawyers
Net Income
RM {{ number_format($dashStats['net_income'], 0) }}
After all payouts
Transactions
{{ $dashStats['total_transactions'] }}
Total processed
Wills Created
{{ $dashStats['total_wills'] }}
+{{ $dashStats['wills_created_this_period'] }} this period
Total Clients
{{ $dashStats['total_clients'] }}
+{{ $dashStats['new_clients'] }} new
Wills Paid
{{ $dashStats['wills_paid'] }}
{{ $dashStats['wills_pending_payment'] }} pending
Completed
{{ $dashStats['completed_payments'] }}
{{ number_format(($dashStats['completed_payments'] / ($dashStats['total_transactions'] ?: 1)) * 100, 1) }}% success rate
Pending
{{ $dashStats['pending_payments'] }}
Awaiting completion
Failed
{{ $dashStats['failed_payments'] }}
Needs review
Success Rate
{{ number_format(($dashStats['completed_payments'] / ($dashStats['total_transactions'] ?: 1)) * 100, 0) }}%
Overall performance
Total Client Income
RM {{ number_format($dashStats['total_client_paid'], 0) }}
Money In
Less
Agent Commission
RM {{ number_format($dashStats['total_agent_paid'], 0) }}
Paid Out
Less
Lawyer Invoices
RM {{ number_format($dashStats['total_lawyer_paid'], 0) }}
Paid Out
Net Profit After All Deductions
RM {{ number_format($dashStats['net_income'], 0) }}
Your remaining income after agent & lawyer payments
{{ number_format($profitMargin, 1) }}%
Profit Margin
Avg Wills per Lawyer: {{ number_format($dashStats['wills_by_lawyers'] / $dashStats['total_lawyers'], 1) }}
Avg Wills per Agent: {{ number_format($dashStats['wills_by_agents'] / $dashStats['total_agents'], 1) }}
| ID | Will ID | Client Name | Amount | Transfer To | Status | Method | Date & Time |
|---|---|---|---|---|---|---|---|
| #{{ $payment->id }} | {{ $payment->will_id ?? 'N/A' }} | @if($payment->will && $payment->will->client) {{ $payment->will->client->full_name }} @elseif($payment->client) {{ $payment->client->full_name }} @elseif($payment->user_id && $payment->user) Admin @else N/A @endif | RM {{ number_format($payment->amount, 2) }} |
@php
$transferTo = 'Unknown';
$badgeClass = 'bg-gray-100 text-gray-800';
$icon = 'fa-question-circle';
$description = '';
// Priority 1: Check if payment has a user_id (admin sending to agent/lawyer)
if ($payment->user_id && $payment->user) {
$transferTo = $payment->user->name ?? 'Unknown User';
$description = $payment->user->name . ' (' . ucfirst($payment->user->role ?? 'user') . ')';
$userRole = $payment->user->role ?? null;
if ($userRole === 'agent') {
$badgeClass = 'bg-purple-100 text-purple-800';
$icon = 'fa-user-tie';
} elseif ($userRole === 'lawyer') {
$badgeClass = 'bg-indigo-100 text-indigo-800';
$icon = 'fa-scale-balanced';
}
}
// Priority 2: Check if it's from a client (admin receives money)
elseif ($payment->client_id || ($payment->will && $payment->will->client)) {
$transferTo = 'Admin';
$badgeClass = 'bg-blue-100 text-blue-800';
$icon = 'fa-building';
$description = 'Company Account';
}
// Priority 3: Check payment method for lawyer invoices
elseif ($payment->amount && (strpos($payment->payment_method ?? '', 'lawyer') !== false || strpos(strtolower($payment->notes ?? ''), 'lawyer') !== false)) {
$transferTo = 'Lawyer';
$badgeClass = 'bg-indigo-100 text-indigo-800';
$icon = 'fa-scale-balanced';
$description = 'Lawyer Invoice';
}
@endphp
{{ $transferTo }}
{{ $description }}
|
@php $statusClass = match($payment->status ?? 'pending') { 'completed' => 'bg-green-100 text-green-800', 'pending' => 'bg-yellow-100 text-yellow-800', 'failed' => 'bg-red-100 text-red-800', default => 'bg-gray-100 text-gray-800' }; @endphp {{ ucfirst($payment->status ?? 'pending') }} | {{ $payment->payment_method ?? 'N/A' }} | {{ $payment->created_at->format('d M Y H:i') }} |
| No transactions found for selected filters | |||||||