# `Beancount.Directives.Open`
[🔗](https://github.com/thanos/beancount_ex/blob/v0.6.0/lib/beancount/directives/open.ex#L1)

The `open` directive declares the start of an account's life.

See the [Beancount Open directive](https://beancount.github.io/docs/beancount_language_syntax/#open).

## Beancount syntax

    2026-01-01 open Assets:Bank USD,EUR "STRICT"
      note: "Primary checking"

General form: `YYYY-MM-DD open Account [Currency,...] ["BookingMethod"]`

## Elixir struct

    %Beancount.Directives.Open{
      date: ~D[2026-01-01],
      account: "Assets:Bank",
      currencies: ["USD", "EUR"],
      booking: "STRICT",
      metadata: %{"note" => "Primary checking"}
    }

Prefer `Beancount.open/4` when building ledgers programmatically:

    Beancount.open(~D[2026-01-01], "Assets:Bank", ["USD", "EUR"],
      booking: "STRICT",
      metadata: %{"note" => "Primary checking"}
    )

## Fields

  * `date` - `Date.t()` when the account becomes active. Must be on or before the
    first posting to this account.
  * `account` - colon-separated account name, e.g. `"Assets:Bank"`.
  * `currencies` - optional list of allowed commodities for postings to this
    account. Empty list `[]` means no constraint. Rendered comma-separated in
    the `.bean` file.
  * `booking` - lot-matching method when a reducing posting is ambiguous.
    Common values: `"STRICT"` (default; error on ambiguity), `"NONE"`,
    `"FIFO"`, `"LIFO"`, `"AVERAGE"`, `"HIFO"`. `nil` omits the booking clause.
  * `metadata` - optional map of key/value pairs rendered as indented metadata
    lines below the directive.

# `t`

```elixir
@type t() :: %Beancount.Directives.Open{
  account: String.t(),
  booking: String.t() | nil,
  currencies: [String.t()],
  date: Date.t(),
  metadata: map()
}
```

---

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