Design your Ledger

A Ledger uses a Schema to define functionality for a specific product and use case. A Schema may be shared across multiple Ledgers. Updating a Schema will trigger migrations to update each Ledger. Use the Ledger designer in the Dashboard to model and store your Schema.

Schema

Schema

Ledgers track money using:

  • Ledger Accounts, balances that represent the financial state of a business
  • Ledger Entries, financial events that update Ledger Accounts

Ledger Accounts

A Ledger Account has a balance. Changes to a Ledger Account's balance are called Ledger Lines.

Lines and Balances

Ledger
Account10
Line5
Line5
Account10
Line2
Line3

There are four types of Ledger Accounts, split into two layers:

State

Assets: what you own
Liabilities: what you owe

Change

Income: what you've earned
Expense: what you've spent

State Ledger Accounts track your product's financial relationships with your bank, payment systems and users. Balance Sheets are a report of State Ledger Account balances.

Change Ledger Accounts track when and how your product makes a profit or loss. They produce Income Statements.

Within a Schema, the chartOfAccounts key contains a nested tree of Ledger Accounts, up to a maximum depth of 10:

Chart of Accounts

assets
bank
receivables
clearing

Ledger Accounts that share a parent require a unique key, but the same key can be used in different parts of the tree.

For some Ledger Accounts, you must set additional properties:

  • linkedAccount enables reconciliation with an external system
  • template allows multiple instances to be created on demand
  • currencyMode configures the account's currency mode, single or multi
  • consistencyConfig configures the whether the Ledger Account's balances and Ledger Lines are strongly or eventually consistent

Ledger Entries

A Ledger Entry is a single update to a Ledger. Define a Ledger Entry type in your Schema for every financial event in your product and bank.

Anatomy of an Entry

Type
Line
EntryDescription
Line10
Line5
Line7
Line2
Amount

A Ledger Entry must be balanced, which means it follows the Accounting Equation:


Assets - Liabilities
=
Income - Expenses

Accounting Equation

Assets$
Income$
Liabilities$
Expense$
State0
Change0

How you balance a Ledger Entry depends upon its net effect to the Ledger's balances.

When the net change to the State Ledger Accounts is zero, the financial event being recorded did not change the net worth of the business. In this example, an increase to an asset account is balanced by an increase in a liability account:

Balanced Entry

Entry

Entry
Line10
Line10

Accounting Equation

Assets10
Income0
Liabilities10
Expense0
State0
Change0

When the net change to the State Ledger Accounts is non-zero, the financial event being recorded made a profit or loss. In this example, a difference in asset and liability accounts is balanced by an increase in an income account.

Balanced Entry

Entry

Entry
Line10
Line5
Line5

Accounting Equation

Assets10
Income5
Liabilities5
Expense0
State5
Change5