Skip to content

fix(dao): document-totals recompute refreshes expression-calculated header fields (#6519) - #6520

Merged
delchev merged 1 commit into
masterfrom
fix/recalculate-refreshes-calculated
Aug 4, 2026
Merged

fix(dao): document-totals recompute refreshes expression-calculated header fields (#6519)#6520
delchev merged 1 commit into
masterfrom
fix/recalculate-refreshes-calculated

Conversation

@delchev

@delchev delchev commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Closes #6519.

Live failure: an issued, unpaid invoice printed an empty "TOTAL DUE" — Paid/Balance were NULL. The settlement rollup writes them only on allocation events, and expression-calculated fields were re-evaluated only on an explicit header save — while the totals they derive from move on every line change.

recalculate() (the targeted document-totals recompute that line repositories call after every item write) now additionally re-evaluates the header's expression-calculated calculatedOnUpdate fields via the shared Calc evaluator (null inputs read as 0 per its contract) and includes them in the same targeted updateProperties write — so balance = Total - Paid follows the totals from the first line onward and stays correct between allocations. Calculated actions are deliberately excluded: a server call-out may mint or mutate state and belongs to the explicit save/update paths only (documented in-code).

Authoring note (suite side): paid defaults to 0 and balance declares calculatedOnCreate/OnUpdate: "Total - Paid" — Calc identifiers are the PascalCase property names.

Test: IntentEmissionCoverageIT — the coverage document gains balanceDue calculated from its aggregate Amount; asserts the emitted repository persists the refreshed value in the recompute's targeted write, and at runtime posting a line makes the header's BalanceDue equal the line total immediately, with no header save in between. Full fixture compile+publish, 1/1 green locally.

Template-only — reaches deployed apps on regeneration.

🤖 Generated with Claude Code

…ed header fields (#6519)

An unpaid invoice printed an empty Balance: expression-calculated header
fields (balance = Total - Paid) were evaluated only on an explicit
header save, while the totals they derive from move on every LINE
change - so they stayed null (or stale) from the moment items were
added until the next header edit or payment allocation.

recalculate(), the targeted recompute the line repositories call on
every item change, now also re-evaluates the header's
calculatedOnUpdate EXPRESSIONS (shared Calc evaluator; null inputs read
as 0) and persists them in the same targeted write. Calculated ACTIONS
are deliberately not run there - a server call-out may mint or mutate
state and belongs to the explicit save/update paths.

IntentEmissionCoverageIT: the coverage document gains balanceDue
calculated from its aggregate Amount; the emitted repository persists
the refreshed value in the recompute's write, and at runtime posting a
line makes the header's BalanceDue equal the line total immediately
(1/1 green locally, full compile+publish).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@delchev
delchev merged commit a0a563d into master Aug 4, 2026
10 checks passed
@delchev
delchev deleted the fix/recalculate-refreshes-calculated branch August 4, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expression-calculated header fields stay null/stale between item changes - an unpaid invoice prints an empty Balance

1 participant