fix(dao): document-totals recompute refreshes expression-calculated header fields (#6519) - #6520
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #6519.
Live failure: an issued, unpaid invoice printed an empty "TOTAL DUE" —
Paid/Balancewere 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-calculatedcalculatedOnUpdatefields via the sharedCalcevaluator (null inputs read as 0 per its contract) and includes them in the same targetedupdatePropertieswrite — sobalance = Total - Paidfollows 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):
paiddefaults to 0 andbalancedeclarescalculatedOnCreate/OnUpdate: "Total - Paid"— Calc identifiers are the PascalCase property names.Test:
IntentEmissionCoverageIT— the coverage document gainsbalanceDuecalculated from its aggregateAmount; asserts the emitted repository persists the refreshed value in the recompute's targeted write, and at runtime posting a line makes the header'sBalanceDueequal 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