Two-pass processing.
This commit is contained in:
parent
f2e47b9ad3
commit
8c2f848c73
1 changed files with 29 additions and 30 deletions
|
@ -335,20 +335,29 @@
|
||||||
|
|
||||||
;; Prints summary table of all fees and credits for all members
|
;; Prints summary table of all fees and credits for all members
|
||||||
(define (print-members-fees-table MB)
|
(define (print-members-fees-table MB)
|
||||||
(let ((balances (map member-balance MB))
|
(let ((balances (map member-balance (sort MB member<?)))
|
||||||
(members ;; Pass 1
|
(members ;; Pass 1
|
||||||
(map
|
(map
|
||||||
(lambda (mr)
|
(lambda (mr)
|
||||||
(list (member-nick mr)
|
(let* ((balance (member-balance mr))
|
||||||
(if (member-suspended? mr)
|
(fees (dict-ref balance 'fees))
|
||||||
"suspended"
|
(credit (dict-ref balance 'credit))
|
||||||
(if (member-student? mr)
|
(payment (dict-ref balance 'payment))
|
||||||
"student"
|
(total (- (+ credit payment) fees)))
|
||||||
(if (member-destroyed? mr)
|
(list (member-nick mr)
|
||||||
"destroyed"
|
(if (member-suspended? mr)
|
||||||
"active")))
|
"suspended"
|
||||||
;; TODO: move let* below here and add fees, credit, payment and total
|
(if (member-student? mr)
|
||||||
)))))
|
"student"
|
||||||
|
(if (member-destroyed? mr)
|
||||||
|
"destroyed"
|
||||||
|
"active")))
|
||||||
|
fees
|
||||||
|
credit
|
||||||
|
payment
|
||||||
|
total
|
||||||
|
)))
|
||||||
|
MB)))
|
||||||
(print
|
(print
|
||||||
(table->string
|
(table->string
|
||||||
(cons
|
(cons
|
||||||
|
@ -359,24 +368,14 @@
|
||||||
(ansi-string #:bgblue #:brightyellow #:bold "Payments")
|
(ansi-string #:bgblue #:brightyellow #:bold "Payments")
|
||||||
(ansi-string #:bgblue #:brightyellow #:bold "Balance"))
|
(ansi-string #:bgblue #:brightyellow #:bold "Balance"))
|
||||||
(append
|
(append
|
||||||
(map
|
(map ;; Pass 2
|
||||||
(lambda (mr)
|
(lambda (member)
|
||||||
(let* ((balance (member-balance mr))
|
(let ((total (list-ref member 5)))
|
||||||
(fees (dict-ref balance 'fees))
|
(list (list-ref member 0)
|
||||||
(credit (dict-ref balance 'credit))
|
(list-ref member 1)
|
||||||
(payment (dict-ref balance 'payment))
|
(sprintf "\t~A" (list-ref member 2))
|
||||||
(total (- (+ credit payment) fees)))
|
(sprintf "\t~A" (list-ref member 3))
|
||||||
(list (member-nick mr)
|
(sprintf "\t~A" (list-ref member 4))
|
||||||
(if (member-suspended? mr)
|
|
||||||
"suspended"
|
|
||||||
(if (member-student? mr)
|
|
||||||
"student"
|
|
||||||
(if (member-destroyed? mr)
|
|
||||||
"destroyed"
|
|
||||||
"active")))
|
|
||||||
(sprintf "\t~A" fees)
|
|
||||||
(sprintf "\t~A" credit)
|
|
||||||
(sprintf "\t~A" payment)
|
|
||||||
(sprintf "\t~A~A~A"
|
(sprintf "\t~A~A~A"
|
||||||
(if (< total -500)
|
(if (< total -500)
|
||||||
a:error
|
a:error
|
||||||
|
@ -386,7 +385,7 @@
|
||||||
(exact->inexact total)
|
(exact->inexact total)
|
||||||
a:default)
|
a:default)
|
||||||
)))
|
)))
|
||||||
(sort MB member<?))
|
members)
|
||||||
(let* ((fees (foldl + 0 (map (lambda (b) (dict-ref b 'fees)) balances)))
|
(let* ((fees (foldl + 0 (map (lambda (b) (dict-ref b 'fees)) balances)))
|
||||||
(credit (foldl + 0 (map (lambda (b) (dict-ref b 'credit)) balances)))
|
(credit (foldl + 0 (map (lambda (b) (dict-ref b 'credit)) balances)))
|
||||||
(payment (foldl + 0 (map (lambda (b) (dict-ref b 'payment)) balances)))
|
(payment (foldl + 0 (map (lambda (b) (dict-ref b 'payment)) balances)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue