Account Derivation
Account derivation is the process of resolving which GL code combination (account) each subledger journal line should post to. Rather than hard-coding accounts on every transaction, FSL uses a priority-based rule engine that searches a chain of sources until it finds a match.
Line types
Every journal line is categorised by a line type that determines what kind of entry it represents. The line type drives which derivation rules apply. See the Data Model for the full list of seeded line types.
Derivation rules
A derivation rule belongs to an accounting method and a line type. It specifies:
- Source — where to look for the account (e.g. customer site, item, ledger default)
- Priority — the order in which sources are checked (lower number = higher priority)
- Fallback account — an optional code combination to use if the source has no mapping
When creating a journal line, the system walks the derivation rules for the line's type in priority order. At each step it checks whether a source account mapping exists for the given source entity. The first match wins.
Source types
The following source types are available:
| Source | Entity checked | Typical use |
|---|---|---|
CUSTOMER_SITE | The customer site on the AR transaction | Receivable and revenue accounts that vary by customer location |
SUPPLIER_SITE | The supplier site on the AP transaction | Payable and expense accounts that vary by supplier location |
ITEM | The inventory item on the transaction line | Revenue or expense accounts that vary by product |
TRANSACTION_TYPE | The transaction type (invoice, credit memo, etc.) | Accounts that vary by document type |
BANK_ACCOUNT_USE | The bank account on the cash receipt or payment | Cash accounts for different bank accounts |
TAX_RATE | The tax rate applied to the transaction line | Tax liability and tax recoverable accounts |
LEDGER_DEFAULT | The ledger itself | Catch-all default accounts |
Standard method rules
The seeded STANDARD (Standard Accrual) accounting method defines the following derivation rules:
AR line types
| Line type | Priority 1 | Priority 2 | Priority 3 |
|---|---|---|---|
| RECEIVABLE | Customer site | Ledger default | — |
| REVENUE | Item | Customer site | Ledger default |
| TAX_LIABILITY | Tax rate | — | — |
| CASH | Bank account use | — | — |
| UNAPPLIED | Ledger default | — | — |
| REALISED_GAIN | Ledger default | — | — |
| REALISED_LOSS | Ledger default | — | — |
AP line types
| Line type | Priority 1 | Priority 2 | Priority 3 |
|---|---|---|---|
| PAYABLE | Supplier site | Ledger default | — |
| EXPENSE | Item | Supplier site | Ledger default |
| TAX_RECOVERABLE | Tax rate | — | — |
Source accounts
A source account is the mapping record that derivation rules search. Each source account links:
- A source type (e.g.
CUSTOMER_SITE) - A source entity (e.g. a specific customer site ID)
- A line type (e.g.
RECEIVABLE) - A GL code combination (the account to use)
For example, to post all receivables for customer site "Auckland Office" to account 100-1200-000, you create a source account with source type CUSTOMER_SITE, the site's ID, line type RECEIVABLE, and the code combination for 100-1200-000.
Resolution example
When creating a RECEIVABLE line for an AR invoice:
- Priority 1 — Customer site: Look up source accounts where
source_type = 'CUSTOMER_SITE',source_id= the transaction's customer site, andline_type = 'RECEIVABLE'. If found, use that code combination. - Priority 2 — Ledger default: Look up source accounts where
source_type = 'LEDGER_DEFAULT',source_id= the ledger ID, andline_type = 'RECEIVABLE'. If found, use that code combination. - Fallback: If neither rule resolves, check the rule's
fallback_ccid. If still unresolved, raise errorFSL-00010.
Ledger defaults
Ledger defaults are the last resort in the derivation chain. They provide a catch-all account for each line type, ensuring that accounting can always proceed even when more specific mappings have not been configured. Ledger defaults use source type LEDGER_DEFAULT with the ledger ID as the source entity.
At a minimum, you should configure ledger defaults for: RECEIVABLE, REVENUE, PAYABLE, EXPENSE, UNAPPLIED, REALISED_GAIN, and REALISED_LOSS.
Further reading
- Data Model — entity relationships for the derivation model
- Accounting Events — how events trigger journal entry creation
- Create Accounting and Transfer to GL — how derived accounts are used in journal entries