Posting script
Updated
A posting script is the movements a document writes in one subtype. Which registers, dimensions, analytics, resources, and signs is read entirely from this script. A service may compute the number. It must not assemble the movement, and no shared builder returns a ready movement for several documents to share. Similar movements in different documents are normal.
Note
The engine replaces movements on a subtype change (Mix). Bind the script on the document with
subtypeTransactionScripts. A script in the pool that is not bound does not run.
A subtype may have any number of posting scripts, one per accounting goal (stock, cost, GL). They run as a horizontal list (executionOrder, then creation time) — not as Chain of Command. To adjust somebody else's posting, wrap that script with Chain of Command.
GetTransactions is a pure calculation. Spawned documents belong in OnAfterPostAsync on the event handler, and must be idempotent.
A GL leg known before posting is IGeneralLedgerService.EntryAsync inside this script. A leg that is a fact of posting is OnAfterPost + PostForDocumentAsync with a fixed legKey. Do not spawn a JournalEntry per source document.
The posting boundary is two dates per tenant. It sits in document posting, not in the FiscalPeriod dictionary.
See also#
- Document
- Command — what the user pressed to reach this subtype
- Accumulation register — what the script writes
- Runtime — totals and document posting