> ## Documentation Index
> Fetch the complete documentation index at: https://educontroldoc.pixelspectivetech.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Allocation and credit

> How a payment finds the fee lines it settles, and what happens to money that has nowhere to go yet.

Allocation is what turns a lump of money into settled debt. A parent hands over GH₵ 300; allocation decides which fee lines that GH₵ 300 pays off.

## Oldest debt first

By default a payment settles the oldest open lines first, where "oldest" means the earliest **due date** — not the date the invoice was created.

Using the due date is what makes a mid-term supplementary bill fall behind the term's main invoice rather than jumping ahead of it.

## Directing a payment instead

Where a parent is paying for something specific, direct the payment at that fee type and the money settles those lines first.

<Tip>
  Direct the payment whenever the parent tells you what it is for. A family paying for meals expects their next meal bill to go down; if the money quietly clears a tuition arrear instead, they come back to the desk convinced you lost it.
</Tip>

## Money with nowhere to go: credit

If a payment is larger than the debt available to settle — or arrives before the invoice does — the remainder is held as the pupil's **credit**. Nothing is lost.

Credit remembers what it was for. Money directed at feeding stays tagged to feeding while it sits unallocated.

## How credit is used up

When a new invoice is issued for the pupil, EduControl draws down their credit automatically, in this order:

<Steps>
  <Step title="Credit tagged for this fee type, oldest payment first">
    Money the payer intended for exactly this charge is used first — that is what they meant it for.
  </Step>

  <Step title="Untagged credit, oldest payment first">
    General credit follows, once tagged credit is exhausted.
  </Step>
</Steps>

This is why a family who prepays a term of meals sees that prepayment land on the meal bill rather than on tuition.

## Reading a pupil's position

A pupil's financial position is their issued invoices, less what has been paid, less any credit notes, plus any credit they are holding. The pupil's record shows all of it — and so does the [pupil portal](/docs/portal/pupil-portal).

<Warning>
  A pupil with credit is not the same as a pupil with no debt. Credit tagged to feeding does not settle a tuition arrear until an invoice draws it down. Read the invoice balances, not just the credit figure.
</Warning>

## Who can do this

Allocation happens automatically when you record a payment, which needs `record_payments`.
