Beancount.Compare (beancount_ex v0.6.0)

Copy Markdown View Source

Compare two engines on identical input within the v0.4 parity contract.

Equivalence is asserted for structural check/1 results (by error category) and the canned report query set (balances, balance_sheet, income_statement, holdings).

Summary

Functions

Run check and canned reports through both engines on the same input.

Functions

compare(oracle, native, input)

@spec compare(module(), module(), Beancount.directive() | binary()) ::
  {:ok, :equivalent} | {:error, Beancount.Property.Diff.t()}

Run check and canned reports through both engines on the same input.

Returns {:ok, :equivalent} when normalized results match, or {:error, %Diff{}} describing the first mismatch.

Examples

iex> ledger = [
...>   Beancount.open(~D[2026-01-01], "Assets:Bank", ["USD"]),
...>   Beancount.open(~D[2026-01-01], "Income:Salary", ["USD"]),
...>   Beancount.open(~D[2026-01-01], "Equity:Opening", ["USD"]),
...>   Beancount.transaction(~D[2026-01-31], "*", nil, "Salary", [
...>     Beancount.posting("Assets:Bank", Decimal.new("100"), "USD"),
...>     Beancount.posting("Income:Salary", Decimal.new("-100"), "USD")
...>   ])
...> ]
iex> Beancount.Compare.compare(Beancount.Engine.Elixir, Beancount.Engine.Elixir, ledger)
{:ok, :equivalent}