Karl Hans Janke Kollaborativ
Heute die Welt, morgen das Sonnensystem!

oct 2009

Semiautomating Accountancy for Fun and Profit

z23.klein.jpg
Zuse Z23 @ Technikmuseum Berlin — definately a semiautomatic accountant!

Is anybody out there using ledger or one of its siblings for their personal accounting? If not, take this as a recommendation. It's a command-line tool to generate various financial reports from a plain text listing of account transactions. If you happen to have access to your bank transactions in csv format, the script I wrote yesterday may be useful to you. It reads comma-separated values from stdin and writes ledger entries to stdout.

If you're German, your likely way to get csv files from your bank is via HBCI. The right tool for the job appears to be aqbanking. Hooking it up to the bank is a bit of fiddling, so I'll reproduce the quick how-to here. This is assuming authentication via PIN/TAN:

$ aqhbci-tool4 adduser -t pintan --context=1 --hbciversion=300 \
        -b BLZ -u NUTZERKENNUNG -c KUNDENKENNUNG \
        -s SERVERURL \
        -N "Real Name"
$ aqhbci-tool4 getsysid -c KUNDENKENNUNG
$ aqhbci-tool4 getaccounts -c KUNDENKENNUNG

To fetch transactions from all accounts and print them in csv format:

$ aqbanking-cli request -c /tmp/foo.ctx --transactions
$ aqbanking-cli listtrans -c /tmp/foo.ctx

The csv2ledger script is tailored to the default output format of the above. I also have made a small shell script to drive these two commands and pipe the result through the converter. It accepts an optional date range to which to restrict the output.

Appendix: