mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[budget] compact calc-periods
This commit is contained in:
@@ -595,24 +595,20 @@
|
||||
(define (calc-periods
|
||||
budget user-start user-end collapse-before? collapse-after? show-total?)
|
||||
(define (range start end)
|
||||
(define (int-range current end step lst)
|
||||
(if (>= current end)
|
||||
lst
|
||||
(int-range (+ current step) end step (cons current lst))))
|
||||
(reverse (int-range (if (number? start) start 0) end 1 '())))
|
||||
(iota (- end start) start))
|
||||
(let* ((num-periods (gnc-budget-get-num-periods budget))
|
||||
(range-start (if user-start user-start 0))
|
||||
(range-end (if user-end (+ 1 user-end) num-periods))
|
||||
(range-start (or user-start 0))
|
||||
(range-end (if user-end (1+ user-end) num-periods))
|
||||
(fold-before-start 0)
|
||||
(fold-before-end (if collapse-before? range-start 0))
|
||||
(fold-after-start (if collapse-after? range-end num-periods))
|
||||
(fold-after-end num-periods))
|
||||
(map (lambda (x) (if (and (list? x) (= 1 (length x))) (car x) x))
|
||||
(map (lambda (x) (if (and (list? x) (null? (cdr x))) (car x) x))
|
||||
(filter (lambda (x) (not (null? x)))
|
||||
(append (list (range fold-before-start fold-before-end))
|
||||
(range range-start range-end)
|
||||
(list (range fold-after-start fold-after-end))
|
||||
(if show-total? (list 'total) '()))))))
|
||||
(if show-total? '(total) '()))))))
|
||||
;; end of defines
|
||||
|
||||
(let* ((rownum 0)
|
||||
|
||||
Reference in New Issue
Block a user