Handle all bank loading gracefully.
This commit is contained in:
parent
cc4cfccae1
commit
e25a75ab27
5 changed files with 51 additions and 29 deletions
|
@ -42,6 +42,7 @@
|
|||
(chicken sort)
|
||||
(chicken process-context)
|
||||
(chicken pathname)
|
||||
(chicken condition)
|
||||
bank-account
|
||||
member-record
|
||||
members-base
|
||||
|
@ -49,7 +50,8 @@
|
|||
dictionary
|
||||
member-fees
|
||||
period
|
||||
configuration)
|
||||
configuration
|
||||
utils)
|
||||
|
||||
;; Exchange rates
|
||||
(define exchange-rates-lookup-table
|
||||
|
@ -103,9 +105,15 @@
|
|||
|
||||
;; Reads the payments
|
||||
(define (load-accounts-list apikeys)
|
||||
(map (compose car string-split)
|
||||
(read-lines
|
||||
(open-input-file apikeys))))
|
||||
(call/cc
|
||||
(lambda (ret)
|
||||
(with-exception-handler
|
||||
(lambda (ex)
|
||||
(ret #f))
|
||||
(lambda ()
|
||||
(map (compose car string-split)
|
||||
(read-lines
|
||||
(open-input-file apikeys))))))))
|
||||
|
||||
;; Loads all accounts - it expects .csv files in given directory.
|
||||
(define (load-accounts accounts-list dir)
|
||||
|
@ -117,13 +125,17 @@
|
|||
;; accounts and processes transactions.
|
||||
(define (members-payments-process mb apikeys-file dir)
|
||||
(if apikeys-file
|
||||
(let* ((accounts (load-accounts
|
||||
(load-accounts-list apikeys-file)
|
||||
dir)))
|
||||
(map member-sort-payments
|
||||
(foldl members-payments-process-bank
|
||||
mb
|
||||
accounts)))
|
||||
(let* ((acc-list (load-accounts-list apikeys-file))
|
||||
(accounts (if acc-list (load-accounts acc-list dir) #f)))
|
||||
(if accounts
|
||||
(map member-sort-payments
|
||||
(foldl members-payments-process-bank
|
||||
mb
|
||||
(filter identity
|
||||
accounts)))
|
||||
(let ()
|
||||
(print "Warning: no accounts loaded!")
|
||||
mb)))
|
||||
mb))
|
||||
|
||||
;; Adds all balances - payments are converted to CZK in member-payments-total
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue