# `Logistiki.Knowledge.PolicySelector`
[🔗](https://github.com/thanos/logistiki/blob/v0.1.0/lib/logistiki/knowledge/policy_selector.ex#L1)

Selects the accounting policy for a normalized event using the knowledge layer.

This is a thin façade over `Logistiki.Knowledge.KnowledgeBase` for callers
that only need the policy decision.

# `select`
*since 0.1.0* 

```elixir
@spec select(Logistiki.Event.Normalized.t()) ::
  {:ok, atom()}
  | {:error, :blocked_event | :approval_required | :no_policy_found | term()}
```

Returns the accounting policy for `normalized_event`, or an error.

## Arguments

  * `normalized_event` — `%Logistiki.Event.Normalized{}`.

## Returns

  * `{:ok, atom()}` — the selected policy (e.g. `:cash_deposit`).
  * `{:error, :blocked_event}` — a business rule blocked the event.
  * `{:error, :approval_required}` — the event requires approval.
  * `{:error, :no_policy_found}` — no policy matched.
  * `{:error, term()}` — knowledge evaluation failed.

## Examples

    iex> {:ok, :cash_deposit} = Logistiki.Knowledge.PolicySelector.select(normalized_deposit)
    iex> {:error, :blocked_event} = Logistiki.Knowledge.PolicySelector.select(blocked_event)
    iex> {:error, :no_policy_found} = Logistiki.Knowledge.PolicySelector.select(unknown_event)

---

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