-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgencsv.sh
46 lines (36 loc) · 1.17 KB
/
gencsv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
set -e -u -o pipefail
WORKPATH="$HOME/.aqbanking"
source "$WORKPATH/env"
if [ -s ${WORKPATH}/TODATE ]
then
FROMDATE=$( date +%Y%m%d -d "$( < ${WORKPATH}/TODATE ) + 1 day ")
if [ "${FROMDATE}" = "$( date +%Y%m%d )" ]
then
echo "Nothing to do!"
exit 0
fi
else
FROMDATE=$( date +%Y%m%d -d '2 day ago' )
fi
TODATE="$( date +%Y%m%d -d '1 day ago' )"
echo "From $FROMDATE to $TODATE"
aqhbci-tool4 -P ${WORKPATH}/pinfile getaccounts -u 1
test -f ${WORKPATH}/pinfile || echo "PINFILE missing"
cd $WORKPATH
for KTO in $KTOS
do
aqbanking-cli --acceptvalidcerts -n -P ${WORKPATH}/pinfile request --account=${KTO} --fromdate=${FROMDATE} --todate=${TODATE} --transactions --balance > /dev/shm/${KTO}.ctx
aqbanking-cli export --exporter=csv --profile-file=/opt/dkb-csv-export-profile.conf -tt statement < /dev/shm/${KTO}.ctx > /dev/shm/${KTO}-${FROMDATE}-${TODATE}.csv
balances.py /dev/shm/${KTO}.ctx > $WORKPATH/balance/${KTO}
done
#
# convert csv
for FILE in $( find /dev/shm/ -type f -name '*.csv' )
do
FILENAME=$( basename $FILE )
csv-convert.py --input $FILE --output $WORKPATH/$FILENAME
rm -v $FILE
done
echo ${TODATE} > ${WORKPATH}/TODATE
echo "DONE"