:total_recall:

# The version of total_recall that generated this file
:version: <%= @version %>

:template:

# 1). Provide the [mustache-template](https://github.com/defunkt/mustache)
#   for your ledger.
#
# Either assign a template to :raw: or point to a file via :file:.
# The location of :file: is relative to this file.
# :file: takes precedence over :raw:
#
# The template MUST contain a section `transactions`.
#
#:file: ledger.mustache
:raw: |-
  ; -*- ledger -*-¬
  ; Generated by total_recall at {{generated_at}}
  --decimal-comma

  {{# transactions}}
  {{date}} {{{description}}}
    {{to}}    {{currency}} {{amount}}
    {{from}}

  {{/ transactions}}

:csv:

# 2). Provide the csv
#
# Either assign csv to :raw: or point to a csv-file via :file:.
# :raw: is ideal for experimenting with the csv-format.
#
# The location of :file: is relative to this file.
# :file: takes precedence over :raw:
#
#:file: sample.csv
:raw: |-
  "date";"description";"effective_data";"amount"
  "2013-11-01";"Foo";"2013-11-02";"1.638,00"
  "2013-11-02";"Bar";"2013-11-03";"-492,93"
:options: 
  # Any option accepted by CSV#new (http://www.ruby-doc.org/stdlib-2.1.1/libdoc/csv/rdoc/CSV.html#method-c-new).
  :col_sep: ";"
  :headers: true
  :header_converters: :symbol # row[:date] rather than row[0]

:context:

# 3). Define the context
#
# The context is in essence the dictionary that will be applied to the template.
# The value for transactions will be expanded to an array, one for every line in the csv.
:transactions: 
  # transactions have defaults...
  :__defaults__: 
    :from: !!proc |
      ask_account("What account provides these transactions?",
                    default: 'Assets:Checking')
    :currency: $
  # ...and fields that vary per transaction.
  # Helper method exist such as `row`, `ask_account` (see `TotalRecall::SessionHelper` for more).
  :date: !!proc row[:date]
  :description: !!proc row[:description]
  :amount: !!proc row[:amount]
  :currency: !!proc |
    case row[:description]
    when /some regex to detect non-dollar/ then '€'
    else
      default
    end
  :to: !!proc |
    # show the row and let the user decide
    render_row(columns: [:date, :description, :amount])
    ask_account("To what account did the money go?")
:generated_at: !!proc Time.now

# You can add any other data needed: # :ticker_sybols: # “Apple”: AAPL # “Google Inc.”: GOOG # # Example usage: # :context: # :transactions: # :symbol: !!proc config[row]