@extends('super_admin.layouts.master') @section('title', 'Reports & Billing') @section('page_title', 'Financial Reports & Invoicing') @section('content')
Total Schools
{{ $schools->count() }}
Total Revenue
₹{{ number_format($summary['total_revenue'] ?? 0) }}
₹
Total GST Collected
₹{{ number_format($summary['total_gst'] ?? 0) }}
Total Invoices
{{ $summary['total_transactions'] ?? 0 }}
{{ $selectedSchool->email }} | {{ $selectedSchool->phone }}
Total Spent
₹{{ number_format($schoolTotalSpent) }}
{{ ucfirst($plan) }}
{{ $count }} Schools
No school data available
Schools will appear here when subscriptions are created
| Sr. | Invoice # | School | Plan | Period | Duration | Amount | Status | Actions |
|---|---|---|---|---|---|---|---|---|
| {{ $loop->iteration }} | @if($history->invoice) {{ $history->invoice->invoice_number }} @else Draft @endif |
{{ $history->school ? substr($history->school->name, 0, 1) : '?' }}
{{ $history->school ? $history->school->name : 'Unknown School' }} {{ $history->school ? $history->school->email : 'ID: ' . $history->school_id }} |
{{ ucfirst($history->plan) }} @if($history->action !== 'created' && $history->action !== 'renewed') {{ ucfirst($history->action) }} @endif |
{{ $history->start_date->format('M d, Y') }} to {{ $history->end_date->format('M d, Y') }} |
{{ $history->duration_months }} month(s) |
@php
// 🆕 Get actual invoice amount if invoice exists, else fall back to plan amount
$invoice = \App\Models\Invoice::where('subscription_history_id', $history->id)->first();
$displayAmount = $invoice ? $invoice->total_amount : $history->amount;
$displayGst = $invoice ? $invoice->gst_amount : ($history->amount * 0.18);
@endphp
₹{{ number_format($displayAmount, 2) }} @if($displayAmount > 0)GST: ₹{{ number_format($displayGst, 2) }} @endif |
{{ $history->school ? ucfirst($history->school->status) : 'Unknown' }} |
@if($history->school)
@php
$invoice = \App\Models\Invoice::where('subscription_history_id', $history->id)->first();
$paymentCount = \App\Models\Payment::where('subscription_history_id', $history->id)->count();
$hasInvoice = !is_null($invoice);
$hasPayments = $paymentCount > 0;
$isFullyPaid = $invoice && $invoice->is_locked;
$hasPartialPayment = $invoice && !$invoice->is_locked && $paymentCount > 0;
$isCreditNote = $invoice && $invoice->is_credit_note;
$isLatest = \App\Models\SubscriptionHistory::where('school_id', $history->school_id)
->orderBy('id', 'desc')
->first()?->id === $history->id;
$isFirstEntry = \App\Models\SubscriptionHistory::where('school_id', $history->school_id)
->orderBy('id', 'asc')
->first()?->id === $history->id;
@endphp
@if(!$hasInvoice)
@if($isLatest && !$isFirstEntry)
@endif
@else
@if($isCreditNote)
CreditNote
₹{{ number_format(abs($invoice->total_amount), 2) }}
@php
$isConsumed = false;
if ($invoice->credit_consumed) {
if ($invoice->consumed_by_invoice_id) {
$consumingInvoice = \App\Models\Invoice::find($invoice->consumed_by_invoice_id);
$isConsumed = !is_null($consumingInvoice);
} else {
$isConsumed = true;
}
}
$canDeleteCreditNote = !$isConsumed;
@endphp
@if($canDeleteCreditNote)
@else
Adjusted
@endif
@else
@if($isFullyPaid)
Paid
@elseif($hasPartialPayment)
@else
@endif
@if(!$hasPayments)
@endif
@endif
@endif
@else
N/A
@endif
|
|
No records found for the selected filters |
||||||||