Prepare for notifications.

This commit is contained in:
Dominik Pantůček 2023-04-08 21:53:48 +02:00
parent ac3dce41a6
commit 1551ea15e6
3 changed files with 27 additions and 5 deletions

View file

@ -32,7 +32,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
month month
period period
command-line command-line
utils util-list
ansi ansi
members-base members-base
primes primes
@ -70,6 +70,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
(define -jendasap-checked- (make-parameter "checked.ntlm")) (define -jendasap-checked- (make-parameter "checked.ntlm"))
(define -ml-all- (make-parameter #f)) (define -ml-all- (make-parameter #f))
(define -show-destroyed- (make-parameter #f)) (define -show-destroyed- (make-parameter #f))
(define -notify-months- (make-parameter 1))
;; Arguments parsing ;; Arguments parsing
(command-line (command-line
@ -144,6 +145,12 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
(-action- 'mlcheck)) (-action- 'mlcheck))
(-mlsync () "Synchronize internal ML" (-mlsync () "Synchronize internal ML"
(-action- 'mlsync)) (-action- 'mlsync))
(-notify () "Members with debt for more than 1 month"
(-notify-months- 1)
(-action- 'notify))
(-notify3 () "Members with debt for more than 3 month"
(-notify-months- 3)
(-action- 'notify))
) )
;; Run tests ;; Run tests
@ -152,7 +159,7 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
(dictionary-tests!) (dictionary-tests!)
(month-tests!) (month-tests!)
(period-tests!) (period-tests!)
(utils-tests!) (util-list-tests!)
(ansi-tests!) (ansi-tests!)
(command-line-tests!) (command-line-tests!)
(members-dir-tests!) (members-dir-tests!)
@ -297,6 +304,8 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
(print " Missing: " missing)) (print " Missing: " missing))
(when (not (null? surplus)) (when (not (null? surplus))
(print " Outsiders: " surplus)))))) (print " Outsiders: " surplus))))))
((notify)
(print "Notify" (-notify-months-)))
(else (else
(print "Nothing to do.")) (print "Nothing to do."))

View file

@ -32,6 +32,7 @@
members-payments-process members-payments-process
member-balance member-balance
member-total-balance member-total-balance
members-to-notify
) )
(import scheme (import scheme
@ -211,5 +212,17 @@
(else 0)))) (else 0))))
(member-payments mr)))) (member-payments mr))))
;; Return members to notify because of late payments for more than
;; given number of months
(define (members-to-notify mb months)
(filter-members-by-predicate
mb
(lambda (mr)
(let ((total (member-total-balance mr))
(fee (lookup-member-fee (if (member-student? mr)
'student
'regular))))
(and (< total 0)
(< total (- (* months fee))))))))
) )

View file

@ -29,7 +29,7 @@
util-list util-list
( (
filter filter
utils-tests! util-list-tests!
) )
(import scheme (import scheme
@ -51,9 +51,9 @@
res))))) res)))))
;; Performs utils module self-tests. ;; Performs utils module self-tests.
(define (utils-tests!) (define (util-list-tests!)
(run-tests (run-tests
utils util-list
(test-equal? filter (filter odd? '(1 2 3 4)) '(1 3)) (test-equal? filter (filter odd? '(1 2 3 4)) '(1 3))
(test-equal? filter (filter odd? '(2 4)) '()) (test-equal? filter (filter odd? '(2 4)) '())
)) ))