Skip to content

Worked accounting lifecycle

This example follows one invoice through the complete accounting lifecycle. It uses simplified accounts and amounts to show when each part becomes provisional, frozen, or final.

The first table creates profile company_2026 with EUR as its accounting currency. The server provisions the managed accounting tables:

accounts
general_ledger
journal_lines
custom_exchange_rates

EUR is the currency in which journals, account book balances, and period book snapshots are stored. Individual business columns and leaf accounts may still use another currency.

Configure a year period beginning on 2026-01-01. Its end is derived as 2026-12-31.

The period starts open. Posting is still allowed within its date range. Configuring it early makes the intended reporting boundary visible, but the period does not own a separate journal: journals belong to the profile and are selected by accounting date when the period closes.

Create the account paths used by automatic source rows:

311 Receivables
604 Revenue
343 Tax payable

An accounting-enabled business row resolves account to an existing account; it does not create a missing path. Manual journal posting is different: it atomically creates missing account ancestors and the leaf account as part of posting.

All three accounts use EUR denomination in this example.

Create invoice_posting with an ACCOUNTING definition in EUR and any additional domain fields needed to trace the invoice.

The definition expands into:

name
account
tax_point_date
debit
credit

Every saved row must select exactly one side. The source table is now registered to create one journal line per row.

Save three rows:

Name Account Date Debit Credit
INV-42 311 2026-08-09 120.00
INV-42 604 2026-08-09 100.00
INV-42 343 2026-08-09 20.00

The first row creates open journal INV-42; the next rows join it because the name and date match.

After the first row the journal is temporarily unbalanced. After all three rows:

total debit = 120.00
total credit = 120.00
balance = 0.00

The source rows, journal lines, totals, and account projections are updated transactionally. Each line retains the source table, row ID, and row revision.

6. Correct mistakes while the journal is open

Section titled “6. Correct mistakes while the journal is open”

Suppose the revenue should be 98.00 and tax 22.00. Updating those two source rows:

  1. soft-deletes each previous active source line;
  2. posts a replacement from the new row revision;
  3. updates journal totals;
  4. removes the old account contribution and applies the new one.

The historical lines remain available for audit, but only the replacements contribute to active totals.

Once all expected lines are present and total debit equals total credit, close INV-42.

Closing freezes its header and lines and moves its signed account contribution from the open projection to closed. It does not change each account’s total.

If another correction is needed before period close, reopen the journal, correct the source rows, then close it again.

Before closing the 2026 period, every journal dated on or before 2026-12-31 must be closed. Any unbalanced journal is necessarily still open and must be completed or corrected first.

Period close stores frozen balances for each relevant account:

opening + debit - credit = closing

It also freezes denomination quantities for foreign-denominated accounts. After close, changes at or before 2026-12-31 are rejected.

Create the successor period and point it to the closed 2026 period.

If it uses the same profile and account paths remain unchanged, balances carry by path automatically. If account paths changed or the successor belongs to another profile, explicitly map every nonzero source balance to a target account.

For a reviewable transformation, generate an ACCOUNTING_TRANSFER table instead. Its source facts come from the frozen 2026 snapshot; its target fields describe where those amounts will open in the successor. The transfer must be complete and balanced before the successor can close.

After every period in company_2026 is closed, approve the profile’s financial statement.

Approval is final for that profile. Its periods cannot be reopened. A later-discovered error belongs in a later corrective period rather than rewriting the approved statement.

State Source rows and journal lines Journal action Period action
Journal open, date mutable May post, replace, or soft-delete May append or close Period remains open
Journal closed, period open Source-linked changes are blocked May reopen Period may close when all journals qualify
Period closed Changes through its end date are blocked Journals through the boundary stay frozen May reopen only in reverse successor order and before approval
Profile approved Approved-period history is final Closed history remains frozen Periods cannot reopen or be extended