Skip to main content

balance_tolerance

Function balance_tolerance 

Source
pub fn balance_tolerance(
    expected: Decimal,
    explicit: Option<Decimal>,
    tolerance_multiplier: Decimal,
) -> Decimal
Expand description

Compute the tolerance to apply when comparing a balance assertion’s expected amount against the booked actual.

  • expected: the asserted amount from the balance directive.
  • explicit: the ~ tolerance from the directive, if any (always wins).
  • tolerance_multiplier: the active inferred_tolerance_multiplier option (default 0.5; overridable via option "inferred_tolerance_multiplier" "...").

Mirrors the inline logic in validate_balance_late (private) so out-of-pipeline consumers (currently the LSP code-lens path) produce the same verdict as the validator without re-deriving the rule from the Beancount spec.

Matches Python beancount: https://github.com/beancount/beancount/blob/master/beancount/ops/balance.py