# `Beancount.Compare`
[🔗](https://github.com/thanos/beancount_ex/blob/v0.6.0/lib/beancount/compare.ex#L1)

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`).

# `compare`

```elixir
@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}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
