Logistiki.VirtualAccounts.VirtualAccount (logistiki v0.1.0)

Copy Markdown View Source

A hierarchical accounting account. Virtual accounts are not balances; balances are derived from postings. Parent accounts aggregate children.

Fields

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

  • codeString.t() — unique, stable, human-readable (colon-separated, e.g. "ASSETS:CASH:USD:NOSTRO")
  • nameString.t() — display name (e.g. "Nostro USD")
  • account_typeString.t() — one of account_types/0 (e.g. "asset", "liability", "client")
  • currencyString.t() | nil — required for posting accounts; nil for aggregation accounts (e.g. "USD" or nil)

  • statusString.t() — one of statuses/0 (default "active", e.g. "frozen")
  • posting_allowedboolean() — only leaf accounts may allow postings (default false)
  • normal_balanceString.t() | nil"debit" or "credit" (e.g. "debit")

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

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

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

Associations

  • parentbelongs_to __MODULE__ — the parent account (via parent_id)
  • childrenhas_many __MODULE__ — direct child accounts

Example

%Logistiki.VirtualAccounts.VirtualAccount{
  id: 10,
  parent_id: 9,
  code: "ASSETS:CASH:USD:NOSTRO",
  name: "Nostro USD",
  account_type: "asset",
  currency: "USD",
  posting_allowed: true,
  normal_balance: "debit",
  status: "active"
}

Summary

Types

t()

The VirtualAccount struct type.

Functions

Returns the list of allowed account types as atoms.

Returns the list of allowed normal-balance values as atoms.

Returns the list of allowed account statuses as atoms.

Types

t()

@type t() :: %Logistiki.VirtualAccounts.VirtualAccount{
  __meta__: term(),
  account_type: String.t() | nil,
  children: term(),
  code: String.t() | nil,
  currency: String.t() | nil,
  external_id: String.t() | nil,
  id: integer() | nil,
  inserted_at: DateTime.t() | nil,
  metadata: map() | nil,
  name: String.t() | nil,
  normal_balance: String.t() | nil,
  parent: term(),
  parent_id: integer() | nil,
  posting_allowed: boolean() | nil,
  status: String.t() | nil,
  updated_at: DateTime.t() | nil
}

The VirtualAccount struct type.

Represents a hierarchical accounting account. Balances are derived from postings — the account itself is not a balance.

Fields

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

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

  • codeString.t() | nil — unique code (e.g. "ASSETS:CASH:USD:NOSTRO")

  • nameString.t() | nil — display name (e.g. "Nostro USD")

  • account_typeString.t() | nil — e.g. "asset", "client"

  • currencyString.t() | nil — e.g. "USD" or nil for aggregation accounts

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

  • posting_allowedboolean() | nil — whether postings target this account

  • normal_balanceString.t() | nil"debit" or "credit"

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

  • metadatamap() | nil — extensible metadata

  • inserted_atDateTime.t() | nil

  • updated_atDateTime.t() | nil

Example

%Logistiki.VirtualAccounts.VirtualAccount{
  id: 10, parent_id: 9, code: "ASSETS:CASH:USD:NOSTRO",
  name: "Nostro USD", account_type: "asset", currency: "USD",
  posting_allowed: true, normal_balance: "debit", status: "active"
}

Functions

account_types()

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

Returns the list of allowed account types as atoms.

Returns

  • [atom()][:asset, :liability, :equity, :income, :expense, :client, :settlement, :suspense, :fee, :tax, :clearing]

Examples

iex> :asset in Logistiki.VirtualAccounts.VirtualAccount.account_types()
true

normal_balances()

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

Returns the list of allowed normal-balance values as atoms.

Returns

  • [atom()][:debit, :credit]

Examples

iex> Logistiki.VirtualAccounts.VirtualAccount.normal_balances()
[:debit, :credit]

statuses()

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

Returns the list of allowed account statuses as atoms.

Returns

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

Examples

iex> Logistiki.VirtualAccounts.VirtualAccount.statuses()
[:active, :inactive, :frozen, :closed]