Logistiki.BusinessEntities.BusinessEntity (logistiki v0.1.0)

Copy Markdown View Source

A hierarchical business entity: legal, operational, customer, organizational, or ownership structure.

Entities form a tree maintained through a closure table (Logistiki.BusinessEntities.BusinessEntityClosure). Each entity may have a parent_id pointing to its parent; roots have parent_id: nil.

Fields

  • idinteger() — primary key (e.g. 1)
  • parent_idinteger() | nil — self-reference; nil for roots (e.g. nil or 1)

  • nameString.t() — display name (required) (e.g. "Acme Holdings")
  • legal_nameString.t() | nil — legal name (e.g. "Acme Holdings LLC")

  • entity_typeString.t() — one of types/0 (default "company", e.g. "trust", "individual")
  • statusString.t() — one of statuses/0 (default "pending", e.g. "active", "frozen")
  • jurisdictionString.t() | nil — e.g. "US", "EU", "GB"

  • external_idString.t() | nil — unique external reference (e.g. "crm_12345")

  • metadatamap() — extensible key/value store (default %{}, e.g. %{"risk_score" => "low"})
  • inserted_atDateTime.t() | nil — set by Ecto timestamps (e.g. ~U[2026-07-07 12:00:00Z])

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

Associations

  • parentbelongs_to __MODULE__ — the parent entity (via parent_id)
  • childrenhas_many __MODULE__ — direct child entities

Example

%Logistiki.BusinessEntities.BusinessEntity{
  id: 1,
  parent_id: nil,
  name: "Acme Holdings",
  legal_name: "Acme Holdings LLC",
  entity_type: "company",
  status: "active",
  jurisdiction: "US",
  external_id: "crm_12345",
  metadata: %{"risk_score" => "low"},
  inserted_at: ~U[2026-07-07 12:00:00Z],
  updated_at: ~U[2026-07-07 12:00:00Z]
}

Summary

Types

t()

The BusinessEntity struct type.

Functions

Returns the list of allowed entity statuses as atoms.

Returns the list of allowed entity types as atoms.

Types

t()

@type t() :: %Logistiki.BusinessEntities.BusinessEntity{
  __meta__: term(),
  children: term(),
  entity_type: String.t() | nil,
  external_id: String.t() | nil,
  id: integer() | nil,
  inserted_at: DateTime.t() | nil,
  jurisdiction: String.t() | nil,
  legal_name: String.t() | nil,
  metadata: map() | nil,
  name: String.t() | nil,
  parent: term(),
  parent_id: integer() | nil,
  status: String.t() | nil,
  updated_at: DateTime.t() | nil
}

The BusinessEntity struct type.

Represents a hierarchical business entity with provenance, status, and extensible metadata.

Fields

  • idinteger() | nil — primary key (e.g. 1)

  • parent_idinteger() | nil — parent entity id; nil for roots

  • nameString.t() | nil — display name (e.g. "Acme Holdings")

  • legal_nameString.t() | nil — legal name

  • entity_typeString.t() | nil — e.g. "company", "trust"

  • statusString.t() | nil — e.g. "active", "frozen"

  • jurisdictionString.t() | nil — e.g. "US"

  • external_idString.t() | nil — unique external reference

  • metadatamap() | nil — extensible metadata

  • inserted_atDateTime.t() | nil

  • updated_atDateTime.t() | nil

Example

%Logistiki.BusinessEntities.BusinessEntity{
  id: 1, parent_id: nil, name: "Acme Holdings",
  entity_type: "company", status: "active"
}

Functions

statuses()

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

Returns the list of allowed entity statuses as atoms.

Returns

  • [atom()][:pending, :active, :inactive, :frozen, :closed]

Examples

iex> Logistiki.BusinessEntities.BusinessEntity.statuses()
[:pending, :active, :inactive, :frozen, :closed]

types()

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

Returns the list of allowed entity types as atoms.

Returns

  • [atom()][:individual, :company, :trust, :partnership, :fund, :bank, :branch, :department, :counterparty, :internal]

Examples

iex> :company in Logistiki.BusinessEntities.BusinessEntity.types()
true