All Projects → eval → total_recall

eval / total_recall

Licence: other
Turn any csv into Ledger journals. Canonical repository can be found at -->

Programming Languages

ruby
36898 projects - #4 most used programming language

Labels

Projects that are alternatives of or similar to total recall

Ledger Autosync
Synchronize your ledger-cli files with your bank.
Stars: ✭ 189 (+1081.25%)
Mutual labels:  ledger
database-journal
Databases: Concepts, commands, codes, interview questions and more...
Stars: ✭ 50 (+212.5%)
Mutual labels:  ledger
ledg
Batch modifiable ledger-like written in nodejs
Stars: ✭ 32 (+100%)
Mutual labels:  ledger
Wavelet
Write once, run forever. Deploy robust, scalable, decentralized WebAssembly applications on Wavelet.
Stars: ✭ 224 (+1300%)
Mutual labels:  ledger
hledger-iadd
A terminal UI as drop-in replacement for hledger add.
Stars: ✭ 61 (+281.25%)
Mutual labels:  ledger
npo-ledger-cli
Give Up GitHub: https://GiveUpGitHub.org
Stars: ✭ 57 (+256.25%)
Mutual labels:  ledger
Abandon
😌 Simple and Robust Accounting
Stars: ✭ 155 (+868.75%)
Mutual labels:  ledger
nledger
.Net Ledger: Double-Entry Accounting System
Stars: ✭ 141 (+781.25%)
Mutual labels:  ledger
sage
💸 Download from your banks and credit cards straight to your computer
Stars: ✭ 51 (+218.75%)
Mutual labels:  ledger
bankster
Money Creation Made Easy
Stars: ✭ 30 (+87.5%)
Mutual labels:  ledger
Frame
System-wide Web3 for macOS, Windows and Linux
Stars: ✭ 225 (+1306.25%)
Mutual labels:  ledger
Vim Ledger
Vim plugin for Ledger
Stars: ✭ 253 (+1481.25%)
Mutual labels:  ledger
conceal-desktop
Conceal Desktop (GUI)
Stars: ✭ 65 (+306.25%)
Mutual labels:  ledger
Insolar
Enterprise-ready blockchain platform
Stars: ✭ 192 (+1100%)
Mutual labels:  ledger
Credits
Credits(CRDS) - An Evolving Currency For An Evolving Society
Stars: ✭ 14 (-12.5%)
Mutual labels:  ledger
Blockvotes
An e-voting system based on blockchain using ring signature
Stars: ✭ 182 (+1037.5%)
Mutual labels:  ledger
ledger-app-nano
Ledger Nano X, Nano S & Blue applications for NANO and derivative coins
Stars: ✭ 34 (+112.5%)
Mutual labels:  ledger
ripple-binary-codec
Convert between json and hex representations of transactions and ledger entries on the XRP Ledger. Moved to: https://github.com/XRPLF/xrpl.js/tree/develop/packages/ripple-binary-codec
Stars: ✭ 18 (+12.5%)
Mutual labels:  ledger
ledgers
No description or website provided.
Stars: ✭ 26 (+62.5%)
Mutual labels:  ledger
pygnucash
Python code to read gnucash 2.6 sqlite3 files; features gnucash 2 ledger translator.
Stars: ✭ 31 (+93.75%)
Mutual labels:  ledger

TotalRecall build status

Turn any csv-file into a Ledger journal.

Introduction

total_recall assumes nothing about the structure of your csv, nor of the ledger-file you want to create.
Instead, one creates a yaml-config consisting of:

  • a mustache-template of the ledger-file
  • the source (and parse-options) of the csv
  • the value of every template-variable via Ruby lambdas

Example

After installation you run total_recall init bank to generate the following file:

# file: bank.yml
:total_recall:
  :version: 0.6.0
:template:
  :raw: |-
    ; -*- ledger -*-¬

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

    {{/ transactions}}

:csv:
  #:file: total_recall.csv
  :raw: |-
    "2013-11-01","Foo","2013-11-02","1.638,00"
    "2013-11-02","Bar","2013-11-03","-492,93"
  :options:
    #:col_sep: ";"
    #:headers: false

:context:
  :transactions:
    :__defaults__:
      :from: !!proc |
        ask_account("What account provides these transactions?", default: 'Assets:Checking')
    :date: !!proc row[0]
    :description: !!proc row[1]
    :amount: !!proc row[3]
    :to: !!proc |
      render_row(columns: [0, 1, 3])
      ask_account("To what account did the money go?")

The template-section is pretty straightforward: you can add any variable you need using the mustache-syntax.
The csv-section defines where csv comes from and what parse-options should be used. It's best to start with a csv-snippet in raw (and leave file commented) in order to test-run the config.

In the context-section the actual mapping is done: in this section your should define a key for every variable in the template.
A key's value is derived from the csv via Ruby. This can be done via a simple mapping: :date: !!proc row[0], via some specific operation: :data: !!proc Date.parse(row[0]).iso8601 or via one of the interactive helpers as you can see for the to-field above.
Fields can also have default-values: the from-field for example is the same for all rows.

As it's all Ruby, you can make the mapping as smart as you like:

:context:
  :transactions:
    :description: !!proc row[3]
    :to: !!proc |
      guess = begin
        case self.description # the description-field is defined above
        when /CREDITCARD/ then "Liabilities:MasterCard"
        when /INTERNET/i then "Expenses:Communication"
        end
      end
      ask_account("To what account did the money go?", default: guess)
...

See Extensibility below for providing your own Ruby module with helpers (i.e. your own self-learning account-guesser!).

Once your config is done, you can give it a spin:

# the result will be echoed:
$ total_recall ledger -c bank.yml

# to quickly see if the output is actually valid ledger:
$ total_recall ledger -c bank.yml | ledger -f - reg

When the output looks good and doesn't make Ledger choke, you can uncomment the file-key in the csv-section and run it against the real csv-data:

$ total_recall ledger -c bank.yml > bank.dat

That's it!

To see an extensive annotated config-file do:

$ total_recall sample

Install

gem install total_recall

Usage

total_recall

# Commands:
#   total_recall help [COMMAND]              # Describe available commands or one specific command
#   total_recall init NAME                   # Generate a minimal config NAME.yml
#   total_recall ledger -c, --config=CONFIG  # Convert CONFIG to a ledger
#   total_recall sample                      # Generate an annotated config
#   total_recall version                     # Show total_recall version

# typically you would do:
total_recall init my-bank

# fiddle with the settings in 'my-bank.yml' and test-run it:
total_recal ledger -c my-bank.yml
# to skip prompts just provide dummy-data:
yes 'Dummy' | total_recal ledger -c my-bank.yml

# export it to a journal:
total_recall ledger -c my-bank.yml > my-bank.dat

# verify correctness with ledger:
ledger -f my-bank.dat bal

Extensibility

You can extend the ledger subcommand by passing a file with additions to it:

total_recall ledger -c my-bank.yml -r ./my_extension.rb

This makes it possible to add helpers or redefine existing ones:

cat my_extension.rb
module MyExtension
  # adding some options to an existing helper:
  def ask_account(question, options = {})
    question.upcase! if options.delete(:scream)
    super
  end

  # a new helper:
  def guess_account(question, options = {})
    guess = Guesser.new.guess
    ask_account(question, default: guess)
  end
end

TotalRecall::SessionHelper.include MyExtension

Develop

git clone https://gitlab.com/eval/total_recall.git
cd total_recall
bundle
bundle exec rake spec

Author

Gert Goet (eval) :: [email protected] :: @gertgoet

License

(The MIT license)

Copyright (c) 2017 Gert Goet, ThinkCreate

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].