ZuloOne
English
Sign in
Menu

Totals

Updated

An accumulation register stores deltas. A posting script writes them. The balance is the sum of the deltas for a cut. Scripts read and write through register movements and the totals manager.

Note

The engine replaces movements on a subtype change (Mix). It drops every movement the document already has and writes what the target subtype's scripts produce. PostMovementAsync outside that chain does not start a totals driver. A test of cost or tax must create the balance with a receipt document, or the test stays green while production doubles the book.

The totals manager is what a script asks for: registers by name, a balance, a dated cut, a rare direct movement. Register movements is the engine — TR_ rows, TB_ upserts, the drivers. Both refuse an information register (NotSupportedException). Slices go through the information-register service.

A balance on a date is GetBalanceAsync(register, resource, cut, onDate) on the totals manager. It sums TR_ through that day. Without a date it reads TB_ — the current total, which has no history. Use the dated overload when a backdated document asks "how much was there". GetBalanceAsync already re-aggregates analytics. A physical dimension is a schema column. An analytic is not.

A totals driver runs because a register moved, not because a particular document posted. Most registers need none (registerEngineType: "Standard"). Write a driver when the rule must follow every document that touches the register (cost write-off, first-event VAT) or when the engine itself is special (FIFO). Bind it with totalDriverMetaId — that engine replaces the register's own. A kernel driver (StockBaseTotalDriver and the rest compiled into Core) has no owner script. A script in a model above is a CoC wrap with next(), not a partial class of the same name.

The shape of the movement stays in the posting script: transactions.Add(new Stock { … }) or RegisterMovementSpec("Stock").Dim(…).An(…).Res(…). A service may compute the number. Layouts on the totals tab are register totals layouts — they do not write.

Virtual totals and custom reports are their own objects. A script cannot retarget an already-issued FIFO lot and change the amount in place. A quantity-zero, amount-only movement poisons both FIFO and AVG.

See also#

Where next#

Was this page helpful?