Expand year url, prepare check.

This commit is contained in:
Dominik Pantůček 2023-05-25 23:10:46 +02:00
parent cc34273c77
commit d5c016e4d4

View file

@ -139,6 +139,15 @@ download_file() {
done
}
#
# Downloads single year
# $1 - apikey
# $2 - year
# $3 - destination file name
download_year() {
echo "${APIURI}/periods/$1/$2-01-01/$2-12-31/transactions.csv"
}
# Current year (last in seq)
CYEAR=`date +%Y`
@ -171,13 +180,15 @@ while read accnt ; do
continue
fi
# Log action
# Iterate over years
for year in `seq $YEAR $CYEAR` ; do
# Log action
log "Processing account $ACCNO for $year"
# Fetch CSV from bank
CSVNAME="$BANK_DIR/$ACCNO.csv"
#download_file "${APIURI}/periods/${APIKEY}/2015-01-01/2025-01-31/transactions.csv" "$CSVNAME"
# Check whether it needs fetching
CSVNAME="$BANK_DIR_PARTS/$ACCNO-$year.csv"
echo "CSVNAME=$CSVNAME"
download_year "$APIKEY" $year $CSVNAME
done
done < "$APIKEYS_FILE"