C1 and C2

Ledger and Accounts

A ledger that argues back. Most core systems treat double-entry as a convention the application layer agrees to follow. Here it is a constraint the database enforces, which is the difference between a book that is usually right and a book that cannot be wrong in that particular way.

Built29 tables9 transaction families

Posting, and refusing to post.

A transfer moves the money and prices it in the same transaction, so the wallet debit, the settlement credit and both sides of the fee post together or not at all. Remove one and the set no longer sums to zero.

What happens then is the point. There is no partial write, no compensating entry queued for the morning, and nothing for an operator to find and reverse. The transaction is simply refused.

LivePosting a transferPosting
AccountSideAmount
Client wallet, Northwind Trading
Debit
-24,500.00EUR
Settlement, safeguarded
Credit
24,500.00EUR
Client wallet, Northwind Trading
Debit
-12.50EUR
Fee income
Credit
12.50EUR
Sum, per currency
Balanced
0.00EUR
RefusedThe same four entries with the fee credit removed. The set sums to 12.50EUR and ledger.trial_balance_zero rejects the transaction before it commits. There is no partial write to clean up.

The tables underneath.

Four of the twenty-nine, and the four an integrator meets first.

TableWhat it isKey columns
transactionOne movement of money, of one type, from one of the transaction families.type, value date, reference, status
entryA single debit or credit against one ledger account. Entries are never amended.transaction, account, direction, amount, currency
ledger_accountAn account in the book. Client money, settlement, fee income, suspense.kind, currency, status, owning party
walletA customer-facing balance in one currency, projected from its entries.account, currency, available, pending

Four invariants, checked rather than asserted.

Each is a named check that runs against the live book. An invariant nobody runs is a comment.

I-1

Entries for a transaction sum to zero, per currency

A deferred constraint checked at commit, so a transaction that does not balance never lands.

I-2

A balance equals the replay of its entries

Checked continuously by ledger.balances_match_replay rather than trusted.

I-3

No client position goes negative without an authorised facility

ledger.no_negative_client_positions, run against the live book.

I-4

A written record is never updated

The evidence tables have no update path. The database rejects the statement.

M1 and M4Orchestration and rails

The same entry, whoever triggered it.

The ledger does not know or care whether an officer booked the movement by hand or a rail webhook did. That is what makes going live before an integration a sequencing decision rather than a rewrite.

LiveInstruction, outbound transferManual
What triggered it
SourceOfficer, admin portalRail webhook, M4
ActorA. Patelsystem
Recorded asmanual_bookingprovider_event
The resulting ledger entry
DebitClient wallet, Northwind
CreditSettlement, safeguarded
Amount24,500.00EUR

Identical entry, either way

See it against your own chart of accounts.

Bring the transaction types you actually run and we will post them, including the ones you expect to break it.