Skip to content

Instantly share code, notes, and snippets.

@margold
Created November 16, 2016 21:24
Show Gist options
  • Save margold/b1993ac2225233844005673a4be66f93 to your computer and use it in GitHub Desktop.
Save margold/b1993ac2225233844005673a4be66f93 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Usage: ./comdirect.sh MM
# Specify BLZ and GIROKONTO before running!
BLZ=
GIROKONTO=
MONTH=$1
# Note:
# Since comdirect has the same account number for both Depot and Girokonto,
# you need to specify the subaccount ID when querying.
# See my writeup at https://devel.aqbanking.de/trac/aqbanking/ticket/237
# use `gdate` from `coreutils` package on OSX
case `uname -s` in
"Darwin")
date=gdate
;;
*)
date=date
;;
esac
START_OF_MONTH=`$date +%Y${MONTH}01`
END_OF_MONTH=`$date -d "$($date +%Y-${MONTH}-01) +1 month -1 day" +%Y%m%d`
PINFILE=pinfile
TMPFILE=tmp.ctx
EXPORTER=csv
PROFILE=default # `comdirect` profile doesn't contain full "purpose" info
RAW_TRANSACTIONS=transactions.csv
echo "Saving transactions from $START_OF_MONTH to $END_OF_MONTH to $RAW_TRANSACTIONS..."
# get transactions
aqbanking-cli --noninteractive --pinfile=$PINFILE request --transactions \
--fromdate=$START_OF_MONTH --todate=$END_OF_MONTH \
--bank=$BLZ --account=$GIROKONTO --subaccount=Girokonto \
--ctxfile=$TMPFILE
# parse transactions into the csv file $RAW_TRANSACTIONS
aqbanking-cli --noninteractive listtrans \
--bank=$BLZ --account=$GIROKONTO \
--exporter=$EXPORTER --profile=$PROFILE \
--ctxfile=$TMPFILE --outfile=$RAW_TRANSACTIONS
rm $TMPFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment