Iterate over account years.
This commit is contained in:
parent
d9ebe5265c
commit
cc34273c77
1 changed files with 20 additions and 8 deletions
28
fetch_fio.sh
28
fetch_fio.sh
|
@ -146,8 +146,9 @@ CYEAR=`date +%Y`
|
||||||
log "$0" ======== started ========
|
log "$0" ======== started ========
|
||||||
|
|
||||||
# Each line should contain account number and Fio API token as first
|
# Each line should contain account number and Fio API token as first
|
||||||
# two non-whitespace strings. The rest of each line is ignored. There
|
# two non-whitespace strings. Third token is the starting year for
|
||||||
# must be no leading whitespace.
|
# this account. The rest of each line is ignored. There must be no
|
||||||
|
# leading whitespace.
|
||||||
while read accnt ; do
|
while read accnt ; do
|
||||||
# Extract account number, Fio token and starting year
|
# Extract account number, Fio token and starting year
|
||||||
ACCNO=${accnt%% *}
|
ACCNO=${accnt%% *}
|
||||||
|
@ -159,14 +160,25 @@ while read accnt ; do
|
||||||
# Check starting year before attempting partial downloads
|
# Check starting year before attempting partial downloads
|
||||||
if [ -z "$YEAR" ] ; then
|
if [ -z "$YEAR" ] ; then
|
||||||
log "Missing start year for account $ACCNO"
|
log "Missing start year for account $ACCNO"
|
||||||
else
|
continue
|
||||||
# Log action
|
fi
|
||||||
log "Processing account $ACCNO starting $YEAR"
|
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
|
# Fetch CSV from bank
|
||||||
CSVNAME="$BANK_DIR/$ACCNO.csv"
|
CSVNAME="$BANK_DIR/$ACCNO.csv"
|
||||||
download_file "${APIURI}/periods/${APIKEY}/2015-01-01/2025-01-31/transactions.csv" "$CSVNAME"
|
#download_file "${APIURI}/periods/${APIKEY}/2015-01-01/2025-01-31/transactions.csv" "$CSVNAME"
|
||||||
fi
|
done
|
||||||
done < "$APIKEYS_FILE"
|
done < "$APIKEYS_FILE"
|
||||||
|
|
||||||
# Mark
|
# Mark
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue