Load latest checked transaction.

This commit is contained in:
Dominik Pantůček 2023-04-05 18:20:33 +02:00
parent 0dd621c30f
commit dc49fcc9a0

View file

@ -117,12 +117,26 @@
(bank-fio-parse (make-pathname dir (string-append acc ".csv"))))
accounts-list))
;; Reads single number from given file and returns it. If no number
;; is and/or the file does not exist, returns #f.
(define (get-latest-checked-id file-name)
(call/cc
(lambda (ret)
(with-exception-handler
(lambda (ex)
(ret #f))
(lambda ()
(with-input-from-file file-name
(lambda ()
(number->string (read-line)))))))))
;; If apikeys is not #f, loads the account numbers, loads bank
;; accounts and processes transactions.
(define (members-payments-process mb apikeys-file dir checked-fn)
(if apikeys-file
(let* ((acc-list (load-accounts-list apikeys-file))
(accounts (if acc-list (load-accounts acc-list dir) #f)))
(accounts (if acc-list (load-accounts acc-list dir) #f))
(last-checked (get-latest-checked-id checked-fn)))
(if accounts
(let ((mbp (foldl members-payments-process-bank
mb