[balance-forecast] adjust sx accumulator until report from-date

this commit will initialize the sx accumulator by adding all
instantiated sx amounts, from the earliest split posted-date among the
selected accounts, until the report start-date.
This commit is contained in:
Christopher Lam 2019-03-05 17:46:11 +08:00
parent a4d76177fb
commit 1ade6fe6b4

View File

@ -145,6 +145,21 @@
(balances #f)
)
;; initialize the SX balance accumulator with the instantiated SX
;; amounts starting from the earliest split date in the list of
;; accounts up to the report start date.
(let* ((account-dates (map (compose xaccTransGetDate xaccSplitGetParent car)
(filter pair? (map xaccAccountGetSplitList accounts))))
(earliest (and (pair? account-dates) (apply min account-dates)))
(sx-hash (if earliest
(gnc-sx-all-instantiate-cashflow-all earliest from-date)
(make-hash-table))))
(for-each
(lambda (account)
(accum 'add (xaccAccountGetCommodity account)
(hash-ref sx-hash (gncAccountGetGUID account) 0)))
accounts))
; Calculate balances
(set! balances
(map (lambda (date) (let* (