fix(core): the audit checks a close's split at the allocation's unit

audit::closes took its unit as minor_units().unwrap_or(2), while the members allocation splits at allocation_places() (minor_units().unwrap_or(MAX_LINE_SCALE)). For a currency code with no minor unit the audit therefore checked a split made at the finest a line carries against a cent: far looser than the split it checks, so real drift passed.

Add Currency::allocation_unit(), the one helper that turns allocation_places() into an amount, and take the audit's unit from it, so the split and its check cannot drift apart (BS-partner-1 statement 4: the allocation is the split to the base currency's smallest unit). A JPY close is now checked at a whole yen.

Test: a_jpy_close_is_checked_at_the_allocations_unit (BS-partner-1 statement 4, WB-ledger-16 invariant 8).

Co-Authored-By: Muse Wonder 1.0
This commit is contained in:
swaitsandMuse Wonder 1.0 committed 2026-11-09 14:48:59 -07:00
1 parent 4da1c5b30f
commit 5b1596f977
4 files changed
+96 -2

No files matched your search

+5 -1
View File
@@ -519,7 +519,10 @@ INVARIANTS:
rule that posted an entry (its true-up, statement 6; the close
journals its rule and whether it posted), a member's running total
MUST be under one minor unit from its exact share, so a drift of a
unit or more is a finding. Before that true-up the count may still
unit or more is a finding. The unit is the allocation's own
(`Currency::allocation_unit`, on `allocation_places`: a whole yen
for JPY, the finest a line carries for a code with no minor unit),
never a cent taken separately. Before that true-up the count may still
carry the rounding of closes made under the older rules, so only a
drift beyond one unit is. Closes under the older rules are not read.
SCENARIOS:
@@ -552,6 +555,7 @@ journal feature `audits`.
(`the_cash_flow_check_says_what_it_found`,
`control_accounts_report_differences_unattached_lines_and_overpaid_documents`,
`a_close_split_drifts_by_the_regime_it_was_made_under`,
`a_jpy_close_is_checked_at_the_allocations_unit`,
`a_count_is_trued_up_by_the_first_cumulative_close_that_posts`,
`a_reversal_without_its_own_receipt_is_info_and_only_when_the_policy_would_cover_it`,
`the_bar_setting_parses_what_it_names_and_refuses_the_rest`,