HORIZON HASKELLDocslts/ghc-10.0.x8fef28d2026-11-02Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 8fef28d · 2026-11-02

Modulehledger-lib-1.52.4GHC2021

Hledger.Data.Balancing

Functions for ensuring transactions and journals are balanced.

Contents
  1. BalancingOpts
  2. transaction balancing
  3. assertion validation
  4. journal balancing
  5. tests
Synopsis

BalancingOpts

datadata BalancingOpts
#

Constructors

Instances4Eq, Ord, Show, HasBalancingOpts
classclass HasBalancingOpts c where
#
Instances2HasBalancingOpts

transaction balancing

Balance this isolated transaction, ensuring that its postings (and its balanced virtual postings) sum to 0, by inferring a missing amount or conversion price(s) if needed. Or if balancing is not possible, because the amounts don't sum to 0 or because there's more than one missing amount, return an error message.

Note this is not as accurate as balanceTransactionInJournal, which considers the whole journal when calculating balance assignments and balance assertions.

assertion validation

journal balancing

Infer any missing amounts and/or conversion costs (as needed to balance transactions and satisfy balance assignments); and check that all transactions are balanced; and (optional) check that all balance assertions pass. Or, return an error message (just the first error encountered).

Assumes journalStyleAmounts has been called, since amount styles affect transaction balancing.

This does multiple things at once because amount inferring, balance assignments, balance assertions and posting dates are interdependent.

tests