Fix --permissive with balance assignments (#2005)#2984
Merged
Conversation
…2005) When a posting uses balance assignment syntax with no explicit amount (e.g., Assets:Checking =$12345) and the assigned amount would cause the transaction not to balance, --permissive now accepts the transaction by reverting to auto-balancing. The previous fix (PR #2710) skipped the balance assignment computation entirely under --permissive, which broke balance assignments that DO balance (issue #2944). This fix takes a different approach: the parser always computes the assignment, and finalize() adjusts the posting amount only if the transaction doesn't balance and --permissive is active. Fixes #2005 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <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.
Summary
Assets:Checking =$12345) and the computed amount causes the transaction not to balance,--permissivenow accepts the transaction by reverting to auto-balancingfinalize()(Phase 8 ofxact.cc), not in the parser — this avoids the regression from PR fix: respect --permissive for balance assignments with elided amounts #2710 which broke issue Permissive mode now breaks balance assertions #2944 by skipping assignment computation entirelyApproach
The previous fix (PR #2710, reverted in PR #2964) modified the parser to skip balance assignment computation under
--permissive. This broke legitimate balance assignments (#2944) where the computed amount balances correctly.This fix takes a different approach: the parser always computes the assignment amount. In
finalize(), after detecting an imbalance but before throwing, we check if--permissiveis active and aPOST_CALCULATEDbalance-assignment posting exists. If so, we adjust that posting's amount to absorb the imbalance, effectively auto-balancing the transaction.Test plan
test/regress/2005.testpasses —--permissiveaccepts the unbalanced assignmenttest/regress/2005.testalso verifies the error is still raised WITHOUT--permissivetest/regress/2944.testpasses — balance assignments that balance are unaffectednix build .passesFixes #2005
🤖 Generated with Claude Code