# `Logistiki.Ledger.Behaviour`
[🔗](https://github.com/thanos/logistiki/blob/v0.1.0/lib/logistiki/ledger/behaviour.ex#L1)

Behaviour implemented by ledger backends.

The runtime calls the configured backend (see `config :logistiki,
:ledger_backend`) to execute journals, reverse them, and compute
projections.

Initial backends:

  * `Logistiki.Ledger.Simulation` — fast, deterministic, no external deps
  * `Logistiki.Ledger.Beancount` — the accounting oracle via `beancount_ex`

Backends must not leak their own types into the public API. Results are
returned as `Logistiki.Projections.*` structs.

# `balance`

```elixir
@callback balance(account :: term(), opts :: keyword()) ::
  {:ok, Logistiki.Projections.Balance.t()} | {:error, term()}
```

# `execute_journal`

```elixir
@callback execute_journal(journal :: Logistiki.Accounting.Journal.t(), opts :: keyword()) ::
  {:ok, Logistiki.Ledger.Result.t()} | {:error, term()}
```

# `reverse_journal`

```elixir
@callback reverse_journal(
  journal :: Logistiki.Accounting.Journal.t(),
  attrs :: map(),
  opts :: keyword()
) ::
  {:ok, Logistiki.Ledger.Result.t()} | {:error, term()}
```

# `statement`

```elixir
@callback statement(account :: term(), opts :: keyword()) ::
  {:ok, [Logistiki.Projections.StatementLine.t()]} | {:error, term()}
```

# `trial_balance`

```elixir
@callback trial_balance(opts :: keyword()) ::
  {:ok, Logistiki.Projections.TrialBalance.t()} | {:error, term()}
```

---

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