Logistiki.Events.BusinessEvent (logistiki v0.1.0)

Copy Markdown View Source

Persisted record of a normalized business event.

Business event persistence enables replay and audit. The payload stores the original event as published by the application; normalized_payload stores the flattened Logistiki.Event.Normalized representation used by the pipeline.

Fields

  • idinteger() — primary key (e.g. 1)
  • event_typeString.t() — e.g. "deposit_received", "fee_assessed"
  • source_systemString.t() | nil — e.g. "bank_core", "onboarding"

  • source_idString.t() | nil — e.g. "wire_123", "crm_456"

  • actor_idString.t() | nil — who initiated the event (e.g. "user_789")

  • occurred_atDateTime.t() | nil — when the event happened (e.g. ~U[2026-07-07 12:00:00Z])

  • effective_dateDate.t() | nil — accounting effective date (e.g. ~D[2026-07-07])

  • payloadmap() — the original event as a string-keyed map (default %{})
  • normalized_payloadmap() | nil — the Normalized.to_map/1 representation

  • statusString.t() — one of statuses/0 (default "received", e.g. "processed")
  • explanationmap() | nil — pipeline explanation (on completion)

  • metadatamap() — extensible metadata (default %{})
  • inserted_atDateTime.t() | nil — set by Ecto

  • updated_atDateTime.t() | nil — set by Ecto

Status transitions

receivednormalizedprocessed (or no_accounting_impact, blocked, requires_approval, failed).

Example

%Logistiki.Events.BusinessEvent{
  id: 1,
  event_type: "deposit_received",
  source_system: "bank_core",
  source_id: "wire_123",
  status: "processed",
  normalized_payload: %{"id" => "evt_001", "type" => "deposit_received", ...},
  inserted_at: ~U[2026-07-07 12:00:00Z]
}

Summary

Types

t()

The BusinessEvent struct type — a persisted record of a normalized business event.

Functions

Returns the list of allowed business-event statuses as atoms.

Types

t()

@type t() :: %Logistiki.Events.BusinessEvent{
  __meta__: term(),
  actor_id: String.t() | nil,
  effective_date: Date.t() | nil,
  event_type: String.t() | nil,
  explanation: map() | nil,
  id: integer() | nil,
  inserted_at: DateTime.t() | nil,
  metadata: map() | nil,
  normalized_payload: map() | nil,
  occurred_at: DateTime.t() | nil,
  payload: map() | nil,
  source_id: String.t() | nil,
  source_system: String.t() | nil,
  status: String.t() | nil,
  updated_at: DateTime.t() | nil
}

The BusinessEvent struct type — a persisted record of a normalized business event.

Fields

  • idinteger() | nil — primary key

  • event_typeString.t() | nil — e.g. "deposit_received"

  • source_systemString.t() | nil — e.g. "bank_core"

  • source_idString.t() | nil — e.g. "wire_123"

  • actor_idString.t() | nil — e.g. "user_789"

  • occurred_atDateTime.t() | nil — e.g. ~U[2026-07-07 12:00:00Z]

  • effective_dateDate.t() | nil — e.g. ~D[2026-07-07]

  • payloadmap() | nil — original event as a string-keyed map

  • normalized_payloadmap() | nil — flattened event representation

  • statusString.t() | nil — e.g. "processed", "blocked"

  • explanationmap() | nil — pipeline explanation

  • metadatamap() | nil — extensible metadata

  • inserted_atDateTime.t() | nil

  • updated_atDateTime.t() | nil

Example

%Logistiki.Events.BusinessEvent{
  id: 1, event_type: "deposit_received", status: "processed"
}

Functions

statuses()

(since 0.1.0)
@spec statuses() :: [atom(), ...]

Returns the list of allowed business-event statuses as atoms.

Returns

  • [atom()][:received, :normalized, :blocked, :requires_approval, :processed, :no_accounting_impact, :failed]

Examples

iex> :processed in Logistiki.Events.BusinessEvent.statuses()
true