Iterate over account years.

This commit is contained in:
Dominik Pantůček 2023-05-25 23:04:41 +02:00
parent d9ebe5265c
commit cc34273c77

View file

@ -146,8 +146,9 @@ CYEAR=`date +%Y`
log "$0" ======== started ========
# Each line should contain account number and Fio API token as first
# two non-whitespace strings. The rest of each line is ignored. There
# must be no leading whitespace.
# two non-whitespace strings. Third token is the starting year for
# this account. The rest of each line is ignored. There must be no
# leading whitespace.
while read accnt ; do
# Extract account number, Fio token and starting year
ACCNO=${accnt%% *}
@ -159,14 +160,25 @@ while read accnt ; do
# Check starting year before attempting partial downloads
if [ -z "$YEAR" ] ; then
log "Missing start year for account $ACCNO"
else
# Log action
log "Processing account $ACCNO starting $YEAR"
continue
fi
if [ "$YEAR" -gt "$CYEAR" ] ; then
log "Start year for account $ACCNO in the future: $YEAR"
continue
fi
if [ "$YEAR" -lt "2010" ] ; then
log "Start year for account $ACCNO before Brmlab existence: $YEAR"
continue
fi
# Log action
for year in `seq $YEAR $CYEAR` ; do
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"
fi
#download_file "${APIURI}/periods/${APIKEY}/2015-01-01/2025-01-31/transactions.csv" "$CSVNAME"
done
done < "$APIKEYS_FILE"
# Mark