Prepare fee lookups.
This commit is contained in:
parent
306cca2ae3
commit
9900764f57
3 changed files with 46 additions and 0 deletions
|
@ -219,6 +219,14 @@ Returns the total duration in months of the periods given in the list
|
||||||
```l```. Each period is represented as ```(list start-month
|
```l```. Each period is represented as ```(list start-month
|
||||||
end-month)```.
|
end-month)```.
|
||||||
|
|
||||||
|
(month-in-periods p [m (*current-month*)])
|
||||||
|
|
||||||
|
* ```p``` - a periods
|
||||||
|
* ```m``` - a valid month - defaults to ```(*current-month*)```
|
||||||
|
|
||||||
|
Returns ```#t``` if given month ```m``` lies within the period
|
||||||
|
```p```.
|
||||||
|
|
||||||
(month-in-periods? ps [m (*current-month*)])
|
(month-in-periods? ps [m (*current-month*)])
|
||||||
|
|
||||||
* ```ps``` - a list of periods
|
* ```ps``` - a list of periods
|
||||||
|
|
|
@ -51,6 +51,43 @@
|
||||||
members-base
|
members-base
|
||||||
period)
|
period)
|
||||||
|
|
||||||
|
;; Specifications of fees, regular and student must be in all
|
||||||
|
(define member-fees-lookup-source
|
||||||
|
'(((2010 1) #f 500 250)))
|
||||||
|
|
||||||
|
;; Convert into lookups - a list of (list period regular student)
|
||||||
|
(define member-fees-lookup-table
|
||||||
|
(map
|
||||||
|
(lambda (src)
|
||||||
|
(let* ((since0 (car src))
|
||||||
|
(since (apply make-month since0))
|
||||||
|
(before0 (cadr src))
|
||||||
|
(before (if before0
|
||||||
|
(apply make-month before0)
|
||||||
|
#f))
|
||||||
|
(regular (caddr src))
|
||||||
|
(student (cadddr src)))
|
||||||
|
(list (make-period since before)
|
||||||
|
regular
|
||||||
|
student)))
|
||||||
|
member-fees-lookup-source))
|
||||||
|
|
||||||
|
;; Returns a matching list of (list regular student)
|
||||||
|
(define (lookup-member-fees)
|
||||||
|
(let loop ((lst member-fees-lookup-table))
|
||||||
|
(if (null? lst)
|
||||||
|
#f
|
||||||
|
(if (month-in-period? (caar lst))
|
||||||
|
(cdar lst)
|
||||||
|
(loop (cdr lst))))))
|
||||||
|
|
||||||
|
;; Returns time-based fee for given type
|
||||||
|
(define (lookup-member-fee type)
|
||||||
|
(let ((fees (lookup-member-fees)))
|
||||||
|
(if (eq? type 'student)
|
||||||
|
(cadr fees)
|
||||||
|
(car fees))))
|
||||||
|
|
||||||
;; Returns a list of months where each month is a list containing:
|
;; Returns a list of months where each month is a list containing:
|
||||||
;; * month (from month module)
|
;; * month (from month module)
|
||||||
;; * flags - a list of symbols: student, suspended, destroyed
|
;; * flags - a list of symbols: student, suspended, destroyed
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
period-bcomment
|
period-bcomment
|
||||||
period-markers->periods
|
period-markers->periods
|
||||||
periods-duration
|
periods-duration
|
||||||
|
month-in-period?
|
||||||
month-in-periods?
|
month-in-periods?
|
||||||
periods->string
|
periods->string
|
||||||
periods-match
|
periods-match
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue