gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Thu Mar 14 04:32:57 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/12a46e62 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/29c0e192 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/784b34a0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6e76cb3d (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1ade6fe6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a4d76177 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d0deda92 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0cf973c1 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/55583829 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b6a70819 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/274897fb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0e60c775 (commit)
	from  https://github.com/Gnucash/gnucash/commit/9a0aaedc (commit)



commit 12a46e62de250c24501d310151c7866757e545ee
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Mar 11 22:45:01 2019 +0800

    [balance-forecast] use gnc:case-exchange-time-fn
    
    The gnc:case-exchange-fn seems to be designed for single-date reports,
    whereas gnc:case-exchange-time-fn for multi-date reports. It may be
    faster to have a single exchange-fn definition.
    
    The main reason for this change is to harmonize - all multidate charts
    are using case-exchange-time-fn.

diff --git a/gnucash/report/standard-reports/balance-forecast.scm b/gnucash/report/standard-reports/balance-forecast.scm
index e2739fc56..49f65da2b 100644
--- a/gnucash/report/standard-reports/balance-forecast.scm
+++ b/gnucash/report/standard-reports/balance-forecast.scm
@@ -163,6 +163,11 @@ date point, a projected minimum balance including scheduled transactions."))
           (intervals (gnc:make-date-interval-list
             from-date to-date (gnc:deltasym-to-delta interval)))
           (accum (gnc:make-commodity-collector))
+          (exchange-fn (gnc:case-exchange-time-fn
+                        price currency
+                        (delete-duplicates! (map xaccAccountGetCommodity accounts)
+                                            gnc-commodity-equiv)
+                        to-date #f #f))
           (accounts-balancelist
            (map
             (lambda (acc)
@@ -206,7 +211,6 @@ date point, a projected minimum balance including scheduled transactions."))
                 (let* ((start-date (car date))
                        (end-date (cadr date))
                        (balance (gnc:make-commodity-collector))
-                       (exchange-fn (gnc:case-exchange-fn price currency end-date))
                        (sx-value (gnc-sx-all-instantiate-cashflow-all
                                   start-date end-date)))
                   (for-each
@@ -218,7 +222,10 @@ date point, a projected minimum balance including scheduled transactions."))
                    accounts accounts-balance)
                   (balance 'merge accum #f)
                   (gnc:gnc-monetary-amount
-                   (gnc:sum-collector-commodity balance currency exchange-fn))))
+                   (gnc:sum-collector-commodity
+                    balance currency
+                    (lambda (monetary target-curr)
+                      (exchange-fn monetary target-curr end-date))))))
               intervals (apply zip accounts-balancelist))))
 
         ;; Minimum line

commit 29c0e192830307eb7be5039b1924d0407e215400
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun Mar 10 13:38:51 2019 +0800

    [balance-forecast] reuse i18n strings
    
    this commit will modify to reuse some strings which are already
    translated, and also add help strings for the various options.

diff --git a/gnucash/report/standard-reports/balance-forecast.scm b/gnucash/report/standard-reports/balance-forecast.scm
index 9236a95cb..e2739fc56 100644
--- a/gnucash/report/standard-reports/balance-forecast.scm
+++ b/gnucash/report/standard-reports/balance-forecast.scm
@@ -33,20 +33,40 @@
 
 ; Name definitions
 (define report-title         (N_ "Balance Forecast"))
+
 (define optname-accounts     (N_ "Accounts"))
-(define optname-from-date    (N_ "Simulate from"))
-(define optname-to-date      (N_ "Simulate until"))
+(define opthelp-accounts     (_ "Report on these accounts."))
+
+(define optname-from-date    (N_ "Start Date"))
+(define optname-to-date      (N_ "End Date"))
 (define optname-interval     (N_ "Interval"))
-(define optname-currency     (N_ "Report currency"))
-(define optname-price        (N_ "Price source"))
-(define optname-plot-width   (N_ "Plot width"))
-(define optname-plot-height  (N_ "Plot height"))
-(define optname-show-markers (N_ "Show markers"))
+
+(define optname-currency     (N_ "Report's currency"))
+(define optname-price        (N_ "Price Source"))
+
+(define optname-plot-width   (N_ "Plot Width"))
+(define optname-plot-height  (N_ "Plot Height"))
+(define optname-show-markers (N_ "Data markers?"))
+(define opthelp-show-markers (_ "Display a mark for each data point."))
+
 (define optname-show-reserve (N_ "Show reserve line"))
+(define opthelp-show-reserve (_ "Show reserve line"))
+
 (define optname-reserve      (N_ "Reserve amount"))
+(define opthelp-reserve      (_ "The reserve amount is set to a \
+minimum balance desired"))
+
 (define optname-show-target  (N_ "Show target line"))
+(define opthelp-show-target  (_ "Show target line"))
+
 (define optname-target       (N_ "Target amount above reserve"))
+(define opthelp-target       (_ "The target is used to plan for \
+a future large purchase, which will be added as a line above the \
+reserve amount."))
+
 (define optname-show-minimum (N_ "Show future minimum"))
+(define opthelp-show-minimum (_ "The future minimum will add, for each \
+date point, a projected minimum balance including scheduled transactions."))
 
 ; Options generator
 (define (options-generator)
@@ -54,7 +74,7 @@
     ; Account selector
     (gnc:register-option options
       (gnc:make-account-list-option
-        gnc:pagename-accounts optname-accounts "a" optname-accounts
+        gnc:pagename-accounts optname-accounts "a" opthelp-accounts
         (lambda ()
           (gnc:filter-accountlist-type
             (list ACCT-TYPE-BANK ACCT-TYPE-CASH)
@@ -81,28 +101,28 @@
       (cons 'percent 100.0) (cons 'percent 100.0))
     ; Markers
     (gnc:register-option options (gnc:make-simple-boolean-option
-      gnc:pagename-display optname-show-markers "b" "" #f))
+      gnc:pagename-display optname-show-markers "b" opthelp-show-markers #f))
     ; Reserve line
     (gnc:register-option options (gnc:make-complex-boolean-option
-      gnc:pagename-display optname-show-reserve "c" "" #f #f
+      gnc:pagename-display optname-show-reserve "c" opthelp-show-reserve #f #f
       (lambda (x)
         (gnc-option-db-set-option-selectable-by-name
          options gnc:pagename-display optname-reserve x))))
     (gnc:register-option options (gnc:make-number-range-option
-      gnc:pagename-display optname-reserve "d" optname-reserve
+      gnc:pagename-display optname-reserve "d" opthelp-reserve
       0 0 10E9 2 0.01))
     ; Purchasing power target
     (gnc:register-option options (gnc:make-complex-boolean-option
-      gnc:pagename-display optname-show-target "e" "" #f #f
+      gnc:pagename-display optname-show-target "e" opthelp-show-target #f #f
       (lambda (x)
         (gnc-option-db-set-option-selectable-by-name
          options gnc:pagename-display optname-target x))))
     (gnc:register-option options (gnc:make-number-range-option
-      gnc:pagename-display optname-target "f" optname-target
+      gnc:pagename-display optname-target "f" opthelp-target
       0 0 10E9 2 0.01))
     ; Future minimum
     (gnc:register-option options (gnc:make-simple-boolean-option
-      gnc:pagename-display optname-show-minimum "g" "" #f))
+      gnc:pagename-display optname-show-minimum "g" opthelp-show-minimum #f))
     (gnc:options-set-default-section options gnc:pagename-general)
     options)
 )

commit 784b34a0488535d9f94ce13573dbf897a8686f51
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Wed Mar 6 20:29:22 2019 +0800

    [balance-forecast] add null-account and zero-amounts handling

diff --git a/gnucash/report/standard-reports/balance-forecast.scm b/gnucash/report/standard-reports/balance-forecast.scm
index 92c03a34f..9236a95cb 100644
--- a/gnucash/report/standard-reports/balance-forecast.scm
+++ b/gnucash/report/standard-reports/balance-forecast.scm
@@ -147,97 +147,111 @@
            (map
             (lambda (acc)
               (gnc:account-get-balances-at-dates acc (map cadr intervals)))
-            accounts))
-          (accounts-balancelist-transposed
-           (if (null? accounts) '() (apply zip accounts-balancelist)))
-          (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 accounts-balance) (let* (
-          (start-date (car date))
-          (end-date (cadr date))
-          (balance (gnc:make-commodity-collector))
-          (exchange-fn (gnc:case-exchange-fn price currency end-date))
-          (sx-value (gnc-sx-all-instantiate-cashflow-all start-date end-date))
-         )
-        (for-each (lambda (account account-balance)
-          (accum 'add (xaccAccountGetCommodity account)
-            (hash-ref sx-value (gncAccountGetGUID account) 0))
-          (balance 'add (gnc:gnc-monetary-commodity account-balance)
-            (gnc:gnc-monetary-amount account-balance))
-        ) accounts accounts-balance)
-        (balance 'merge accum #f)
-        (gnc:gnc-monetary-amount
-          (gnc:sum-collector-commodity balance currency exchange-fn))
-      )) intervals accounts-balancelist-transposed))
-
-    ; Minimum line
-    (when show-minimum
-      (set! series (cons (list (_ "Minimum") "#0AA") series))
-      (gnc:html-linechart-append-column!
-       chart (let loop ((balances balances) (result '()))
-               (if (null? balances) (reverse! result)
-                   (loop (cdr balances) (cons (apply min balances) result))))))
-
-    ; Balance line (do this here so it draws over the minimum line)
-    (set! series (cons (list (_ "Balance") "#0A0") series))
-    (gnc:html-linechart-append-column! chart balances)
-
-    ; Target line
-    (when show-target
-      (set! series (cons (list (_ "Target") "#FF0") series))
-      (gnc:html-linechart-append-column! chart
-        (make-list (length intervals) (+ reserve target))))
+            accounts)))
 
-    ; Reserve line
-    (when show-reserve
-      (set! series (cons (list (_ "Reserve") "#F00") series))
-      (gnc:html-linechart-append-column! chart
-        (make-list (length intervals) reserve)))
-
-    ; Set the chart titles
-    (gnc:html-linechart-set-title! chart report-title)
-    (gnc:html-linechart-set-subtitle! chart (format #f (_ "~a to ~a")
-      (qof-print-date from-date) (qof-print-date to-date)))
-    ; Set the chart size
-    (gnc:html-linechart-set-width! chart plot-width)
-    (gnc:html-linechart-set-height! chart plot-height)
-    ; Set the axis labels
-    (gnc:html-linechart-set-y-axis-label! chart
-      (gnc-commodity-get-mnemonic currency))
-    ; Set line markers
-    (gnc:html-linechart-set-markers?! chart show-markers)
-    ; Set series labels
-    (let ((old-fmt (qof-date-format-get)))
-      (qof-date-format-set QOF-DATE-FORMAT-ISO)
-      (gnc:html-linechart-set-row-labels! chart
-        (map qof-print-date (map cadr intervals)))
-      (qof-date-format-set old-fmt))
-    (gnc:html-linechart-set-col-labels! chart (map car (reverse series)))
-    ; Assign line colors
-    (gnc:html-linechart-set-col-colors! chart (map cadr (reverse series)))
-
-    ; We're done!
-    (gnc:html-document-add-object! document chart)
-    (gnc:report-finished)
-  document))
+    (cond
+     ((null? accounts)
+      (gnc:html-document-add-object!
+       document
+       (gnc:html-make-no-account-warning
+        report-title (gnc:report-id report-obj))))
+
+     ((every zero? (map gnc:gnc-monetary-amount (apply append accounts-balancelist)))
+      (gnc:html-document-add-object!
+       document
+       (gnc:html-make-empty-data-warning
+        report-title (gnc:report-id report-obj))))
+
+     (else
+      ;; 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* ((accounts-dates (map (compose xaccTransGetDate xaccSplitGetParent car)
+                                  (filter pair?
+                                          (map xaccAccountGetSplitList accounts))))
+             (earliest (and (pair? accounts-dates) (apply min accounts-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
+      (let ((balances
+             (map
+              (lambda (date accounts-balance)
+                (let* ((start-date (car date))
+                       (end-date (cadr date))
+                       (balance (gnc:make-commodity-collector))
+                       (exchange-fn (gnc:case-exchange-fn price currency end-date))
+                       (sx-value (gnc-sx-all-instantiate-cashflow-all
+                                  start-date end-date)))
+                  (for-each
+                   (lambda (account account-balance)
+                     (accum 'add (xaccAccountGetCommodity account)
+                            (hash-ref sx-value (gncAccountGetGUID account) 0))
+                     (balance 'add (gnc:gnc-monetary-commodity account-balance)
+                              (gnc:gnc-monetary-amount account-balance)))
+                   accounts accounts-balance)
+                  (balance 'merge accum #f)
+                  (gnc:gnc-monetary-amount
+                   (gnc:sum-collector-commodity balance currency exchange-fn))))
+              intervals (apply zip accounts-balancelist))))
+
+        ;; Minimum line
+        (when show-minimum
+          (set! series (cons (list (_ "Minimum") "#0AA") series))
+          (gnc:html-linechart-append-column!
+           chart (let loop ((balances balances) (result '()))
+                   (if (null? balances) (reverse! result)
+                       (loop (cdr balances) (cons (apply min balances) result))))))
+
+        ;; Balance line (do this here so it draws over the minimum line)
+        (set! series (cons (list (_ "Balance") "#0A0") series))
+        (gnc:html-linechart-append-column! chart balances)
+
+        ;; Target line
+        (when show-target
+          (set! series (cons (list (_ "Target") "#FF0") series))
+          (gnc:html-linechart-append-column!
+           chart (make-list (length intervals) (+ reserve target))))
+
+        ;; Reserve line
+        (when show-reserve
+          (set! series (cons (list (_ "Reserve") "#F00") series))
+          (gnc:html-linechart-append-column!
+           chart (make-list (length intervals) reserve)))
+
+        ;; Set the chart titles
+        (gnc:html-linechart-set-title! chart report-title)
+        (gnc:html-linechart-set-subtitle!
+         chart (format #f (_ "~a to ~a")
+                       (qof-print-date from-date) (qof-print-date to-date)))
+        ;; Set the chart size
+        (gnc:html-linechart-set-width! chart plot-width)
+        (gnc:html-linechart-set-height! chart plot-height)
+        ;; Set the axis labels
+        (gnc:html-linechart-set-y-axis-label!
+         chart (gnc-commodity-get-mnemonic currency))
+        ;; Set line markers
+        (gnc:html-linechart-set-markers?! chart show-markers)
+        ;; Set series labels
+        (let ((old-fmt (qof-date-format-get)))
+          (qof-date-format-set QOF-DATE-FORMAT-ISO)
+          (gnc:html-linechart-set-row-labels!
+           chart (map qof-print-date (map cadr intervals)))
+          (qof-date-format-set old-fmt))
+        (gnc:html-linechart-set-col-labels! chart (map car (reverse series)))
+        ;; Assign line colors
+        (gnc:html-linechart-set-col-colors! chart (map cadr (reverse series)))
+
+        ;; We're done!
+        (gnc:html-document-add-object! document chart)
+        (gnc:report-finished))))
+    document))
 
 (gnc:define-report
   'version 1

commit 6e76cb3d3be7efab0ce0ec29c3b0fdd502db3e86
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Mar 5 20:40:59 2019 +0800

    [balance-forecast] refactor to avoid xaccAccountGetBalanceAsOfDate
    
    previous will call gnc:account-get-comm-balance-at-date which calls
    xaccAccountGetBalanceAsOfDate for every account at every date
    point. The xaccAccountGetBalanceAsOfDate is an expensive function
    because it scans the account's whole splitlist from the start every
    time. use gnc:account-get-balances-at-dates instead which scans an
    account only once to generate a balancelist.
    
    this should be a much faster chart.

diff --git a/gnucash/report/standard-reports/balance-forecast.scm b/gnucash/report/standard-reports/balance-forecast.scm
index b3b759c7e..92c03a34f 100644
--- a/gnucash/report/standard-reports/balance-forecast.scm
+++ b/gnucash/report/standard-reports/balance-forecast.scm
@@ -27,6 +27,7 @@
 
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
+(use-modules (srfi srfi-1))
 
 (gnc:module-load "gnucash/report/report-system" 0)
 
@@ -142,6 +143,13 @@
           (intervals (gnc:make-date-interval-list
             from-date to-date (gnc:deltasym-to-delta interval)))
           (accum (gnc:make-commodity-collector))
+          (accounts-balancelist
+           (map
+            (lambda (acc)
+              (gnc:account-get-balances-at-dates acc (map cadr intervals)))
+            accounts))
+          (accounts-balancelist-transposed
+           (if (null? accounts) '() (apply zip accounts-balancelist)))
           (balances #f)
         )
 
@@ -162,23 +170,23 @@
 
     ; Calculate balances
     (set! balances
-      (map (lambda (date) (let* (
+      (map (lambda (date accounts-balance) (let* (
           (start-date (car date))
           (end-date (cadr date))
           (balance (gnc:make-commodity-collector))
           (exchange-fn (gnc:case-exchange-fn price currency end-date))
           (sx-value (gnc-sx-all-instantiate-cashflow-all start-date end-date))
          )
-        (for-each (lambda (account)
+        (for-each (lambda (account account-balance)
           (accum 'add (xaccAccountGetCommodity account)
             (hash-ref sx-value (gncAccountGetGUID account) 0))
-          (balance 'merge
-            (gnc:account-get-comm-balance-at-date account end-date #f) #f)
-        ) accounts)
+          (balance 'add (gnc:gnc-monetary-commodity account-balance)
+            (gnc:gnc-monetary-amount account-balance))
+        ) accounts accounts-balance)
         (balance 'merge accum #f)
         (gnc:gnc-monetary-amount
           (gnc:sum-collector-commodity balance currency exchange-fn))
-      )) intervals))
+      )) intervals accounts-balancelist-transposed))
 
     ; Minimum line
     (when show-minimum

commit 1ade6fe6b44ca59d472d65bf200d9db2953c92d4
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Mar 5 17:46:11 2019 +0800

    [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.

diff --git a/gnucash/report/standard-reports/balance-forecast.scm b/gnucash/report/standard-reports/balance-forecast.scm
index f0be356e2..b3b759c7e 100644
--- a/gnucash/report/standard-reports/balance-forecast.scm
+++ b/gnucash/report/standard-reports/balance-forecast.scm
@@ -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* (

commit a4d76177fbf33b5458ceacf4c74d920603be7880
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Mar 5 13:08:25 2019 +0800

    [balance-forecast] modify boolean option to effect number box
    
    1. convert simple boolean to complex boolean to toggle amounts
    2. convert list processing functions to scheme conventions

diff --git a/gnucash/report/standard-reports/balance-forecast.scm b/gnucash/report/standard-reports/balance-forecast.scm
index 4c0ef5935..f0be356e2 100644
--- a/gnucash/report/standard-reports/balance-forecast.scm
+++ b/gnucash/report/standard-reports/balance-forecast.scm
@@ -82,21 +82,28 @@
     (gnc:register-option options (gnc:make-simple-boolean-option
       gnc:pagename-display optname-show-markers "b" "" #f))
     ; Reserve line
-    (gnc:register-option options (gnc:make-simple-boolean-option
-      gnc:pagename-display optname-show-reserve "c" "" #f))
+    (gnc:register-option options (gnc:make-complex-boolean-option
+      gnc:pagename-display optname-show-reserve "c" "" #f #f
+      (lambda (x)
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display optname-reserve x))))
     (gnc:register-option options (gnc:make-number-range-option
       gnc:pagename-display optname-reserve "d" optname-reserve
       0 0 10E9 2 0.01))
     ; Purchasing power target
-    (gnc:register-option options (gnc:make-simple-boolean-option
-      gnc:pagename-display optname-show-target "e" "" #f))
+    (gnc:register-option options (gnc:make-complex-boolean-option
+      gnc:pagename-display optname-show-target "e" "" #f #f
+      (lambda (x)
+        (gnc-option-db-set-option-selectable-by-name
+         options gnc:pagename-display optname-target x))))
     (gnc:register-option options (gnc:make-number-range-option
       gnc:pagename-display optname-target "f" optname-target
       0 0 10E9 2 0.01))
     ; Future minimum
     (gnc:register-option options (gnc:make-simple-boolean-option
       gnc:pagename-display optname-show-minimum "g" "" #f))
-  options)
+    (gnc:options-set-default-section options gnc:pagename-general)
+    options)
 )
 
 ; Renderer
@@ -160,26 +167,25 @@
 
     ; Minimum line
     (when show-minimum
-      (set! series (append series (list (list "Minimum" "#0AA"))))
-      (let* ((minimum (car (reverse balances))))
-        (gnc:html-linechart-append-column! chart
-          (reverse (map (lambda (balance)
-            (set! minimum (min minimum balance))
-            minimum) (reverse balances))))))
+      (set! series (cons (list (_ "Minimum") "#0AA") series))
+      (gnc:html-linechart-append-column!
+       chart (let loop ((balances balances) (result '()))
+               (if (null? balances) (reverse! result)
+                   (loop (cdr balances) (cons (apply min balances) result))))))
 
     ; Balance line (do this here so it draws over the minimum line)
-    (set! series (append series (list (list "Balance" "#0A0"))))
+    (set! series (cons (list (_ "Balance") "#0A0") series))
     (gnc:html-linechart-append-column! chart balances)
 
     ; Target line
     (when show-target
-      (set! series (append series (list (list "Target" "#FF0"))))
+      (set! series (cons (list (_ "Target") "#FF0") series))
       (gnc:html-linechart-append-column! chart
         (make-list (length intervals) (+ reserve target))))
 
     ; Reserve line
     (when show-reserve
-      (set! series (append series (list (list "Reserve" "#F00"))))
+      (set! series (cons (list (_ "Reserve") "#F00") series))
       (gnc:html-linechart-append-column! chart
         (make-list (length intervals) reserve)))
 
@@ -201,9 +207,9 @@
       (gnc:html-linechart-set-row-labels! chart
         (map qof-print-date (map cadr intervals)))
       (qof-date-format-set old-fmt))
-    (gnc:html-linechart-set-col-labels! chart (map car series))
+    (gnc:html-linechart-set-col-labels! chart (map car (reverse series)))
     ; Assign line colors
-    (gnc:html-linechart-set-col-colors! chart (map cadr series))
+    (gnc:html-linechart-set-col-colors! chart (map cadr (reverse series)))
 
     ; We're done!
     (gnc:html-document-add-object! document chart)

commit d0deda92525a8959f0518b2e59966f41c964ebba
Author: Ryan Turner <zdbiohazard2 at gmail.com>
Date:   Thu Feb 28 21:52:21 2019 -0800

    [balance-forecast] More clean-up.
    
     * Draw the "balance" line over the "minimum" line.
     * X axis labels should be for the end of the period,
       as that's when all the balance samples are taken.

diff --git a/gnucash/report/standard-reports/balance-forecast.scm b/gnucash/report/standard-reports/balance-forecast.scm
index ae1c22ccd..4c0ef5935 100644
--- a/gnucash/report/standard-reports/balance-forecast.scm
+++ b/gnucash/report/standard-reports/balance-forecast.scm
@@ -131,14 +131,14 @@
 
           ; Variables
           (chart (gnc:make-html-linechart))
-          (series (list (list "Balance" "#0A0")))
+          (series '())
           (intervals (gnc:make-date-interval-list
             from-date to-date (gnc:deltasym-to-delta interval)))
           (accum (gnc:make-commodity-collector))
           (balances #f)
         )
 
-    ; Balance line
+    ; Calculate balances
     (set! balances
       (map (lambda (date) (let* (
           (start-date (car date))
@@ -157,9 +157,8 @@
         (gnc:gnc-monetary-amount
           (gnc:sum-collector-commodity balance currency exchange-fn))
       )) intervals))
-    (gnc:html-linechart-append-column! chart balances)
 
-    ; Future Line
+    ; Minimum line
     (when show-minimum
       (set! series (append series (list (list "Minimum" "#0AA"))))
       (let* ((minimum (car (reverse balances))))
@@ -168,6 +167,10 @@
             (set! minimum (min minimum balance))
             minimum) (reverse balances))))))
 
+    ; Balance line (do this here so it draws over the minimum line)
+    (set! series (append series (list (list "Balance" "#0A0"))))
+    (gnc:html-linechart-append-column! chart balances)
+
     ; Target line
     (when show-target
       (set! series (append series (list (list "Target" "#FF0"))))
@@ -196,7 +199,7 @@
     (let ((old-fmt (qof-date-format-get)))
       (qof-date-format-set QOF-DATE-FORMAT-ISO)
       (gnc:html-linechart-set-row-labels! chart
-        (map qof-print-date (map car intervals)))
+        (map qof-print-date (map cadr intervals)))
       (qof-date-format-set old-fmt))
     (gnc:html-linechart-set-col-labels! chart (map car series))
     ; Assign line colors

commit 0cf973c1234179b8a4b514e312fedbe4b4b03fa6
Author: Ryan Turner <zdbiohazard2 at gmail.com>
Date:   Thu Feb 28 20:29:31 2019 -0800

    [balance-forecast] Clean-up
    
    * Fix dates display to ISO format
    * Use make-list properly to create a list with identical elements

diff --git a/gnucash/report/standard-reports/balance-forecast.scm b/gnucash/report/standard-reports/balance-forecast.scm
index 6ba4599bd..ae1c22ccd 100644
--- a/gnucash/report/standard-reports/balance-forecast.scm
+++ b/gnucash/report/standard-reports/balance-forecast.scm
@@ -136,7 +136,6 @@
             from-date to-date (gnc:deltasym-to-delta interval)))
           (accum (gnc:make-commodity-collector))
           (balances #f)
-          (minimum #nil)
         )
 
     ; Balance line
@@ -148,7 +147,7 @@
           (exchange-fn (gnc:case-exchange-fn price currency end-date))
           (sx-value (gnc-sx-all-instantiate-cashflow-all start-date end-date))
          )
-        (map (lambda (account)
+        (for-each (lambda (account)
           (accum 'add (xaccAccountGetCommodity account)
             (hash-ref sx-value (gncAccountGetGUID account) 0))
           (balance 'merge
@@ -161,25 +160,25 @@
     (gnc:html-linechart-append-column! chart balances)
 
     ; Future Line
-    (if show-minimum (let* ()
+    (when show-minimum
       (set! series (append series (list (list "Minimum" "#0AA"))))
-      (gnc:html-linechart-append-column! chart
-        (reverse (map (lambda (balance)
-          (if (null? minimum) (set! minimum balance)
-            (if (< balance minimum) (set! minimum balance)))
-          minimum) (reverse balances))))))
+      (let* ((minimum (car (reverse balances))))
+        (gnc:html-linechart-append-column! chart
+          (reverse (map (lambda (balance)
+            (set! minimum (min minimum balance))
+            minimum) (reverse balances))))))
 
     ; Target line
-    (if show-target (let* ()
+    (when show-target
       (set! series (append series (list (list "Target" "#FF0"))))
-      (gnc:html-linechart-append-column! chart (map (lambda (date)
-        (+ target reserve)) intervals))))
+      (gnc:html-linechart-append-column! chart
+        (make-list (length intervals) (+ reserve target))))
 
     ; Reserve line
-    (if show-reserve (let* ()
+    (when show-reserve
       (set! series (append series (list (list "Reserve" "#F00"))))
-      (gnc:html-linechart-append-column! chart (map (lambda (date)
-        reserve) intervals))))
+      (gnc:html-linechart-append-column! chart
+        (make-list (length intervals) reserve)))
 
     ; Set the chart titles
     (gnc:html-linechart-set-title! chart report-title)
@@ -194,8 +193,11 @@
     ; Set line markers
     (gnc:html-linechart-set-markers?! chart show-markers)
     ; Set series labels
-    (gnc:html-linechart-set-row-labels! chart
-      (map qof-print-date (map car intervals)))
+    (let ((old-fmt (qof-date-format-get)))
+      (qof-date-format-set QOF-DATE-FORMAT-ISO)
+      (gnc:html-linechart-set-row-labels! chart
+        (map qof-print-date (map car intervals)))
+      (qof-date-format-set old-fmt))
     (gnc:html-linechart-set-col-labels! chart (map car series))
     ; Assign line colors
     (gnc:html-linechart-set-col-colors! chart (map cadr series))

commit 55583829b01b9a6c2bcae741011b6d0c0dbf3427
Author: Ryan Turner <zdbiohazard2 at gmail.com>
Date:   Wed Feb 27 21:08:25 2019 -0800

    Report: Balance Forecast
    
    This report forecasts the combined balances of the selected accounts
    based on the scheduled transactions and plots them on a line graph.
    
    You can set a "reserve" amount, which will draw a red line on the
    graph, so you can easily see if your forecast dips below a given value.
    
    There is also a "future minimum" line which shows what the lowest future
    balance will be at a given point. I find this useful in conjunction with
    the "target" line for planning.

diff --git a/gnucash/report/standard-reports/CMakeLists.txt b/gnucash/report/standard-reports/CMakeLists.txt
index adda1e450..af94b30cb 100644
--- a/gnucash/report/standard-reports/CMakeLists.txt
+++ b/gnucash/report/standard-reports/CMakeLists.txt
@@ -9,6 +9,7 @@ set (standard_reports_SCHEME_2
     advanced-portfolio.scm
     average-balance.scm
     balance-sheet.scm
+    balance-forecast.scm
     budget-balance-sheet.scm
     budget-barchart.scm
     budget-flow.scm
diff --git a/gnucash/report/standard-reports/balance-forecast.scm b/gnucash/report/standard-reports/balance-forecast.scm
new file mode 100644
index 000000000..6ba4599bd
--- /dev/null
+++ b/gnucash/report/standard-reports/balance-forecast.scm
@@ -0,0 +1,213 @@
+;; -*-scheme-*- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; balance-forecast.scm
+;; Simulate future balance based on scheduled transactions.
+;;
+;; By Ryan Turner 2019-02-27 <zdbiohazard2 at gmail.com>
+;;
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2 of
+;; the License, or (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, contact:
+;;
+;; Free Software Foundation           Voice:  +1-617-542-5942
+;; 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+;; Boston, MA  02110-1301,  USA       gnu at gnu.org
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(define-module (gnucash report standard-reports balance-forecast))
+
+(use-modules (gnucash gnc-module))
+(use-modules (gnucash gettext))
+
+(gnc:module-load "gnucash/report/report-system" 0)
+
+; Name definitions
+(define report-title         (N_ "Balance Forecast"))
+(define optname-accounts     (N_ "Accounts"))
+(define optname-from-date    (N_ "Simulate from"))
+(define optname-to-date      (N_ "Simulate until"))
+(define optname-interval     (N_ "Interval"))
+(define optname-currency     (N_ "Report currency"))
+(define optname-price        (N_ "Price source"))
+(define optname-plot-width   (N_ "Plot width"))
+(define optname-plot-height  (N_ "Plot height"))
+(define optname-show-markers (N_ "Show markers"))
+(define optname-show-reserve (N_ "Show reserve line"))
+(define optname-reserve      (N_ "Reserve amount"))
+(define optname-show-target  (N_ "Show target line"))
+(define optname-target       (N_ "Target amount above reserve"))
+(define optname-show-minimum (N_ "Show future minimum"))
+
+; Options generator
+(define (options-generator)
+  (let* ((options (gnc:new-options)))
+    ; Account selector
+    (gnc:register-option options
+      (gnc:make-account-list-option
+        gnc:pagename-accounts optname-accounts "a" optname-accounts
+        (lambda ()
+          (gnc:filter-accountlist-type
+            (list ACCT-TYPE-BANK ACCT-TYPE-CASH)
+            (gnc-account-get-descendants-sorted
+              (gnc-get-current-root-account))))
+        #f #t))
+
+    ; Date range
+    (gnc:options-add-date-interval! options
+      gnc:pagename-general optname-from-date optname-to-date "a")
+    ; Date interval
+    (gnc:options-add-interval-choice! options
+      gnc:pagename-general optname-interval "b" 'DayDelta)
+    ; Report currency
+    (gnc:options-add-currency! options
+      gnc:pagename-general optname-currency "c")
+    ; Price source
+    (gnc:options-add-price-source! options
+      gnc:pagename-general optname-price "d" 'pricedb-nearest)
+
+    ; Plot size
+    (gnc:options-add-plot-size! options gnc:pagename-display
+      optname-plot-width optname-plot-height "a"
+      (cons 'percent 100.0) (cons 'percent 100.0))
+    ; Markers
+    (gnc:register-option options (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-markers "b" "" #f))
+    ; Reserve line
+    (gnc:register-option options (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-reserve "c" "" #f))
+    (gnc:register-option options (gnc:make-number-range-option
+      gnc:pagename-display optname-reserve "d" optname-reserve
+      0 0 10E9 2 0.01))
+    ; Purchasing power target
+    (gnc:register-option options (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-target "e" "" #f))
+    (gnc:register-option options (gnc:make-number-range-option
+      gnc:pagename-display optname-target "f" optname-target
+      0 0 10E9 2 0.01))
+    ; Future minimum
+    (gnc:register-option options (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-minimum "g" "" #f))
+  options)
+)
+
+; Renderer
+(define (document-renderer report-obj)
+  ; Option-getting helper function.
+  (define (get-option pagename optname)
+    (gnc:option-value
+      (gnc:lookup-option (gnc:report-options report-obj) pagename optname)))
+
+  (gnc:report-starting report-title)
+
+  (let* ( (document (gnc:make-html-document))
+          ; Options
+          (accounts (get-option gnc:pagename-accounts optname-accounts))
+
+          (from-date (gnc:time64-start-day-time (gnc:date-option-absolute-time
+            (get-option gnc:pagename-general optname-from-date))))
+          (to-date (gnc:time64-end-day-time (gnc:date-option-absolute-time
+            (get-option gnc:pagename-general optname-to-date))))
+          (interval (get-option gnc:pagename-general optname-interval))
+          (currency (get-option gnc:pagename-general optname-currency))
+          (price (get-option gnc:pagename-general optname-price))
+
+          (plot-width (get-option gnc:pagename-display optname-plot-width))
+          (plot-height (get-option gnc:pagename-display optname-plot-height))
+          (show-markers (get-option gnc:pagename-display optname-show-markers))
+          (show-reserve (get-option gnc:pagename-display optname-show-reserve))
+          (reserve (get-option gnc:pagename-display optname-reserve))
+          (show-target (get-option gnc:pagename-display optname-show-target))
+          (target (get-option gnc:pagename-display optname-target))
+          (show-minimum (get-option gnc:pagename-display optname-show-minimum))
+
+          ; Variables
+          (chart (gnc:make-html-linechart))
+          (series (list (list "Balance" "#0A0")))
+          (intervals (gnc:make-date-interval-list
+            from-date to-date (gnc:deltasym-to-delta interval)))
+          (accum (gnc:make-commodity-collector))
+          (balances #f)
+          (minimum #nil)
+        )
+
+    ; Balance line
+    (set! balances
+      (map (lambda (date) (let* (
+          (start-date (car date))
+          (end-date (cadr date))
+          (balance (gnc:make-commodity-collector))
+          (exchange-fn (gnc:case-exchange-fn price currency end-date))
+          (sx-value (gnc-sx-all-instantiate-cashflow-all start-date end-date))
+         )
+        (map (lambda (account)
+          (accum 'add (xaccAccountGetCommodity account)
+            (hash-ref sx-value (gncAccountGetGUID account) 0))
+          (balance 'merge
+            (gnc:account-get-comm-balance-at-date account end-date #f) #f)
+        ) accounts)
+        (balance 'merge accum #f)
+        (gnc:gnc-monetary-amount
+          (gnc:sum-collector-commodity balance currency exchange-fn))
+      )) intervals))
+    (gnc:html-linechart-append-column! chart balances)
+
+    ; Future Line
+    (if show-minimum (let* ()
+      (set! series (append series (list (list "Minimum" "#0AA"))))
+      (gnc:html-linechart-append-column! chart
+        (reverse (map (lambda (balance)
+          (if (null? minimum) (set! minimum balance)
+            (if (< balance minimum) (set! minimum balance)))
+          minimum) (reverse balances))))))
+
+    ; Target line
+    (if show-target (let* ()
+      (set! series (append series (list (list "Target" "#FF0"))))
+      (gnc:html-linechart-append-column! chart (map (lambda (date)
+        (+ target reserve)) intervals))))
+
+    ; Reserve line
+    (if show-reserve (let* ()
+      (set! series (append series (list (list "Reserve" "#F00"))))
+      (gnc:html-linechart-append-column! chart (map (lambda (date)
+        reserve) intervals))))
+
+    ; Set the chart titles
+    (gnc:html-linechart-set-title! chart report-title)
+    (gnc:html-linechart-set-subtitle! chart (format #f (_ "~a to ~a")
+      (qof-print-date from-date) (qof-print-date to-date)))
+    ; Set the chart size
+    (gnc:html-linechart-set-width! chart plot-width)
+    (gnc:html-linechart-set-height! chart plot-height)
+    ; Set the axis labels
+    (gnc:html-linechart-set-y-axis-label! chart
+      (gnc-commodity-get-mnemonic currency))
+    ; Set line markers
+    (gnc:html-linechart-set-markers?! chart show-markers)
+    ; Set series labels
+    (gnc:html-linechart-set-row-labels! chart
+      (map qof-print-date (map car intervals)))
+    (gnc:html-linechart-set-col-labels! chart (map car series))
+    ; Assign line colors
+    (gnc:html-linechart-set-col-colors! chart (map cadr series))
+
+    ; We're done!
+    (gnc:html-document-add-object! document chart)
+    (gnc:report-finished)
+  document))
+
+(gnc:define-report
+  'version 1
+  'name report-title
+  'report-guid "321d940d487d4ccbb4bd0467ffbadbf2"
+  'options-generator options-generator
+  'renderer document-renderer)

commit b6a708196ee614796bcc80db72e5a6109d332269
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Mar 14 09:42:08 2019 +0800

    [commodity-utilities] rewrite gnc:exchange-by-pricealist-nearest
    
    this function made clearer. first we can remove sanity-check:
    pricealist will always be sent as a list, and doesn't need to be
    confirmed it is a pair? because assoc-ref can handle an empty list
    returning #f.
    
    then the conversion routine is reordered to be clearer.

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index e5fe468d2..de8026f9e 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -853,12 +853,13 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
 
 ;; Exchange by the nearest price from pricelist. This function takes
 ;; the <gnc-monetary> 'foreign' amount, the <gnc:commodity*>
-;; 'domestic' commodity, a <gnc:time-pair> 'date' and the
+;; 'domestic' commodity, a <gnc:time64> 'date' and the
 ;; 'pricelist'. It exchanges the amount into the domestic currency,
 ;; using the price nearest to 'data' found in the pricelist. The
 ;; function returns a <gnc-monetary>.
 (define (gnc:exchange-by-pricealist-nearest
          pricealist foreign domestic date)
+  ;;Used in weighted-average gnc:case-exchange-time-fn only.
   (gnc:debug "foreign " (gnc:monetary->string foreign))
   (gnc:debug "domestic " (gnc-commodity-get-printname domestic))
   (gnc:debug "pricealist " pricealist)
@@ -867,15 +868,12 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
        date
        (or (gnc:exchange-by-euro foreign domestic date)
            (gnc:exchange-if-same foreign domestic)
-           (and (pair? pricealist)
-                (gnc:make-gnc-monetary
-                 domestic
-                 (* (gnc:gnc-monetary-amount foreign)
-                    (let ((plist (assoc-ref pricealist (gnc:gnc-monetary-commodity foreign))))
-                      (or (and plist
-                               (not (null? plist))
-                               (gnc:pricelist-price-find-nearest plist date))
-                          0))))))))
+           (let* ((foreign-comm (gnc:gnc-monetary-commodity foreign))
+                  (foreign-amt (gnc:gnc-monetary-amount foreign))
+                  (plist (assoc-ref pricealist foreign-comm))
+                  (price (and plist
+                              (gnc:pricelist-price-find-nearest plist date))))
+             (gnc:make-gnc-monetary domestic (* foreign-amt (or price 0)))))))
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

commit 274897fb8c59ec202c02e4dcc6d25a1c10c3d3c2
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Mar 14 09:06:22 2019 +0800

    [commodity-utilities] inline gnc:pricealist-lookup-nearest-in-time
    
    this is an unexported single-use function. we can safely inline.

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index b8990abb0..e5fe468d2 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -372,15 +372,6 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
          (and later (cadr later))))))
 
 
-;; Find the price of the 'commodity' in the 'pricealist' that is
-;; nearest to the 'date'.
-(define (gnc:pricealist-lookup-nearest-in-time pricealist commodity date)
-  (let ((plist (assoc-ref pricealist commodity)))
-    (or (and plist
-             (not (null? plist))
-             (gnc:pricelist-price-find-nearest plist date))
-        0)))
-
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Functions to get one price at a given time (i.e. not time-variant).
 
@@ -880,8 +871,12 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
                 (gnc:make-gnc-monetary
                  domestic
                  (* (gnc:gnc-monetary-amount foreign)
-                    (gnc:pricealist-lookup-nearest-in-time
-                     pricealist (gnc:gnc-monetary-commodity foreign) date)))))))
+                    (let ((plist (assoc-ref pricealist (gnc:gnc-monetary-commodity foreign))))
+                      (or (and plist
+                               (not (null? plist))
+                               (gnc:pricelist-price-find-nearest plist date))
+                          0))))))))
+
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Choosing exchange functions made easy -- get the right function by

commit 0e60c77577b57fdae5e4363c43d13af10a99f23d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu Mar 14 09:02:30 2019 +0800

    [commodity-utilities] deprecate gnc:exchange-by-pricevalue-helper
    
    This function is only used once, internally, and performs a sanity
    check (if price-value ... ...) which is, never needed because the
    price-value received has been sanitized to return a price, or 0 and
    will never be #f. Inlining this function means we can skip this sanity
    check.

diff --git a/gnucash/report/report-system/commodity-utilities.scm b/gnucash/report/report-system/commodity-utilities.scm
index 7df5a464a..b8990abb0 100644
--- a/gnucash/report/report-system/commodity-utilities.scm
+++ b/gnucash/report/report-system/commodity-utilities.scm
@@ -773,6 +773,8 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
 ;; the <gnc:numeric> 'price-value'. Returns a <gnc:monetary>.
 (define (gnc:exchange-by-pricevalue-helper
          foreign domestic price-value)
+  (issue-deprecation-warning
+   "gnc:exchange-by-pricevalue-helper is deprecated. please inline function.")
   (and (gnc:gnc-monetary? foreign)
        (gnc:make-gnc-monetary
         domestic
@@ -875,10 +877,11 @@ construct with gnc:make-gnc-monetary and gnc:monetary->string instead.")
        (or (gnc:exchange-by-euro foreign domestic date)
            (gnc:exchange-if-same foreign domestic)
            (and (pair? pricealist)
-                (gnc:exchange-by-pricevalue-helper
-                 foreign domestic
-                 (gnc:pricealist-lookup-nearest-in-time
-                  pricealist (gnc:gnc-monetary-commodity foreign) date))))))
+                (gnc:make-gnc-monetary
+                 domestic
+                 (* (gnc:gnc-monetary-amount foreign)
+                    (gnc:pricealist-lookup-nearest-in-time
+                     pricealist (gnc:gnc-monetary-commodity foreign) date)))))))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Choosing exchange functions made easy -- get the right function by
diff --git a/gnucash/report/report-system/report-system.scm b/gnucash/report/report-system/report-system.scm
index 7045a9861..85c149123 100644
--- a/gnucash/report/report-system/report-system.scm
+++ b/gnucash/report/report-system/report-system.scm
@@ -57,7 +57,7 @@
 (export gnc:exchange-by-euro)
 (export gnc:exchange-if-same)
 (export gnc:make-exchange-function)
-(export gnc:exchange-by-pricevalue-helper)
+(export gnc:exchange-by-pricevalue-helper) ;deprecated
 (export gnc:exchange-by-pricedb-helper)
 (export gnc:exchange-by-pricedb-latest )
 (export gnc:exchange-by-pricedb-nearest)



Summary of changes:
 .../report/report-system/commodity-utilities.scm   |  26 +-
 gnucash/report/report-system/report-system.scm     |   2 +-
 gnucash/report/standard-reports/CMakeLists.txt     |   1 +
 .../report/standard-reports/balance-forecast.scm   | 288 +++++++++++++++++++++
 4 files changed, 301 insertions(+), 16 deletions(-)
 create mode 100644 gnucash/report/standard-reports/balance-forecast.scm



More information about the gnucash-changes mailing list