Configurable bank directory.
This commit is contained in:
parent
f436e9e07c
commit
d6d47e91fc
2 changed files with 23 additions and 14 deletions
|
@ -61,6 +61,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
(define -fname- (make-parameter #f))
|
(define -fname- (make-parameter #f))
|
||||||
(define -run-tests?- (make-parameter #f))
|
(define -run-tests?- (make-parameter #f))
|
||||||
(define -web-dir- (make-parameter #f))
|
(define -web-dir- (make-parameter #f))
|
||||||
|
(define -bank-dir- (make-parameter #f))
|
||||||
|
|
||||||
;; Arguments parsing
|
;; Arguments parsing
|
||||||
(command-line
|
(command-line
|
||||||
|
@ -84,6 +85,8 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
(*table-border-style* (string->symbol style)))
|
(*table-border-style* (string->symbol style)))
|
||||||
(-apikey (fname) "File with Fio API keys"
|
(-apikey (fname) "File with Fio API keys"
|
||||||
(-apikeys-file- fname))
|
(-apikeys-file- fname))
|
||||||
|
(-bankdir (dir) "Where are bank CSV files"
|
||||||
|
(-bank-dir- dir))
|
||||||
""
|
""
|
||||||
"Query options:"
|
"Query options:"
|
||||||
(-mi (id) "Specify member by id" (-member-id- (string->number id)))
|
(-mi (id) "Specify member by id" (-member-id- (string->number id)))
|
||||||
|
@ -139,7 +142,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
(if (-action-)
|
(if (-action-)
|
||||||
(let ((mb (load-members (*members-directory*) #t)))
|
(let ((mb (load-members (*members-directory*) #t)))
|
||||||
(if (-needs-bank-)
|
(if (-needs-bank-)
|
||||||
(members-payments-process mb (-apikeys-file-))
|
(members-payments-process mb (-apikeys-file-) (-bank-dir-))
|
||||||
mb))
|
mb))
|
||||||
#f))
|
#f))
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,8 @@
|
||||||
(chicken io)
|
(chicken io)
|
||||||
(chicken irregex)
|
(chicken irregex)
|
||||||
(chicken sort)
|
(chicken sort)
|
||||||
|
(chicken process-context)
|
||||||
|
(chicken pathname)
|
||||||
bank-account
|
bank-account
|
||||||
member-record
|
member-record
|
||||||
members-base
|
members-base
|
||||||
|
@ -95,24 +97,28 @@
|
||||||
(read-lines
|
(read-lines
|
||||||
(open-input-file apikeys))))
|
(open-input-file apikeys))))
|
||||||
|
|
||||||
;; Loads all accounts - it expects .csv files in the current
|
;; Loads all accounts - it expects .csv files in given directory.
|
||||||
;; directory.
|
(define (load-accounts accounts-list dir)
|
||||||
(define (load-accounts accounts-list)
|
|
||||||
(map (lambda (acc)
|
(map (lambda (acc)
|
||||||
(bank-fio-parse (string-append acc ".csv")))
|
(bank-fio-parse (make-pathname dir (string-append acc ".csv"))))
|
||||||
accounts-list))
|
accounts-list))
|
||||||
|
|
||||||
;; If apikeys is not #f, loads the account numbers, loads bank
|
;; If apikeys is not #f, loads the account numbers, loads bank
|
||||||
;; accounts and processes transactions.
|
;; accounts and processes transactions.
|
||||||
(define (members-payments-process mb apikeys-file)
|
(define (members-payments-process mb apikeys-file . dirs)
|
||||||
|
(let ((dir (if (null? dirs)
|
||||||
|
(current-directory)
|
||||||
|
(or (car dirs)
|
||||||
|
(current-directory)))))
|
||||||
(if apikeys-file
|
(if apikeys-file
|
||||||
(let* ((accounts (load-accounts
|
(let* ((accounts (load-accounts
|
||||||
(load-accounts-list apikeys-file))))
|
(load-accounts-list apikeys-file)
|
||||||
|
dir)))
|
||||||
(map member-add-balance
|
(map member-add-balance
|
||||||
(foldl members-payments-process-bank
|
(foldl members-payments-process-bank
|
||||||
mb
|
mb
|
||||||
accounts)))
|
accounts)))
|
||||||
mb))
|
mb)))
|
||||||
|
|
||||||
;; Adds all balances - payments are converted to CZK in member-payments-total
|
;; Adds all balances - payments are converted to CZK in member-payments-total
|
||||||
(define (member-add-balance mr)
|
(define (member-add-balance mr)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue