Skip to content

Fix --permissive with balance assignments (#2005)#2984

Merged
jwiegley merged 2 commits intomainfrom
johnw/fix-2005
Mar 25, 2026
Merged

Fix --permissive with balance assignments (#2005)#2984
jwiegley merged 2 commits intomainfrom
johnw/fix-2005

Conversation

@jwiegley
Copy link
Copy Markdown
Member

Summary

Approach

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 --permissive is active and a POST_CALCULATED balance-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.test passes — --permissive accepts the unbalanced assignment
  • test/regress/2005.test also verifies the error is still raised WITHOUT --permissive
  • test/regress/2944.test passes — balance assignments that balance are unaffected
  • Full test suite: 4096/4096 tests pass
  • nix build . passes

Fixes #2005

🤖 Generated with Claude Code

jwiegley and others added 2 commits March 24, 2026 17:45
…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>
@jwiegley jwiegley added this pull request to the merge queue Mar 25, 2026
Merged via the queue into main with commit 1c72bf1 Mar 25, 2026
12 checks passed
@jwiegley jwiegley deleted the johnw/fix-2005 branch March 25, 2026 03:31
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.

--permissive doesn't take effect when elided transactions have balance assertions

1 participant