Skip to content

Extend the per-unit cost rounding allowance to the automated check - #13

Merged
jwiegley merged 1 commit into
mainfrom
johnw/ellerman-review
Nov 7, 2026
Merged

jwiegley merged 1 commit into
mainfrom
johnw/ellerman-review

Conversation

@jwiegley

@jwiegley jwiegley commented Nov 7, 2026

Copy link
Copy Markdown
Member

Follow-up to #12. The extended balance test after an automated transaction's generated postings refused regress/3314_rounding_auto (issues #3314, #1125): a balanced rule adding to both balancing groups leaves a half-cent residual that the zero test refuses and that the per-unit cost rounding allowance of C++ (xact.cc:908-929, PR 3317) absorbs. The pre-merge branch engine rejected the file too, so the conflict resolution had kept the branch's gap.

This commit gives the check the same allowance balancePool states, over the matched postings and those generated so far, beside the zero test.

Witness: regress/3314_rounding_auto prints the four rows of main's oracle; the C++ main binary (5f9855cef) prints the two rows its test expects; the whole 35-file witness set of the previous commit still prints identically to main's oracle.

The extended balance test that follows the generated postings of an
automated transaction weighed each candidate's residual against the
zero test alone, without the per-unit cost rounding allowance that
C++ adds before its balance test (xact.cc:908-929): the exact
adjustment of rounding each per-unit cost of a real posting at its
price's decimals, which the engine models, in `balancePool` as in
this check, as half a unit in the last place of every cost in the
commodity written with decimals. A balanced automated rule that adds
to both balancing groups of regress/3314_rounding_auto (issues 3314
and 1125, each group carrying 0.50 bread @ $3.99 and 1.50 bread @
$4.99 against $-9.49) left a residual of half a cent that the zero
test refuses and that the allowance absorbs, so the merged oracle
rejected a journal that C++ (5f9855cef, with PR 3317) accepts with
the rows `2.00 bread Budget:Bread` and `2.00 bread Expenses:Bread`
and that main's oracle (bbd5478) accepts as well. The pre-merge
branch engine rejected it too, so the conflict resolution had kept
the branch's gap rather than main's behavior.

The check now allows the sum of the per-cost allowances of the
matched postings and of those generated so far, beside the zero
test, as `balancePool` allows it beside its own tests. Witness:
regress/3314_rounding_auto prints the four rows of main's oracle,
and the C++ binary prints the two rows its test expects; the whole
witness set of the previous commit (35 files) still prints
identically to main's oracle.

Co-Authored-By: GLM (Z.ai) via pi <noreply@z.ai>
Pi-Session: 01a163ec-1792677793
@jwiegley
jwiegley merged commit 81afe96 into main Nov 7, 2026
3 checks passed
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.

1 participant