# `Beancount.Schemas.CostSpec`
[🔗](https://github.com/thanos/beancount_ex/blob/v0.6.0/lib/beancount/schemas/cost_spec.ex#L1)

Persisted cost/lot specification (embedded schema).

Storage-layer counterpart of `Beancount.CostSpec`. Embedded inside
`Beancount.Schemas.Posting` via `embeds_one/3`; it has no table of its own.

## Fields

  * `per_amount` - per-unit cost as `Decimal.t()`, or `nil`.
  * `per_currency` - currency for `per_amount`.
  * `total_amount` - total cost for all units (`{{...}}`), or `nil`.
  * `total_currency` - currency for `total_amount`.
  * `date` - acquisition `Date.t()` used for lot matching, or `nil`.
  * `label` - lot label string, or `nil`.
  * `merge` - when `true`, matching lots are merged on deposit.

## Example

    %Beancount.Schemas.CostSpec{
      per_amount: Decimal.new("150"),
      per_currency: "USD",
      total_amount: nil,
      total_currency: nil,
      date: ~D[2026-01-02],
      label: "lot-a",
      merge: false
    }

# `t`

```elixir
@type t() :: %Beancount.Schemas.CostSpec{
  date: term(),
  id: term(),
  label: term(),
  merge: term(),
  per_amount: term(),
  per_currency: term(),
  total_amount: term(),
  total_currency: term()
}
```

---

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