A single posting (leg) of a Beancount.Directives.Transaction.
See Costs and Prices in the Beancount syntax guide.
Beancount syntax
Assets:ETrade:IVV -10 IVV {183.07 USD} @ 197.90 USD
trade-id: "T-991"
Expenses:RestaurantA posting may elide amount and currency; Beancount infers them when balancing.
Elixir struct
%Beancount.Directives.Posting{
account: "Assets:ETrade:IVV",
amount: Decimal.new("-10"),
currency: "IVV",
cost: %Beancount.CostSpec{
per_amount: Decimal.new("183.07"),
per_currency: "USD",
total_amount: nil,
total_currency: nil,
date: nil,
label: nil,
merge: false
},
price: %{amount: Decimal.new("197.90"), currency: "USD", type: :unit},
flag: nil,
metadata: %{"trade-id" => "T-991"}
}Elided amount (inferred by Beancount):
%Beancount.Directives.Posting{
account: "Expenses:Restaurant",
amount: nil,
currency: nil,
cost: nil,
price: nil,
flag: nil,
metadata: %{}
}Or use Beancount.posting/4:
Beancount.posting("Assets:ETrade:IVV", Decimal.new("-10"), "IVV",
cost: %{amount: Decimal.new("183.07"), currency: "USD"},
price: %{amount: Decimal.new("197.90"), currency: "USD", type: :unit},
metadata: %{"trade-id" => "T-991"}
)Fields
account- colon-separated account receiving the posting.amount-Decimal.t()units posted, ornilto elide (Beancount interpolates the balancing amount).currency- commodity symbol foramount, ornilwhen elided.cost-Beancount.CostSpec(or legacy%{amount:, currency:}map) for inventory held at cost, e.g.{183.07 USD}.nilfor simple amounts.price- unit price%{amount:, currency:, type: :unit}(@ 1.2 USD) or total pricetype: :total(@@ 120 USD).nilwhen absent.flag- optional per-posting flag ("!", etc.) rendered before the account name.metadata- optional map rendered as indented lines under the posting.
Summary
Types
A cost specification. See Beancount.CostSpec.
A price annotation, e.g. @ 1.2 USD or @@ 120 USD.
Types
@type cost() :: Beancount.CostSpec.t() | map() | nil
A cost specification. See Beancount.CostSpec.
A price annotation, e.g. @ 1.2 USD or @@ 120 USD.