Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 1.22 KB

README.md

File metadata and controls

38 lines (28 loc) · 1.22 KB

ledgerex

Apache License Hex.pm Documentation Build Status Coverage Status

A parser for Ledger accounting files written in Elixir.

Caveat Emptor: It doesn't support the full range of ledger's capabilities. It's just the bare minimum I needed to parse my ~10 years worth of ledger files.

Pull requests more than welcome. Be nice.

Example

txt = """
2019/01/02 Hello AMEX
  Liabilities:AMEX       $2000.00
  Income                 $-2000.00 = $0

2019/01/02 Another AMEX
  Liabilities:AMEX       $4000.00
  Income
"""

# Load and parse the date
res = Ledger.Parsers.Ledger.parse(txt)

# Re-create the ledger file
Enum.each(res, fn x ->
  IO.puts(Ledger.Entry.to_string(x))
end)

Ledger.balance(txt)