Configurable bank directory.
This commit is contained in:
parent
f436e9e07c
commit
d6d47e91fc
2 changed files with 23 additions and 14 deletions
|
@ -38,6 +38,8 @@
|
|||
(chicken io)
|
||||
(chicken irregex)
|
||||
(chicken sort)
|
||||
(chicken process-context)
|
||||
(chicken pathname)
|
||||
bank-account
|
||||
member-record
|
||||
members-base
|
||||
|
@ -95,24 +97,28 @@
|
|||
(read-lines
|
||||
(open-input-file apikeys))))
|
||||
|
||||
;; Loads all accounts - it expects .csv files in the current
|
||||
;; directory.
|
||||
(define (load-accounts accounts-list)
|
||||
;; Loads all accounts - it expects .csv files in given directory.
|
||||
(define (load-accounts accounts-list dir)
|
||||
(map (lambda (acc)
|
||||
(bank-fio-parse (string-append acc ".csv")))
|
||||
(bank-fio-parse (make-pathname dir (string-append acc ".csv"))))
|
||||
accounts-list))
|
||||
|
||||
;; If apikeys is not #f, loads the account numbers, loads bank
|
||||
;; accounts and processes transactions.
|
||||
(define (members-payments-process mb apikeys-file)
|
||||
(if apikeys-file
|
||||
(let* ((accounts (load-accounts
|
||||
(load-accounts-list apikeys-file))))
|
||||
(map member-add-balance
|
||||
(foldl members-payments-process-bank
|
||||
mb
|
||||
accounts)))
|
||||
mb))
|
||||
(define (members-payments-process mb apikeys-file . dirs)
|
||||
(let ((dir (if (null? dirs)
|
||||
(current-directory)
|
||||
(or (car dirs)
|
||||
(current-directory)))))
|
||||
(if apikeys-file
|
||||
(let* ((accounts (load-accounts
|
||||
(load-accounts-list apikeys-file)
|
||||
dir)))
|
||||
(map member-add-balance
|
||||
(foldl members-payments-process-bank
|
||||
mb
|
||||
accounts)))
|
||||
mb)))
|
||||
|
||||
;; Adds all balances - payments are converted to CZK in member-payments-total
|
||||
(define (member-add-balance mr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue