# Skulitech ERP — Optional Sponsor Schedule and No-Double-Receipting Implementation

**Date:** 14 July 2026  
**Target:** Windows XAMPP (`C:\xampp\htdocs\college_erp`)

## Implemented workflow

Funding-agency money from HELB, County Governments, NG-CDF/CDF, scholarship providers and other sponsors now follows this flow:

```text
Funding agency payment received
→ One parent sponsor receipt
→ Schedule may be attached now or omitted
→ Parent receipt cleared and approved
→ Allocate later by Excel/CSV or one student at a time
→ Post non-cash student credits
```

## Optional bulk allocation schedule

The student allocation schedule is no longer mandatory when the funding-agency receipt is captured.

Finance can now:

1. Save only the parent receipt and leave the whole amount unallocated.
2. Attach an Excel/CSV schedule immediately and create a draft allocation batch.
3. Approve the parent receipt first, then create a bulk allocation batch later.
4. Allocate students individually through **Finance → Manual Student Allocation**.

When no schedule is attached, the system does not create an empty batch. The receipt remains available for later allocation.

## Parent-and-child double-receipting prevention

The system now enforces the principle:

> One official receipt for the actual funding-agency bank transfer or cleared cheque; student entries are allocations, not additional receipts.

Controls implemented:

- A bank, cheque or M-Pesa reference can belong to only one cash receipt across sponsor and direct-student receipt ledgers.
- The direct fee-payment form rejects HELB, County bursary, NG-CDF/CDF, scholarship, sponsor and donor-fund descriptions.
- Direct fee payment requires confirmation that the amount is genuinely new money and not a child allocation.
- The system checks for an exact student-and-amount match against a posted sponsor allocation within seven days and blocks the child receipt.
- Only a **System Admin** or **Admin** can override a verified separate payment, and a detailed audit reason is mandatory.
- Sponsor allocations cannot be printed using the official student cash-receipt page.
- Students receive a **Student Sponsor Allocation Advice — Non-Cash Transaction**.
- **Sponsor Control Reports** now show possible historical parent-and-child receipt matches for investigation and reversal.
- Corrections are reversed with an audit trail rather than deleted.

## Database changes

Added migration:

```text
database/migrations/20260714_004_no_double_receipting.sql
```

Added/confirmed:

- `finance_receipt_reference_registry`
- `fee_payments.payer_type`
- `fee_payments.payment_reference`
- `fee_payments.receipt_origin`
- `fee_payments.is_cash_receipt`
- Index on direct-payment references

The clean-install schema was updated to include the same controls.

## Validation completed

- **189/189 PHP files passed syntax validation**
- **3/3 JavaScript files passed syntax validation**
- **198 POST forms checked; none missing CSRF protection**
- **0 nested forms detected**
- **110 clean-schema tables detected**
- **4 numbered migrations present**
- Optional schedule input confirmed without an HTML `required` attribute
- Receipt-only server path confirmed
- Draft allocation batch is created only when a schedule is supplied
- Global receipt-reference registry confirmed
- Direct student child-receipt block confirmed
- Non-cash receipt printing block confirmed
- Historical double-receipt review confirmed

## XAMPP upgrade

Back up the current application and database, replace the project files, then run:

```bat
cd C:\xampp\htdocs\college_erp
C:\xampp\php\php.exe bin\migrate.php
C:\xampp\php\php.exe bin\xampp_check.php
C:\xampp\php\php.exe bin\check_integrity.php
```

The live MySQL transaction workflow must still be acceptance-tested on the target XAMPP computer because the build environment used for this package does not have the PDO MySQL driver or MariaDB/MySQL service.
