Semiautomating Accountancy for Fun and Profit
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:
- csv2ledger.hs converts comma-separated values
to ledger entries.
There are a few configuration settings at the top of the script to tell it about account names and the input format. - buchungen.sh fetches transactions with
aqbanking and shows them via csv2ledger.
Usage:buchungen.sh [startdate [enddate]] # date format: YYYYMMDD