Handle all bank loading gracefully.

This commit is contained in:
Dominik Pantůček 2023-04-04 22:34:41 +02:00
parent cc4cfccae1
commit e25a75ab27
5 changed files with 51 additions and 29 deletions

View file

@ -61,17 +61,20 @@
;; Loads Fio bank accound statement.
(define (bank-fio-parse fn)
(with-progress%
#t fn
(let* ((csv (csv-parse fn))
(head+body (csv-split-header csv))
(head (car head+body))
(body (cadr head+body))
(numrow (assoc "accountId" head))
(num (if numrow (cadr numrow) "ERROR"))
(bankrow (assoc "bankId" head))
(bank (if bankrow (cadr bankrow) "ERROR")))
(make-bank-account num bank
(map make-fio-transaction body)))))
(let ((csv (with-progress% #t fn (csv-parse fn))))
(if csv
(let* ((head+body (csv-split-header csv))
(head (car head+body))
(body (cadr head+body))
(numrow (assoc "accountId" head))
(num (if numrow (cadr numrow) "ERROR"))
(bankrow (assoc "bankId" head))
(bank (if bankrow (cadr bankrow) "ERROR")))
(make-bank-account num bank
(map make-fio-transaction body)))
(let ()
(print "Fio: cannot load account " fn)
#f
))))
)