# `Logistiki.Relationships.EntityAccount`
[🔗](https://github.com/thanos/logistiki/blob/v0.1.0/lib/logistiki/relationships/entity_account.ex#L1)

A many-to-many relationship between a business entity and a virtual account,
with effective dating and a relationship type.

## Fields

  * `id` — `integer()` — primary key (e.g. `1`)
  * `business_entity_id` — `integer()` — FK to `business_entities` (e.g. `1`)
  * `virtual_account_id` — `integer()` — FK to `virtual_accounts` (e.g. `10`)
  * `relationship_type` — `String.t()` — one of `relationship_types/0` (e.g. `"owner"`, `"beneficiary"`)
  * `valid_from` — `Date.t()` — when the relationship became active (e.g. `~D[2026-07-07]`)
  * `valid_to` — `Date.t() | nil` — when it ended; `nil` while still active (e.g. `nil` or `~D[2026-12-31]`)
  * `metadata` — `map()` — extensible key/value store (default `%{}`, e.g. `%{"note" => "joint account"}`)
  * `inserted_at` — `DateTime.t() | nil` — set by Ecto (e.g. `~U[2026-07-07 12:00:00Z]`)
  * `updated_at` — `DateTime.t() | nil` — set by Ecto

## Associations

  * `business_entity` — `belongs_to` `Logistiki.BusinessEntities.BusinessEntity`
  * `virtual_account` — `belongs_to` `Logistiki.VirtualAccounts.VirtualAccount`

## Unique constraint

The pair `(business_entity_id, virtual_account_id, relationship_type)` is
unique — but multiple relationship *types* between the same entity and
account are allowed (e.g. `:owner` and `:beneficiary`).

## Example

    %Logistiki.Relationships.EntityAccount{
      id: 1,
      business_entity_id: 1,
      virtual_account_id: 10,
      relationship_type: "owner",
      valid_from: ~D[2026-07-07],
      valid_to: nil,
      metadata: %{"note" => "primary owner"}
    }

# `t`

```elixir
@type t() :: %Logistiki.Relationships.EntityAccount{
  __meta__: term(),
  business_entity: term(),
  business_entity_id: integer() | nil,
  id: integer() | nil,
  inserted_at: DateTime.t() | nil,
  metadata: map() | nil,
  relationship_type: String.t() | nil,
  updated_at: DateTime.t() | nil,
  valid_from: Date.t() | nil,
  valid_to: Date.t() | nil,
  virtual_account: term(),
  virtual_account_id: integer() | nil
}
```

The `EntityAccount` struct type.

Represents a many-to-many link between a business entity and a virtual
account with effective dating and a relationship type.

## Fields

  * `id` — `integer() | nil` — primary key
  * `business_entity_id` — `integer() | nil` — FK to `business_entities`
  * `virtual_account_id` — `integer() | nil` — FK to `virtual_accounts`
  * `relationship_type` — `String.t() | nil` — e.g. `"owner"`, `"beneficiary"`
  * `valid_from` — `Date.t() | nil` — when the relationship became active
  * `valid_to` — `Date.t() | nil` — when it ended; `nil` while active
  * `metadata` — `map() | nil` — extensible metadata
  * `inserted_at` — `DateTime.t() | nil`
  * `updated_at` — `DateTime.t() | nil`

## Example

    %Logistiki.Relationships.EntityAccount{
      id: 1, business_entity_id: 1, virtual_account_id: 10,
      relationship_type: "owner", valid_from: ~D[2026-07-07], valid_to: nil
    }

# `relationship_types`
*since 0.1.0* 

```elixir
@spec relationship_types() :: [atom(), ...]
```

Returns the list of allowed relationship types as atoms.

## Returns

  * `[atom()]` — `[:owner, :beneficiary, :controller, :signatory, :viewer,
    :trustee, :related_party, :manager, :custodian]`

## Examples

    iex> :owner in Logistiki.Relationships.EntityAccount.relationship_types()
    true

---

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