A hierarchical accounting account. Virtual accounts are not balances; balances are derived from postings. Parent accounts aggregate children.
Fields
id—integer()— primary key (e.g.10)parent_id—integer() | nil— self-reference;nilfor roots (e.g.9ornil)code—String.t()— unique, stable, human-readable (colon-separated, e.g."ASSETS:CASH:USD:NOSTRO")name—String.t()— display name (e.g."Nostro USD")account_type—String.t()— one ofaccount_types/0(e.g."asset","liability","client")currency—String.t() | nil— required for posting accounts;nilfor aggregation accounts (e.g."USD"ornil)status—String.t()— one ofstatuses/0(default"active", e.g."frozen")posting_allowed—boolean()— only leaf accounts may allow postings (defaultfalse)normal_balance—String.t() | nil—"debit"or"credit"(e.g."debit")external_id—String.t() | nil— unique external reference (e.g."core_001")metadata—map()— extensible key/value store (default%{}, e.g.%{"iban" => "GB29..."})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
parent—belongs_to__MODULE__— the parent account (viaparent_id)children—has_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
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
@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
id—integer() | nil— primary key (e.g.10)parent_id—integer() | nil— parent account id;nilfor rootscode—String.t() | nil— unique code (e.g."ASSETS:CASH:USD:NOSTRO")name—String.t() | nil— display name (e.g."Nostro USD")account_type—String.t() | nil— e.g."asset","client"currency—String.t() | nil— e.g."USD"ornilfor aggregation accountsstatus—String.t() | nil— e.g."active","frozen"posting_allowed—boolean() | nil— whether postings target this accountnormal_balance—String.t() | nil—"debit"or"credit"external_id—String.t() | nil— unique external referencemetadata—map() | nil— extensible metadatainserted_at—DateTime.t() | nilupdated_at—DateTime.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
@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
@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]
@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]