Logistiki.Ledger.Behaviour behaviour (logistiki v0.1.0)

Copy Markdown View Source

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:

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

Summary

Callbacks

balance(account, opts)

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

execute_journal(journal, opts)

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

reverse_journal(journal, attrs, opts)

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

statement(account, opts)

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

trial_balance(opts)

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