Packages

An idiomatic Elixir interface to Beancount that serves as the long-term behavioral oracle for a future native Elixir General Ledger.

Current section

Files

Jump to
beancount_ex lib beancount directives include.ex
Raw

lib/beancount/directives/include.ex

defmodule Beancount.Directives.Include do
@moduledoc """
The `include` directive pulls another ledger file into the current one.
See [Includes](https://beancount.github.io/docs/beancount_language_syntax/#includes).
## Beancount syntax
include "accounts/checking.bean"
General form: `include "Path"`
This directive has no date. Place it at the top of a directive list, before
dated entries, to mirror real Beancount file layout.
## Elixir struct
%Beancount.Directives.Include{
path: "accounts/checking.bean"
}
Or use `Beancount.include/1`:
Beancount.include("accounts/checking.bean")
## Fields
* `path` - relative or absolute path to another `.bean` file. Rendered as a
quoted string.
"""
alias Beancount.Renderer
@enforce_keys [:path]
defstruct path: nil
@type t :: %__MODULE__{path: String.t()}
defimpl Beancount.Directive do
def to_bean(%{path: path}) do
"include " <> Renderer.quote_string(path)
end
end
end