From 7a0db40062b9cfc2fdbcd739942c58adece04247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Pant=C5=AF=C4=8Dek?= Date: Tue, 28 Mar 2023 14:52:11 +0200 Subject: [PATCH] Fix handling calendar for nonsensical data. --- member-fees.scm | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/member-fees.scm b/member-fees.scm index 8f188ad..4b13126 100644 --- a/member-fees.scm +++ b/member-fees.scm @@ -106,24 +106,26 @@ ;; contain the year in the first cell and 12 cells for months after ;; it. (define (member-calendar->years-table mc) - (let* ((fm (member-calendar-first-month mc)) - (lm (member-calendar-last-month mc)) - (fy (month-year fm)) - (ly (month-year lm))) - (let loop ((y fy) - (rows '())) - (if (> y ly) - (reverse rows) - (loop (add1 y) - (cons (let mloop ((m 1) - (row (list y))) - (if (> m 12) - (reverse row) - (mloop (add1 m) - (cons (member-calendar-entry->string - (member-calendar-query mc (make-month y m))) - row)))) - rows)))))) + (if (null? mc) + '() + (let* ((fm (member-calendar-first-month mc)) + (lm (member-calendar-last-month mc)) + (fy (month-year fm)) + (ly (month-year lm))) + (let loop ((y fy) + (rows '())) + (if (> y ly) + (reverse rows) + (loop (add1 y) + (cons (let mloop ((m 1) + (row (list y))) + (if (> m 12) + (reverse row) + (mloop (add1 m) + (cons (member-calendar-entry->string + (member-calendar-query mc (make-month y m))) + row)))) + rows))))))) ;; Converts the whole calendar into a list of amounts (fees) (define (member-calendar->fees mc)