Fix handling calendar for nonsensical data.

This commit is contained in:
Dominik Pantůček 2023-03-28 14:52:11 +02:00
parent bfe763c599
commit 7a0db40062

View file

@ -106,24 +106,26 @@
;; contain the year in the first cell and 12 cells for months after ;; contain the year in the first cell and 12 cells for months after
;; it. ;; it.
(define (member-calendar->years-table mc) (define (member-calendar->years-table mc)
(let* ((fm (member-calendar-first-month mc)) (if (null? mc)
(lm (member-calendar-last-month mc)) '()
(fy (month-year fm)) (let* ((fm (member-calendar-first-month mc))
(ly (month-year lm))) (lm (member-calendar-last-month mc))
(let loop ((y fy) (fy (month-year fm))
(rows '())) (ly (month-year lm)))
(if (> y ly) (let loop ((y fy)
(reverse rows) (rows '()))
(loop (add1 y) (if (> y ly)
(cons (let mloop ((m 1) (reverse rows)
(row (list y))) (loop (add1 y)
(if (> m 12) (cons (let mloop ((m 1)
(reverse row) (row (list y)))
(mloop (add1 m) (if (> m 12)
(cons (member-calendar-entry->string (reverse row)
(member-calendar-query mc (make-month y m))) (mloop (add1 m)
row)))) (cons (member-calendar-entry->string
rows)))))) (member-calendar-query mc (make-month y m)))
row))))
rows)))))))
;; Converts the whole calendar into a list of amounts (fees) ;; Converts the whole calendar into a list of amounts (fees)
(define (member-calendar->fees mc) (define (member-calendar->fees mc)