@extends('layouts.app') @section('title', 'Fee Setup') @php $students = \App\Models\Student::where('status', 'active')->orderBy('first_name')->get(['id', 'first_name', 'surname', 'admission_no', 'class_id']); $termInvoices = \Illuminate\Support\Facades\DB::table('invoices') ->join('students', 'students.id', '=', 'invoices.student_id') ->leftJoin('school_classes', 'school_classes.id', '=', 'students.class_id') ->where('invoices.term', $term)->where('invoices.year', $year) ->select('invoices.*', \Illuminate\Support\Facades\DB::raw("CONCAT(students.first_name,' ',students.surname) as student_name"), 'students.admission_no', 'school_classes.name as class_name') ->orderByDesc('invoices.id')->limit(100)->get(); @endphp @section('content')

Fees & invoicing

Build fee structures per class, raise invoices and track collection against each votehead.
@csrf
@include('finance._nav')

{{ $structure ? 'Structure for term '.$term : 'No structure yet' }}

Enter the amount charged per votehead. Zero entries are ignored.
@csrf
@forelse($voteheads as $votehead) @empty @endforelse
VoteheadTypeAmount
{{ $votehead->name }}
{{ ucfirst($votehead->category ?? 'General') }} @if($activityAmounts->has($votehead->id))
Activity {{ money($activityAmounts->get($votehead->id)) }}
@endif
{{ $votehead->type }}
Structure total: {{ money($structure->total ?? 0) }}

Invoicing

Raise invoices for the whole class.
@if($structure)
Class{{ $classes->firstWhere('id', $structure->class_id)?->name }}
Term total{{ money($structure->total) }}
Status{{ $structure->invoiced ? 'Invoiced' : 'Not invoiced' }}
@csrf
@else @endif

Single learner invoice

@csrf

Invoices for term {{ $term }} {{ $year }}

{{ $termInvoices->count() }} shown (latest 100).
@forelse($termInvoices as $invoice) @empty @endforelse
InvoiceLearnerClassTotalDiscountPaidBalanceStatusActions
{{ $invoice->invoice_no ?? '#'.$invoice->id }}
{{ $invoice->student_name }}
{{ $invoice->admission_no }}
{{ $invoice->class_name }} {{ money($invoice->total) }} {{ money($invoice->discount) }} {{ money($invoice->paid) }} {{ money($invoice->balance) }}

Voteheads

Fee heads appear in the structure builder and on invoices.
@forelse($voteheads as $votehead) @empty @endforelse
NameTypeCategoryPrioritySystemActions
{{ $votehead->name }} {{ $votehead->type }} {{ $votehead->category ?: '—' }} {{ $votehead->priority }} {!! $votehead->is_system ? 'System' : 'Custom' !!} @if(!$votehead->is_system)
@csrf @method('DELETE')
@endif

Government allocations

Recorded capitation and grants for the term.
@forelse($gov as $allocation) @empty @endforelse
AccountTermYearAmountReferenceStatus
{{ $allocation->account }} {{ $allocation->term }} {{ $allocation->year }} {{ money($allocation->amount) }} {{ $allocation->reference ?: '—' }}

Votehead allocation plan

How government funds are spread across voteheads.
@csrf @foreach($voteheads->take(10) as $votehead)
@endforeach
@csrf
@csrf

Existing target structures are replaced.

@foreach($termInvoices as $invoice)
@csrf
@endforeach @endsection