Skip to main content
Some companies use segmented account codes in their journal entries: a single account reference assembled from parts, such as a base code and a department, combined into a value like 5000-ENG rather than one flat code.
A journal entry is how accounting records a transaction: each line assigns an amount to an account, like wages or taxes payable. A payroll produces one, and the Journal Entry report is that entry laid out line by line.
Nmbr offers segment templates to build that code on the Journal Entry report. You define how the parts are assembled, and Nmbr renders the result into two columns, Generated Expense Code and Generated Liability Code.
A payroll line records both an expense (the employer’s cost) and the liability it creates (what’s owed until it’s paid out). That’s why segments, templates, and the report columns all come in an expense and a liability form.
Segment templates are optional, and each applies only to the line items it matches. They build on Nmbr’s accounting concepts, so if those are new to you, start with the Accounting guide.

How this differs from an accounting code

A generated code is not an accounting code. Both can appear on the Journal Entry report, but they come from separate systems. Accounting codes
  • A distinct entity in Nmbr: a fixed expense or liability code.
  • Often imported from an external accounting platform, and drive the automated export back to it (Xero, QuickBooks).
  • Assigned to a line manually, or by accounting code rules based on attributes like the primary tag or line item type.
  • Rules are driven by a single primary tag group.
Generated codes
  • Computed when the Journal Entry report is built, from a segment template you define globally.
  • Can combine any number of tag groups, accounting codes, and freeform text.
  • Not a fixed, labelled value from a known set.
  • Never part of the export to Xero or QuickBooks.

How a generated code is built

A generated code is built from a segment template on an accounting code rule: an ordered list of segments, some of which read values from tags.

The segment template

A segment template is defined on a global accounting code rule (one with no tag or tag group scope). A rule holds one template per side, in expense_segment_template and liability_segment_template. When the Journal Entry report is built, Nmbr renders the template’s segments in order and joins them into that side’s generated code.

Segments

Each segment resolves to a value from one of three sources:
  • accounting_code: a fixed accounting code’s code. Set id to the accounting code’s id.
  • tag_group: a code carried by one of the row’s tags. Set tag_group_id to the tag group’s id.
  • text: a literal string you supply.
A tag_group segment reads its value from the tag itself. Each tag carries a per-side code, expense_segment and liability_segment, set when you create or update the tag (see Setting up tag groups and tags). On each report row, the segment takes the code from the row’s tag in that group.

Formatting

The accounting_code and tag_group segments also accept optional formatting:
  • prefix / suffix: literal strings wrapped around the resolved value.
  • transform: an ordered list of uppercase, lowercase, alphanumeric (strip non-alphanumeric characters).
  • max_length: truncate the resolved value to this many characters.
  • fallback: a value to use when the segment resolves empty. Without one, an empty segment is dropped, prefix and suffix included.
Each of those segments is processed in a fixed order: resolve the raw value, apply the fallback if it’s empty, run the transforms, truncate to max_length, then wrap with prefix and suffix.

The result

When a rule’s template matches a line, the rendered string appears in Generated Expense Code or Generated Liability Code on the Journal Entry report. The columns are always present; on a given line only the relevant side is filled. Bank, payable, and total rows stay blank.

Which template applies

Templates resolve on their own when the report is built, separately from how accounting codes are routed during payroll calculation. The precedence is the same: for each side of a line, Nmbr uses the template from the most specific matching global rule.
  1. business_preset_id
  2. type + subtype
  3. type
  4. the catch-all: no type, subtype, or business_preset_id
The expense and liability sides resolve independently, so a line’s two columns can come from different rules. Set one catch-all template as a default, then override it for specific line item types. Because templates are defined only on global rules, this precedence has no tag dimension. A tag or tag-group-scoped rule never carries a template.

Example

Give two tags an expense segment. The “Engineering” department tag:
And the “Toronto” location tag:
Set an expense template on the global rule for wages. It emits the wages accounting code, then the department, then the location, each uppercased. The department falls back to GEN when a row has none:
For an Engineering wages line in Toronto where the wages code is 5000, the report’s Generated Expense Code reads:
A wages line with no department resolves the second segment to its fallback: 5000-GEN-TOR.

Behaviour and limits

  • Global rules only. Templates are defined on rules with no tag or tag group scope.
  • Report only. Generated codes never affect the accounting code that syncs to the connected accounting platform. See Exporting journal entries.