From cc34273c772778db932c521a935969e36847ef05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Thu, 25 May 2023 23:04:41 +0200 Subject: [PATCH] Iterate over account years. --- fetch_fio.sh | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/fetch_fio.sh b/fetch_fio.sh index 4d7f2b6..f29560e 100644 --- a/fetch_fio.sh +++ b/fetch_fio.sh @@ -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