Loans and treasury
Sub-ledger 4, migration0006.
One lifecycle, every facility shape
A term loan, a revolving facility, an owner loan and a factoring line are different products with the same shape: money is drawn, interest accrues, principal is repaid, fees are charged. So there is one lifecycle, and the facility’s own attributes carry the differences.Currency and base evidence
Every drawdown, accrual, repayment, fee and factoring event states the facility/document currency on its journal lines. The ledger resolves the dated FX rate inside the transaction; a missing rate rolls the whole event back instead of storing a movement at par. Each new loan movement keeps its native amount and currency plus the exact base amount, journal entry and journal line that the immutable posting established. Books and Close use that journal-line evidence. Historical movements without it remain explicitly unresolved; GreatBook does not backfill them from a current rate or assume base currency. Factoring also keeps four facts separate: cash advance, finance fee, receivable derecognition and any recourse borrowing. The settlement row is the cash component in its real currency and links to the exact journal entry; a non-recourse purchase derecognises only the authoritative purchased receivable amount, while recourse leaves AR open and records the facility debt.The balance is derived
balance column.
FACILITY-BAL then checks that the balance derived from the movements equals the facility’s GL loan-account balance, which is two independent paths that must agree.
That check exists to catch precisely the thing a stored balance invites: a keyed or pasted figure drifting from the movement ledger.
Recourse is the interesting distinction
Factoring a receivable can be two completely different accounting events, and which one it is depends on who carries the risk if the customer does not pay.
Getting this wrong in the recourse direction understates both assets and liabilities, which flatters every leverage ratio a lender looks at.
The Close list polices it from both ends:
NONRECOURSE-NODEBT asserts that a non-recourse facility carries no loan debt, and the factoring derecognition checks read obligation.due from sub-ledger 1 to confirm the receivable moved the way the recourse flag says it should.
The checks
Facility-scoped checks expand per facility, so this family’s size depends on the book.
Where it is enforced
Facilities settle on rails like anything else, so a drawdown that hit the bank reconciles against the bank statement rather than being taken on trust.
The test that would fail if it broke
backend/tests/test_loans.py covers the lifecycle and both factoring shapes against the v12 worked data: a recourse buyout where the receivable stays, and a non-recourse one where it is derecognised together with the factor’s fee.
What goes wrong without it
Two failures, in order of how often they happen. A keyed facility balance. Somebody types the number from the bank’s statement into a field. It is right on the day and drifts thereafter, and because it is also what the balance sheet reports, the drift is invisible until a reconciliation nobody has done. Recourse treated as sale. The receivable comes off the books, the liability never goes on, and the balance sheet shows a business with less leverage and better working capital than it has. This is a well-known audit finding class, and it is the reason the recourse flag is a first-class attribute here rather than a note in a description field.Related
- Settlement, rails and the AP/AR spine - the rails facilities move on, and the AR they derecognise
- Nothing stored that can be derived - why the facility balance has no column
- The Close checksums - the loans family in the full surface