mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[report-utilities.scm] gnc:budget-account-get-rolledup-net bugfix
This function accepts start-period and end-period, either/both can be #f which signifies budget start and end respectively. If end-period of #f, numperiods was then defined as (budget->num_periods + 1) which was incorrect. Bugfix and refactor to be cleaner.
This commit is contained in:
parent
b1176b4614
commit
ebfe0a4716
@ -940,14 +940,12 @@ query instead.")
|
||||
;;
|
||||
;; Returns a gnc-numeric value
|
||||
(define (gnc:budget-account-get-rolledup-net budget account start-period end-period)
|
||||
(let* ((start (or start-period 0))
|
||||
(end (or end-period (gnc-budget-get-num-periods budget)))
|
||||
(numperiods (- end start -1)))
|
||||
(apply +
|
||||
(map
|
||||
(lambda (period)
|
||||
(gnc:get-account-period-rolledup-budget-value budget account period))
|
||||
(iota numperiods start 1)))))
|
||||
(define end (or end-period (1- (gnc-budget-get-num-periods budget))))
|
||||
(let lp ((period (or start-period 0)) (sum 0))
|
||||
(cond
|
||||
((> period end) sum)
|
||||
(else (lp (1+ period) (+ sum (gnc:get-account-period-rolledup-budget-value
|
||||
budget account period)))))))
|
||||
|
||||
;; ***************************************************************************
|
||||
;; The following 3 functions belong together
|
||||
|
Loading…
Reference in New Issue
Block a user