Logistiki.Knowledge.Result (logistiki v0.1.0)

Copy Markdown View Source

The outcome of evaluating the knowledge layer for a single business event.

Captures the business-rule decisions, the selected accounting policy, the resolved posting template, the resolved account roles, and the required dimensions. The runtime turns this into a journal draft.

Fields

  • event_idterm() | nil — the originating event id

  • blockedboolean()true when a business rule blocked the event
  • requires_approvalboolean()true when approval is required
  • policyatom() | nil — the selected accounting policy (e.g. :cash_deposit)

  • templateatom() | nil — the selected template (= the policy in v0.1.0)

  • template_postings[map()] — ordered posting specs, each with :sequence, :direction, :role, :amount_var, :currency_var
  • account_roles%{atom() => String.t()} — resolved role-to-code mappings (e.g. %{cash_account: "ASSETS:CASH:USD:NOSTRO", ...})
  • required_dimensions[atom()] — e.g. [:entity_id, :currency, :account_code]
  • explanationmap() — why the policy was selected / blocked

Example

%Logistiki.Knowledge.Result{
  event_id: "evt_001",
  blocked: false,
  requires_approval: false,
  policy: :cash_deposit,
  template: :cash_deposit,
  template_postings: [
    %{sequence: 1, direction: :debit, role: :cash_account, ...},
    %{sequence: 2, direction: :credit, role: :client_liability_account, ...}
  ],
  account_roles: %{
    cash_account: "ASSETS:CASH:USD:NOSTRO",
    client_liability_account: "LIABILITIES:CLIENT_DEPOSITS:USD:ACME:OPERATING"
  },
  required_dimensions: [:entity_id, :currency, :account_code],
  explanation: %{reason: :unique, selected: :cash_deposit}
}

Summary

Types

t()

The struct type. See the module documentation for field details and examples.

Types

t()

@type t() :: %Logistiki.Knowledge.Result{
  account_roles: %{required(atom()) => String.t()},
  blocked: boolean(),
  event_id: term(),
  explanation: map(),
  policy: atom() | nil,
  required_dimensions: [atom()],
  requires_approval: boolean(),
  template: atom() | nil,
  template_postings: [map()]
}

The struct type. See the module documentation for field details and examples.