gnucash master: Multiple changes pushed

John Ralls jralls at code.gnucash.org
Tue Oct 31 21:00:21 EDT 2017


Updated	 via  https://github.com/Gnucash/gnucash/commit/4f971636 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a6f4ea65 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f4acb6c0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3913c528 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/46b3e1ca (commit)
	 via  https://github.com/Gnucash/gnucash/commit/85e56512 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9c7ba523 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/2fcd1efd (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3c8eeb8b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a8407484 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/be44db2e (commit)
	 via  https://github.com/Gnucash/gnucash/commit/cbd87647 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/039dda52 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/41ad8915 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/49c70795 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5ca2834b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/44df91ad (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9cb8a3c8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/6e3d4781 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d6d1549a (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3926535e (commit)
	from  https://github.com/Gnucash/gnucash/commit/f05761e6 (commit)



commit 4f9716362c7c10c5c02f4b14ca0f9f2aa66c244e
Merge: a6f4ea6 6e3d478
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Oct 31 17:31:33 2017 -0700

    Merge branch J. Marino's fix-report-colors into unstable


commit a6f4ea65e94efd11f6dc495660b4fc19c48ba9ab
Merge: a840748 f4acb6c
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Oct 31 17:24:44 2017 -0700

    Merge J. Marino's 'fix/report-net-barchart' into unstable


commit f4acb6c00071a8c4e900bf0f2ee479826c5eb372
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Wed Oct 18 14:44:54 2017 -0600

    report/category-barchart: fix unit test to work with gnc-monetary
    
    The unit test for category-barchart did not initialize html stylesheets.
    Without any stylesheets available, the renderer defaults to a
    trivial renderer. This works fine if the table in the report is
    populated by doubles. However, now it is populated by gnc-monetary
    and they need a stylesheet to be properly formatted.
    
    This commit makes sure to initialize the html stylesheet code in
    the unit test and adapts the parsing code to the new formatting.

diff --git a/gnucash/report/standard-reports/test/test-generic-category-report.scm b/gnucash/report/standard-reports/test/test-generic-category-report.scm
index e5a0473..a93ac17 100644
--- a/gnucash/report/standard-reports/test/test-generic-category-report.scm
+++ b/gnucash/report/standard-reports/test/test-generic-category-report.scm
@@ -32,6 +32,7 @@
 (use-modules (gnucash app-utils))
 (use-modules (gnucash engine))
 (use-modules (sw_engine))
+(use-modules (gnucash report stylesheets))
 
 (use-modules (gnucash report report-system collectors))
 (use-modules (gnucash engine test test-extras))
@@ -114,8 +115,8 @@
 	  (let* ((result (gnc:html-document-render doc #f))
 		 (tbl (stream->list
 		       (pattern-streamer "<tr>"
-					 (list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
-					       (list "<number> ([^<]*)</td>" 1))
+					 (list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
 					 result))))
 	    (every (lambda (date value-list)
 		     (let ((day (second date))
@@ -172,12 +173,12 @@
 		 (columns (columns-from-report-document html-document))
 		 (tbl (stream->list
 		       (pattern-streamer "<tr>"
-					 (list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1))
+					 (list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
 					 html-document))))
 	    ;(format #t "~a" html-document)
 	    (and (= 6 (length columns))
@@ -188,7 +189,7 @@
 
 (define (columns-from-report-document doc)
   (let ((columns (stream->list (pattern-streamer "<th>"
-						 (list (list "<string> ([^<]*)</" 1))
+						 (list (list "<th>([^<]*)</" 1))
 						 doc))))
     (map caar columns)))
 
@@ -231,8 +232,8 @@
 		 (columns (columns-from-report-document html-document))
 		 (tbl (stream->list
 		       (pattern-streamer "<tr>"
-					 (list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
-					       (list "<number> ([^<]*)</td>" 1))
+					 (list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>" 1 2 3)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
 					 html-document)))
 		 (row-count (tbl-row-count tbl)))
 	    (and (member "account-1" columns)

commit 3913c528f10200e3bc1e5c46fa47c828a41d4b42
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Wed Oct 18 14:32:25 2017 -0600

    report/category-barchart: calculate using gnc-monetary instead of double
    
    Perform and store all calculations using gnc-monetary instead of double.
    Conversion to double is only needed as a last step when adding data
    to the chart (using new local function "monetary->double").
    
    When a table is displayed, since the values are gnc-monetary, they are
    properly formatted as monetary values.

diff --git a/gnucash/report/standard-reports/category-barchart.scm b/gnucash/report/standard-reports/category-barchart.scm
index 22b0482..3cb4bb2 100644
--- a/gnucash/report/standard-reports/category-barchart.scm
+++ b/gnucash/report/standard-reports/category-barchart.scm
@@ -302,19 +302,24 @@ developing over time"))
                (averaging-multiplier
                  (if averaging-fraction-func
                      ;; Calculate the divisor of the amounts so that an
-                     ;; average is shown
+                     ;; average is shown. Multiplier factor is a gnc-numeric
                      (let* ((start-frac-avg (averaging-fraction-func (gnc:timepair->secs from-date-tp)))
                              (end-frac-avg (averaging-fraction-func (+ 1 (gnc:timepair->secs to-date-tp))))
                              (diff-avg (- end-frac-avg start-frac-avg))
+                             (diff-avg-numeric (gnc:make-gnc-numeric
+                                                (inexact->exact (round (* diff-avg 1000000))) ; 6 decimals precision
+                                                1000000))
                              (start-frac-int (interval-fraction-func (gnc:timepair->secs from-date-tp)))
                              (end-frac-int (interval-fraction-func (+ 1 (gnc:timepair->secs to-date-tp))))
                              (diff-int (- end-frac-int start-frac-int))
+                             (diff-int-numeric (gnc:make-gnc-numeric
+                                                (inexact->exact diff-int) 1))
                             )
                      ;; Extra sanity check to ensure a number smaller than 1
                      (if (> diff-avg diff-int)
-                         (/ diff-int diff-avg)
-                         1))
-                     1))
+                         (gnc-numeric-div diff-int-numeric diff-avg-numeric GNC-DENOM-AUTO GNC-RND-ROUND)
+                         (gnc:make-gnc-numeric 1 1)))
+                     (gnc:make-gnc-numeric 1 1)))
                ;; If there is averaging, the report-title is extended
                ;; accordingly.
                (report-title
@@ -323,6 +328,7 @@ developing over time"))
                    ((WeekDelta) (string-append report-title " " (_ "Weekly Average")))
                    ((DayDelta) (string-append report-title " " (_ "Daily Average")))
                    (else report-title)))
+               (currency-frac (gnc-commodity-get-fraction report-currency))
                ;; This is the list of date intervals to calculate.
                (dates-list (if do-intervals?
                                (gnc:make-date-interval-list
@@ -349,24 +355,52 @@ developing over time"))
                               date-list-item)))
                  dates-list))
 
-          ;; Converts a commodity-collector into one single double
-          ;; number, depending on the report's currency and the
-          ;; exchange-fn calculated above. Returns a double, multiplied
-          ;; by the averaging-multiplies (smaller than one; multiplication
+          ;; Converts a commodity-collector into gnc-monetary in the report's
+          ;; currency using the exchange-fn calculated above. Returns a gnc-monetary
+          ;; multiplied by the averaging-multiplier (smaller than one; multiplication
           ;; instead of division to avoid division-by-zero issues) in case
           ;; the user wants to see the amounts averaged over some value.
-          (define (collector->double c date)
-            ;; Future improvement: Let the user choose which kind of
-            ;; currency combining she want to be done.
-	    (if (not (gnc:timepair? date))
-		(throw 'wrong))
-            (*
-              (gnc-numeric-to-double
+          (define (collector->monetary c date)
+            (if (not (gnc:timepair? date))
+                (throw 'wrong))
+            (gnc:make-gnc-monetary
+             report-currency
+             (gnc-numeric-mul
               (gnc:gnc-monetary-amount
                 (gnc:sum-collector-commodity
                 c report-currency
-                (lambda (a b) (exchange-fn a b date)))))
-             averaging-multiplier))
+                (lambda (a b) (exchange-fn a b date))))
+              averaging-multiplier currency-frac GNC-RND-ROUND)
+              ))
+
+          ;; Add two or more gnc-monetary objects
+          (define (monetary+ a . blist)
+            (if (null? blist)
+                a
+                (let ((b (apply monetary+ blist)))
+                  (if (and (gnc:gnc-monetary? a) (gnc:gnc-monetary? b))
+                      (let ((same-currency? (gnc-commodity-equal (gnc:gnc-monetary-commodity a) (gnc:gnc-monetary-commodity b)))
+                            (amount (gnc-numeric-add (gnc:gnc-monetary-amount a) (gnc:gnc-monetary-amount b) GNC-DENOM-AUTO GNC-RND-ROUND)))
+                        (if same-currency?
+                            (gnc:make-gnc-monetary (gnc:gnc-monetary-commodity a) amount)
+                            (warn "incompatible currencies in monetary+: " a b)))
+                      (warn "wrong arguments for monetary+: " a b)))
+                )
+            )
+
+          ;; Extract value of gnc-monetary and return it as double
+          (define (monetary->double monetary)
+            (gnc-numeric-to-double (gnc:gnc-monetary-amount monetary)))
+
+          ;; copy of gnc:not-all-zeros using gnc-monetary
+          (define (not-all-zeros data)
+            (define (myor list)
+              (begin
+                (if (null? list) #f
+                    (or (car list) (myor (cdr list))))))
+            (cond ((gnc:gnc-monetary? data) (not (gnc-numeric-zero-p (gnc:gnc-monetary-amount data))))
+                  ((list? data) (myor (map not-all-zeros data)))
+                  (else #f)))
 
 	  (define (count-accounts current-depth accts)
 	    (if (< current-depth tree-depth)
@@ -394,7 +428,7 @@ developing over time"))
           ;; would forget an account that is selected but not its
           ;; parent.
 	  (define (apply-sign account x)
-	    (if (reverse-balance? account) (- x) x))
+            (if (reverse-balance? account) (gnc:monetary-neg x) x))
           (define (calculate-report accounts progress-range)
 	    (let* ((the-acount-destination-alist (account-destination-alist accounts
 									    account-types
@@ -404,7 +438,7 @@ developing over time"))
 			(lambda (account result)
 			  (map (lambda (collector datepair)
 				 (let ((date (second datepair)))
-				   (apply-sign account (collector->double collector date))))
+                                   (apply-sign account (collector->monetary collector date))))
 			       result dates-list))
 			(lambda (account result)
 			  (let ((commodity-collector (gnc:make-commodity-collector)))
@@ -412,8 +446,8 @@ developing over time"))
 						   (commodity-collector 'merge next #f)
 						   (collector-add list-collector
 								  (apply-sign account
-									      (collector->double commodity-collector
-												 date))))
+                                                                              (collector->monetary commodity-collector
+                                                                                                   date))))
 						 (collector-into-list)
 						 result dates-list))))))
 
@@ -446,7 +480,8 @@ developing over time"))
           ;; Sort the account list according to the account code field.
           (set! all-data (sort
                           (filter (lambda (l)
-                                    (not (= 0.0 (apply + (cadr l)))))
+                                    (not (gnc-numeric-equal (gnc-numeric-zero)
+                                                            (gnc:gnc-monetary-amount (apply monetary+ (cadr l))))))
                                   (calculate-report accounts (cons 0 90)))
 			  (cond
 			   ((eq? sort-method 'acct-code)
@@ -463,8 +498,10 @@ developing over time"))
 					     xaccAccountGetName) (car b)))))
 			   (else
 			    (lambda (a b)
-			      (> (apply + (cadr a))
-				 (apply + (cadr b))))))))
+                              (> (gnc-numeric-compare (gnc:gnc-monetary-amount (apply monetary+ (cadr a)))
+                                                      (gnc:gnc-monetary-amount (apply monetary+ (cadr b))))
+                                 0)))
+                            )))
           ;; Or rather sort by total amount?
           ;;(< (apply + (cadr a)) 
           ;;   (apply + (cadr b))))))
@@ -478,7 +515,7 @@ developing over time"))
           ;; Proceed if the data is non-zeros
           (if 
            (and (not (null? all-data))
-                (gnc:not-all-zeros (map cadr all-data)))
+                (not-all-zeros  (map cadr all-data)))
            (begin 
              (set! date-string-list (datelist->stringlist dates-list))
              (qof-date-format-set QOF-DATE-FORMAT-ISO)
@@ -547,7 +584,7 @@ developing over time"))
                  (let* ((start (take all-data (- max-slices 1)))
                         (finish (drop all-data (- max-slices 1)))
                         (other-sum (map 
-                                    (lambda (l) (apply + l))
+                                    (lambda (l) (apply monetary+ l))
                                     (apply zip (map cadr finish)))))
                    (set! all-data
                          (append start
@@ -576,7 +613,9 @@ developing over time"))
                  (if (not (null? all-data))
                      (gnc:html-barchart-set-data!
                       chart
-                      (apply zip (map cadr all-data))))
+                      (apply zip (map (lambda (mlist)
+                                        (map monetary->double mlist))
+                                      (map cadr all-data)))))
              
                  ;; Labels and colors
 	         (gnc:report-percent-done 94)
@@ -596,7 +635,9 @@ developing over time"))
                  (if (not (null? all-data))
                      (gnc:html-linechart-set-data!
                       chart
-                      (apply zip (map cadr all-data))))
+                      (apply zip (map (lambda (mlist)
+                                        (map monetary->double mlist))
+                                      (map cadr all-data)))))
 
                  ;; Labels and colors
 	         (gnc:report-percent-done 94)
@@ -716,8 +757,8 @@ developing over time"))
                             (sumrow
                              (lambda (row)
                                (if (not (null? row))
-                                   (+ (car row) (sumrow (cdr row)))
-                                   0
+                                   (monetary+ (car row) (sumrow (cdr row)))
+                                   (gnc:make-gnc-monetary report-currency (gnc-numeric-zero))
                                    )
                                )
                              ))

commit 46b3e1caad3b585727803cd46e6f8d9d20a65d81
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Wed Oct 18 09:53:09 2017 -0600

    report/net-linechart: fix unit test to work with gnc-monetary
    
    The unit test for net-linechart did not initialize html stylesheets.
    Without any stylesheets available, the renderer defaults to a
    trivial renderer. This works fine if the table in the net-linechart
    report is populated by doubles. However, now it is populated by
    gnc-monetary and they need a stylesheet to be properly formatted.
    
    This commit makes sure to initialize the html stylesheet code in
    the unit test and adapts the parsing code to the new formatting.

diff --git a/gnucash/report/standard-reports/test/test-generic-net-linechart.scm b/gnucash/report/standard-reports/test/test-generic-net-linechart.scm
index dd79472..3b26dfe 100644
--- a/gnucash/report/standard-reports/test/test-generic-net-linechart.scm
+++ b/gnucash/report/standard-reports/test/test-generic-net-linechart.scm
@@ -25,6 +25,7 @@
 
 (use-modules (gnucash gnc-module))
 (gnc:module-load "gnucash/report/report-system" 0)
+(use-modules (gnucash report stylesheets))
 
 (use-modules (gnucash report report-system test test-extras))
 (use-modules (gnucash engine test test-extras))
@@ -97,11 +98,11 @@
 	  (let* ((result (gnc:html-document-render doc #f))
 		 (tbl (stream->list
 		       (pattern-streamer "<tr>"
-					 (list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
+					 (list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
 						     1 2 3)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1))
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
 					 result))))
 	    (and (= 1 (tbl-ref->number tbl 0 1))
 			 (= 0 (tbl-ref->number tbl 0 2))
@@ -151,11 +152,11 @@
 	  (let* ((result (gnc:html-document-render doc #f))
 		 (tbl (stream->list
 		       (pattern-streamer "<tr>"
-					 (list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
+					 (list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
 						     1 2 3)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1))
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
 					 result))))
 	    (and (every (lambda (row)
 				  (and (equal? (second row) (fourth row))
@@ -205,11 +206,11 @@
 	  (let* ((result (gnc:html-document-render doc #f))
 		 (tbl (stream->list
 		       (pattern-streamer "<tr>"
-					 (list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
+					 (list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
 						     1 2 3)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1))
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
 					 result))))
 	    (and (every (lambda (row)
 				  (and (= (string->number (car (fourth row)))

commit 85e56512023f67bf6b8843625c427a836ec5eb88
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Wed Oct 18 09:46:50 2017 -0600

    report/net-linechart: calculate using gnc-monetary instead of double
    
    Perform and store all calculations using gnc-monetary instead of double.
    Conversion to double is only needed as a last step when adding data
    to the chart (using new function "monetary->double").
    
    If the table is displayed, its values are properly formatted as monetary
    values since they are gnc-monetary instead of doubles.

diff --git a/gnucash/report/standard-reports/net-linechart.scm b/gnucash/report/standard-reports/net-linechart.scm
index 2738187..13a37bf 100644
--- a/gnucash/report/standard-reports/net-linechart.scm
+++ b/gnucash/report/standard-reports/net-linechart.scm
@@ -242,26 +242,36 @@
         #f))
 
     ;; This exchanges the commodity-collector 'c' to one single
-    ;; 'report-currency' according to the exchange-fn. Returns a
-    ;; double.
-    (define (collector->double c date)
+    ;; 'report-currency' according to the exchange-fn. Returns a gnc:monetary
+    (define (collector->monetary c date)
       (if (not (gnc:timepair? date))
 	  (throw 'wrong))
-      (gnc-numeric-to-double
-       (gnc:gnc-monetary-amount
-        (gnc:sum-collector-commodity
-         c report-currency
-         (lambda (a b) (exchange-fn a b date))))))
+      (gnc:sum-collector-commodity
+       c report-currency
+       (lambda (a b) (exchange-fn a b date))))
+
+    ;; Add two gnc-monetary objects in the same currency.
+    (define (monetary+ a b)
+      (if (and (gnc:gnc-monetary? a) (gnc:gnc-monetary? b))
+          (let ((same-currency? (gnc-commodity-equal (gnc:gnc-monetary-commodity a) (gnc:gnc-monetary-commodity b)))
+                (amount (gnc-numeric-add (gnc:gnc-monetary-amount a) (gnc:gnc-monetary-amount b) GNC-DENOM-AUTO GNC-RND-ROUND)))
+            (if same-currency?
+                (gnc:make-gnc-monetary (gnc:gnc-monetary-commodity a) amount)
+                (warn "incompatible currencies in monetary+: " a b)))
+          (warn "wrong arguments for monetary+: " a b)))
+
+    (define (monetary->double monetary)
+      (gnc-numeric-to-double (gnc:gnc-monetary-amount monetary)))
 
     ;; This calculates the balances for all the 'accounts' for each
     ;; element of the list 'dates'. If income?==#t, the signs get
     ;; reversed according to income-sign-reverse general option
-    ;; settings. Uses the collector->double conversion function
-    ;; above. Returns a list of doubles.
+    ;; settings. Uses the collector->monetary conversion function
+    ;; above. Returns a list of gnc-monetary.
     (define (process-datelist accounts dates income?)
       (map
        (lambda (date)
-         (collector->double
+         (collector->monetary
           ((if inc-exp?
                (if income?
                    gnc:accounts-get-comm-total-income
@@ -325,14 +335,14 @@
 	      (account-reformat (if inc-exp?
 				    (lambda (account result)
 				      (map (lambda (collector date-interval)
-					     (- (collector->double collector (second date-interval))))
+					     (gnc:monetary-neg (collector->monetary collector (second date-interval))))
 					   result dates-list))
 				    (lambda (account result)
 				      (let ((commodity-collector (gnc:make-commodity-collector)))
 					(collector-end (fold (lambda (next date list-collector)
 							       (commodity-collector 'merge next #f)
 							       (collector-add list-collector
-									      (collector->double
+									      (collector->monetary
 									       commodity-collector date)))
 							     (collector-into-list)
 							     result
@@ -346,15 +356,19 @@
 	      (rpt (category-by-account-report-do-work work progress-range))
 	      (assets (assoc-ref rpt 'asset))
 	      (liabilities (assoc-ref rpt 'liability)))
-	 (set! assets-list (if assets (car assets)
-			       (map (lambda (d) 0) dates-list)))
-	 (set! liability-list (if liabilities (car liabilities)
-				  (map (lambda (d) 0) dates-list)))
+         (set! assets-list (if assets (car assets)
+                               (map (lambda (d)
+                                      (gnc:make-gnc-monetary report-currency (gnc-numeric-zero)))
+                                    dates-list)))
+         (set! liability-list (if liabilities (car liabilities)
+                                  (map (lambda (d)
+                                      (gnc:make-gnc-monetary report-currency (gnc-numeric-zero)))
+                                       dates-list)))
 	 )
 
        (gnc:report-percent-done 80)
        (set! net-list
-             (map + assets-list liability-list))
+             (map monetary+ assets-list liability-list))
        (gnc:report-percent-done 90)
 
        (gnc:html-linechart-set-title!
@@ -379,13 +393,13 @@
        ;; Add the data
        (if show-sep?
            (begin
-             (add-column! assets-list)
+             (add-column! (map monetary->double assets-list))
              (add-column!		      ;;(if inc-exp?
-              (map - liability-list)
+              (map - (map monetary->double liability-list))
               ;;liability-list)
               )))
        (if show-net?
-           (add-column! net-list))
+           (add-column! (map monetary->double net-list)))
 
        ;; Legend labels, colors
        (gnc:html-linechart-set-col-labels!

commit 9c7ba5231526914d922bcaf944fbe379a202e054
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Tue Oct 17 15:09:20 2017 -0600

    report/net-barchart: fix unit test to work with gnc-monetary
    
    The unit test for net-barchart did not initialize html stylesheets.
    Without any stylesheets available, the renderer defaults to a
    trivial renderer. This works fine if the table in the net-barchart
    report is populated by doubles. However, now it is populated by
    gnc-monetary and they need a stylesheet to be properly formatted.
    
    Using doubles and the trivial renderer, a table cell looks like:
    <td class="number-cell"><number> 6.0</td>
    
    Using gnc-monetary and the trivial renderer, a table cell looks like:
    <td class="number-cell"><gnc-monetary> #[unknown]</td>
    
    Initializing the html stylesheets, the table cell looks like:
    <td class="number-cell">$6.00</td>
    
    This commit makes sure to initialize the html stylesheet code in
    the unit test and adapts the parsing code to the new formatting.

diff --git a/gnucash/report/standard-reports/test/test-generic-net-barchart.scm b/gnucash/report/standard-reports/test/test-generic-net-barchart.scm
index 91a1a48..ac475e6 100644
--- a/gnucash/report/standard-reports/test/test-generic-net-barchart.scm
+++ b/gnucash/report/standard-reports/test/test-generic-net-barchart.scm
@@ -25,6 +25,7 @@
 
 (use-modules (gnucash gnc-module))
 (gnc:module-load "gnucash/report/report-system" 0)
+(use-modules (gnucash report stylesheets))
 
 (use-modules (gnucash engine test test-extras))
 (use-modules (gnucash report report-system test test-extras))
@@ -99,11 +100,11 @@
 	  (let* ((result (gnc:html-document-render doc #f))
 		 (tbl (stream->list
 		       (pattern-streamer "<tr>"
-					 (list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
+					 (list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
 						     1 2 3)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1))
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
 					 result))))
 	    (and (= 1 (tbl-ref->number tbl 0 1))
 			 (= 0 (tbl-ref->number tbl 0 2))
@@ -153,11 +154,11 @@
 	  (let* ((result (gnc:html-document-render doc #f))
 		 (tbl (stream->list
 		       (pattern-streamer "<tr>"
-					 (list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
+					 (list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
 						     1 2 3)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1))
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
 					 result))))
 	    (and (every (lambda (row)
 				  (and (equal? (second row) (fourth row))
@@ -207,11 +208,11 @@
 	  (let* ((result (gnc:html-document-render doc #f))
 		 (tbl (stream->list
 		       (pattern-streamer "<tr>"
-					 (list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
+					 (list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
 						     1 2 3)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1))
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
 					 result))))
 	    (and (every (lambda (row)
 				  (and (= (string->number (car (fourth row)))
@@ -263,11 +264,11 @@
 	  (let* ((result (gnc:html-document-render doc #f))
 		 (tbl (stream->list
 		       (pattern-streamer "<tr>"
-					 (list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
+					 (list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
 						     1 2 3)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1))
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
 					 result))))
 	    (and (every (lambda (row)
 				  (and (= (string->number (car (fourth row)))
@@ -328,11 +329,11 @@
 	  (let* ((result (gnc:html-document-render doc #f))
 		 (tbl (stream->list
 		       (pattern-streamer "<tr>"
-					 (list (list "<string> ([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
+					 (list (list "<td>([0-9][0-9])/([0-9][0-9])/([0-9][0-9])</td>"
 						     1 2 3)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1)
-					       (list "<number> ([^<]*)</td>" 1))
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1)
+					       (list "<td class=\"number-cell\">[^0-9]*([^<]*)</td>" 1))
 					 result))))
 	    (and (every (lambda (row)
 				  (and (= (string->number (car (fourth row)))

commit 2fcd1efd6dc1a157143a8e010b9d59de5b628ccd
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Tue Oct 17 14:51:52 2017 -0600

    report/net-barchart: default to list of zeros instead of empty list
    
    This was the original behavior before the change to gnc-monetary.

diff --git a/gnucash/report/standard-reports/net-barchart.scm b/gnucash/report/standard-reports/net-barchart.scm
index 4e82854..83f4890 100644
--- a/gnucash/report/standard-reports/net-barchart.scm
+++ b/gnucash/report/standard-reports/net-barchart.scm
@@ -312,8 +312,14 @@
 	      (rpt (category-by-account-report-do-work work progress-range))
 	      (assets (assoc-ref rpt 'asset))
 	      (liabilities (assoc-ref rpt 'liability)))
-	 (set! assets-list (if assets (car assets) '()))
-	 (set! liability-list (if liabilities (car liabilities) '()))
+	 (set! assets-list (if assets (car assets)
+			       (map (lambda (d)
+				      (gnc:make-gnc-monetary report-currency (gnc:make-gnc-numeric 0 1)))
+				    dates-list)))
+	 (set! liability-list (if liabilities (car liabilities)
+				  (map (lambda (d)
+				      (gnc:make-gnc-monetary report-currency (gnc:make-gnc-numeric 0 1)))
+				    dates-list)))
 	 )
 
        (gnc:report-percent-done 80)

commit 3c8eeb8b3bdb54683fe5a804aa35d87b60693657
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Fri Oct 13 10:40:52 2017 -0600

    report/net-barchart: calculate using gnc-monetary instead of double
    
    Perform and store all calculations using gnc-monetary instead of double.
    Conversion to double is only needed as a last step when adding data
    to the chart (using new function "monetary->double").
    
    When a table is displayed, since the values are gnc-monetary, they are
    properly formatted as monetary values.

diff --git a/gnucash/report/standard-reports/net-barchart.scm b/gnucash/report/standard-reports/net-barchart.scm
index a180983..4e82854 100644
--- a/gnucash/report/standard-reports/net-barchart.scm
+++ b/gnucash/report/standard-reports/net-barchart.scm
@@ -205,26 +205,36 @@
         #f))
 
     ;; This exchanges the commodity-collector 'c' to one single
-    ;; 'report-currency' according to the exchange-fn. Returns a
-    ;; double.
-    (define (collector->double c date)
+    ;; 'report-currency' according to the exchange-fn. Returns a gnc:monetary
+    (define (collector->monetary c date)
       (if (not (gnc:timepair? date))
 	  (throw 'wrong))
-      (gnc-numeric-to-double
-       (gnc:gnc-monetary-amount
-        (gnc:sum-collector-commodity
-         c report-currency
-         (lambda (a b) (exchange-fn a b date))))))
+      (gnc:sum-collector-commodity
+       c report-currency
+       (lambda (a b) (exchange-fn a b date))))
+
+    ;; Add two gnc-monetary objects in the same currency.
+    (define (monetary+ a b)
+      (if (and (gnc:gnc-monetary? a) (gnc:gnc-monetary? b))
+	  (let ((same-currency? (gnc-commodity-equal (gnc:gnc-monetary-commodity a) (gnc:gnc-monetary-commodity b)))
+		(amount (gnc-numeric-add (gnc:gnc-monetary-amount a) (gnc:gnc-monetary-amount b) GNC-DENOM-AUTO GNC-RND-ROUND)))
+	    (if same-currency?
+		(gnc:make-gnc-monetary (gnc:gnc-monetary-commodity a) amount)
+		(warn "incompatible currencies in monetary+: " a b)))
+	  (warn "wrong arguments for monetary+: " a b)))
+
+    (define (monetary->double monetary)
+      (gnc-numeric-to-double (gnc:gnc-monetary-amount monetary)))
 
     ;; This calculates the balances for all the 'accounts' for each
     ;; element of the list 'dates'. If income?==#t, the signs get
     ;; reversed according to income-sign-reverse general option
-    ;; settings. Uses the collector->double conversion function
-    ;; above. Returns a list of doubles.
+    ;; settings. Uses the collector->monetary conversion function
+    ;; above. Returns a list of gnc-monetary.
     (define (process-datelist accounts dates income?)
       (map
        (lambda (date)
-         (collector->double
+         (collector->monetary
           ((if inc-exp?
                (if income?
                    gnc:accounts-get-comm-total-income
@@ -281,14 +291,14 @@
 	      (account-reformat (if inc-exp?
 				    (lambda (account result)
 				      (map (lambda (collector date-interval)
-					     (- (collector->double collector (second date-interval))))
+					     (gnc:monetary-neg (collector->monetary collector (second date-interval))))
 					   result dates-list))
 				    (lambda (account result)
 				      (let ((commodity-collector (gnc:make-commodity-collector)))
 					(collector-end (fold (lambda (next date list-collector)
 							       (commodity-collector 'merge next #f)
 							       (collector-add list-collector
-									      (collector->double
+									      (collector->monetary
 									       commodity-collector date)))
 							     (collector-into-list)
 							     result
@@ -302,15 +312,13 @@
 	      (rpt (category-by-account-report-do-work work progress-range))
 	      (assets (assoc-ref rpt 'asset))
 	      (liabilities (assoc-ref rpt 'liability)))
-	 (set! assets-list (if assets (car assets)
-			       (map (lambda (d) 0) dates-list)))
-	 (set! liability-list (if liabilities (car liabilities)
-				  (map (lambda (d) 0) dates-list)))
+	 (set! assets-list (if assets (car assets) '()))
+	 (set! liability-list (if liabilities (car liabilities) '()))
 	 )
 
        (gnc:report-percent-done 80)
        (set! net-list
-             (map + assets-list liability-list))
+             (map monetary+ assets-list liability-list))
        (gnc:report-percent-done 90)
 
        (gnc:html-barchart-set-title!
@@ -335,13 +343,13 @@
        ;; Add the data
        (if show-sep?
            (begin
-             (add-column! assets-list)
+             (add-column! (map monetary->double assets-list))
              (add-column!		      ;;(if inc-exp?
-              (map - liability-list)
+              (map - (map monetary->double liability-list))
               ;;liability-list)
               )))
        (if show-net?
-           (add-column! net-list))
+           (add-column! (map monetary->double net-list)))
 
        ;; Legend labels, colors
        (gnc:html-barchart-set-col-labels!

commit a8407484094464c0159151d06c2e8be82180ff66
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Oct 31 14:31:00 2017 -0700

    [Gwenhywfar] Use the new getpassword API only on the gwen5 branch.

diff --git a/gnucash/import-export/aqb/gnc-gwen-gui.c b/gnucash/import-export/aqb/gnc-gwen-gui.c
index 682e96e..eebc20a 100644
--- a/gnucash/import-export/aqb/gnc-gwen-gui.c
+++ b/gnucash/import-export/aqb/gnc-gwen-gui.c
@@ -196,7 +196,7 @@ static gint progress_advance_cb(GWEN_GUI *gwen_gui, uint32_t id,
 static gint progress_log_cb(GWEN_GUI *gwen_gui, guint32 id,
                             GWEN_LOGGER_LEVEL level, const gchar *text);
 static gint progress_end_cb(GWEN_GUI *gwen_gui, guint32 id);
-#if GWENHYWFAR_VERSION_INT <= 41700
+#if GWENHYWFAR_VERSION_INT <= 49900
 static gint GNC_GWENHYWFAR_CB getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags,
                                              const gchar *token,
                                              const gchar *title,
@@ -1410,7 +1410,7 @@ progress_end_cb(GWEN_GUI *gwen_gui, guint32 id)
 }
 
 static gint GNC_GWENHYWFAR_CB
-#if GWENHYWFAR_VERSION_INT <= 41700
+#if GWENHYWFAR_VERSION_INT <= 49900
 getpassword_cb(GWEN_GUI *gwen_gui, guint32 flags, const gchar *token,
                const gchar *title, const gchar *text, gchar *buffer,
                gint min_len, gint max_len, guint32 guiid)

commit be44db2ef8ed3b2df2335896a0286dbaa20f7e2c
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Oct 31 12:04:37 2017 -0700

    Provide for report/report-system/test/test-extras to be built before other tests.

diff --git a/gnucash/report/report-system/test/CMakeLists.txt b/gnucash/report/report-system/test/CMakeLists.txt
index 0beae99..897517a 100644
--- a/gnucash/report/report-system/test/CMakeLists.txt
+++ b/gnucash/report/report-system/test/CMakeLists.txt
@@ -20,13 +20,23 @@ GNC_ADD_SCHEME_TESTS(${scm_test_report_system_SOURCES})
 GNC_ADD_SCHEME_TEST(test-load-module-report-system test-load-module.in)
 
 GNC_ADD_SCHEME_TARGETS(scm-test-report-system
-  "${scm_test_report_system_SOURCES};test-extras.scm"
+  "test-extras.scm"
   gnucash/report/report-system/test
   ""
   ""
   ""
   "scm-gnc-module;scm-test-engine;scm-report-system-3"
   FALSE
+  )
+
+GNC_ADD_SCHEME_TARGETS(scm-test-report-system-2
+  "${scm_test_report_system_SOURCES}"
+  gnucash/report/report-system/test
+  ""
+  ""
+  ""
+  "scm-test-report-system"
+  FALSE
 )
 
 CONFIGURE_FILE(test-load-module.in test-load-module @ONLY)

commit cbd87647806ca3700d2ead8a6623b758a07ba2a7
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Oct 31 10:59:12 2017 -0700

    Ensure that report unit tests dependencies are built with  target.

diff --git a/common/cmake_modules/GncAddTest.cmake b/common/cmake_modules/GncAddTest.cmake
index e3df3af..fa8a8c5 100644
--- a/common/cmake_modules/GncAddTest.cmake
+++ b/common/cmake_modules/GncAddTest.cmake
@@ -109,6 +109,13 @@ FUNCTION(GNC_ADD_SCHEME_TEST _TARGET _SOURCE_FILE)
   SET_TESTS_PROPERTIES(${_TARGET} PROPERTIES ENVIRONMENT "${GUILE_ENV};${ARGN}")
 ENDFUNCTION()
 
+FUNCTION(GNC_ADD_SCHEME_TESTS _SOURCE_FILES)
+  FOREACH(test_file ${_SOURCE_FILES})
+    GET_FILENAME_COMPONENT(basename ${test_file} NAME_WE)
+    GNC_ADD_SCHEME_TEST(${basename} ${test_file})
+  ENDFOREACH()
+ENDFUNCTION()
+
 FUNCTION(GNC_GTEST_CONFIGURE)
   MESSAGE(STATUS "Checking for GTEST")
   IF (NOT DEFINED ${GTEST_ROOT})
diff --git a/gnucash/report/report-system/test/CMakeLists.txt b/gnucash/report/report-system/test/CMakeLists.txt
index 0b0a05a..0beae99 100644
--- a/gnucash/report/report-system/test/CMakeLists.txt
+++ b/gnucash/report/report-system/test/CMakeLists.txt
@@ -9,15 +9,18 @@ GNC_ADD_TEST_WITH_GUILE(test-link-module-report-system test-link-module.c
   REPORT_SYSTEM_TEST_INCLUDE_DIRS REPORT_SYSTEM_TEST_LIBS
 )
 
+SET(scm_test_report_system_SOURCES
+  test-collectors.scm
+  test-list-extras.scm
+  test-report-utilities.scm
+# test-test-extras.scm ;;Not run in autotools
+  )
+
+GNC_ADD_SCHEME_TESTS(${scm_test_report_system_SOURCES})
 GNC_ADD_SCHEME_TEST(test-load-module-report-system test-load-module.in)
-GNC_ADD_SCHEME_TEST(test-collectors test-collectors.scm)
-GNC_ADD_SCHEME_TEST(test-list-extras test-list-extras.scm)
-GNC_ADD_SCHEME_TEST(test-report-utilities test-report-utilities.scm)
-# This test is not run in the autotools build.
-#GNC_ADD_SCHEME_TEST(test-test-extras test-test-extras.scm)
 
 GNC_ADD_SCHEME_TARGETS(scm-test-report-system
-  test-extras.scm
+  "${scm_test_report_system_SOURCES};test-extras.scm"
   gnucash/report/report-system/test
   ""
   ""
@@ -29,4 +32,4 @@ GNC_ADD_SCHEME_TARGETS(scm-test-report-system
 CONFIGURE_FILE(test-load-module.in test-load-module @ONLY)
 
 SET_DIST_LIST(test_report_system_DIST CMakeLists.txt Makefile.am test-collectors.scm test-extras.scm test-link-module.c
-        test-load-module.in test-report-utilities.scm test-list-extras.scm)
\ No newline at end of file
+        test-load-module.in test-report-utilities.scm test-list-extras.scm)
diff --git a/gnucash/report/standard-reports/test/CMakeLists.txt b/gnucash/report/standard-reports/test/CMakeLists.txt
index 7be4c9c..6233372 100644
--- a/gnucash/report/standard-reports/test/CMakeLists.txt
+++ b/gnucash/report/standard-reports/test/CMakeLists.txt
@@ -1,22 +1,20 @@
-GNC_ADD_SCHEME_TEST(test-cash-flow test-cash-flow.scm)
-GNC_ADD_SCHEME_TEST(test-cashflow-barchart test-cashflow-barchart.scm)
-GNC_ADD_SCHEME_TEST(test-standard-category-report test-standard-category-report.scm)
-GNC_ADD_SCHEME_TEST(test-standard-net-barchart test-standard-net-barchart.scm)
-GNC_ADD_SCHEME_TEST(test-standard-net-linechart test-standard-net-linechart.scm)
-
 SET(scm_test_standard_reports_SOURCES
+  test-cash-flow.scm
+  test-cashflow-barchart.scm
   test-generic-category-report.scm
   test-generic-net-barchart.scm
   test-generic-net-linechart.scm
 )
 
+GNC_ADD_SCHEME_TESTS(${scm_test_standard_reports_SOURCES})
+
 GNC_ADD_SCHEME_TARGETS(scm-test-standard-reports
   "${scm_test_standard_reports_SOURCES}"
   gnucash/report/standard-reports/test
   ""
   ""
   ""
-  "scm-gnc-module;scm-test-report-system"
+  "scm-gnc-module;scm-test-report-system;scm-standard-reports;scm-report-stylesheets-2"
   FALSE
 )
 

commit 039dda5294e3b103e449247114a733dbf6e47bc8
Merge: 49c7079 41ad891
Author: John Ralls <jralls at ceridwen.us>
Date:   Tue Oct 31 10:20:50 2017 -0700

    Merge J. Marino's cashflow-barchart updates into unstable.


commit 41ad89154ff856b8d53ef6a7e135ba927594e199
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Tue Oct 31 09:59:18 2017 -0600

    report-test: move add-to-load-path to build system
    
    The unit test for cashflow-barchart.scm needs module stylesheets
    to work, to render gnc-monetary objects correctly.
    It makes sense to add the extra load-path needed by the module
    in the build system instead of with code in the test file.
    
    This is only needed when building with autotools. It seems cmake
    builds don't need this.

diff --git a/gnucash/report/standard-reports/test/Makefile.am b/gnucash/report/standard-reports/test/Makefile.am
index 2a4e808..78ebd09 100644
--- a/gnucash/report/standard-reports/test/Makefile.am
+++ b/gnucash/report/standard-reports/test/Makefile.am
@@ -30,6 +30,7 @@ GNC_TEST_DEPS = \
   --guile-load-dir ${top_builddir}/gnucash/report/report-system/test \
   --guile-load-dir ${top_builddir}/gnucash/report/standard-reports \
   --guile-load-dir ${top_builddir}/gnucash/report/standard-reports/test \
+  --guile-load-dir ${top_builddir}/gnucash/report/stylesheets \
 \
   --library-dir    ${top_builddir}/gnucash/report/report-system \
   --library-dir    ${top_builddir}/libgnucash/core-utils \
diff --git a/gnucash/report/standard-reports/test/test-cashflow-barchart.scm b/gnucash/report/standard-reports/test/test-cashflow-barchart.scm
index e4f7dde..481df91 100644
--- a/gnucash/report/standard-reports/test/test-cashflow-barchart.scm
+++ b/gnucash/report/standard-reports/test/test-cashflow-barchart.scm
@@ -29,8 +29,6 @@
 (use-modules (gnucash report report-system))
 (use-modules (gnucash report report-system test test-extras))
 (use-modules (gnucash report standard-reports cashflow-barchart))
-
-(add-to-load-path "../../stylesheets/")
 (use-modules (gnucash report stylesheets))
 
 (use-modules (ice-9 format))

commit 49c70795c39bf75c1999b45d0883fdaf076e1202
Author: John Ralls <jralls at ceridwen.us>
Date:   Mon Oct 30 10:08:07 2017 -0700

    Remove X11 error handler
    
    And with it the only direct X11 dependency.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b12c00f..8704645 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -581,10 +581,6 @@ ENDIF ()
 SET (HAVE_HTMLHELPW 1)
 ENDIF (WIN32)
 
-IF (NOT WIN32)
-CHECK_INCLUDE_FILES (X11/Xlib.h HAVE_X11_XLIB_H)
-ENDIF (NOT WIN32)
-
 CHECK_INCLUDE_FILES (dirent.h HAVE_DIRENT_H)
 CHECK_INCLUDE_FILES (dlfcn.h HAVE_DLFCN_H)
 CHECK_INCLUDE_FILES (glob.h HAVE_GLOB_H)
diff --git a/common/config.h.cmake.in b/common/config.h.cmake.in
index 34e7e9c..200b129 100644
--- a/common/config.h.cmake.in
+++ b/common/config.h.cmake.in
@@ -264,9 +264,6 @@
 /* Define to 1 if you have the <wctype.h> header file. */
 #cmakedefine HAVE_WCTYPE_H 1
 
-/* Define to 1 if you have the <X11/Xlib.h> header file. */
-#cmakedefine HAVE_X11_XLIB_H 1
-
 /* Define to 1 if you have the file `/usr/include/gmock/gmock.h'. */
 #cmakedefine HAVE__USR_INCLUDE_GMOCK_GMOCK_H
 
diff --git a/configure.ac b/configure.ac
index b786758..c77e51b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -486,15 +486,10 @@ AM_CONDITIONAL(PLATFORM_OSX_QUARTZ, test "x$platform" = "xdarwin/quartz")
 AM_CONDITIONAL(PLATFORM_WIN32, test "x$platform" = "xwin32")
 AM_CONDITIONAL(OS_WIN32, test "x$native_win32" = "xyes")
 
-# These are unavailable on windows/mingw32 and X11 isn't desired or
+# These are unavailable on windows/mingw32
 # required for MacOSX Quartz
-if test "x$_gdk_tgt" = xquartz;
-then
-    AC_CHECK_HEADERS(glob.h)
-else
-    AC_CHECK_HEADERS(X11/Xlib.h glob.h)
-fi
-AM_CONDITIONAL(HAVE_X11_XLIB_H, test "x$ac_cv_header_X11_Xlib_h" = "xyes")
+AC_CHECK_HEADERS(glob.h)
+
 AC_CHECK_FUNCS(chown gethostname getppid getuid gettimeofday gmtime_r)
 AC_CHECK_FUNCS(gethostid link)
 ##################################################
diff --git a/gnucash/gnome-utils/Makefile.am b/gnucash/gnome-utils/Makefile.am
index c2ea84f..4cfba43 100644
--- a/gnucash/gnome-utils/Makefile.am
+++ b/gnucash/gnome-utils/Makefile.am
@@ -217,10 +217,6 @@ gnc-warnings.c: gschemas/org.gnucash.warnings.gschema.xml.in make-gnc-warnings-c
 gnc-warnings.h: gschemas/org.gnucash.warnings.gschema.xml.in make-gnc-warnings-h.xsl
 	$(XSLTPROC) -o $@ $(srcdir)/make-gnc-warnings-h.xsl $<
 
-if HAVE_X11_XLIB_H
-  libgncmod_gnome_utils_la_LIBADD += -lX11
-endif
-
 if BUILDING_FROM_VCS
 swig-gnome-utils.c: gnome-utils.i \
                     ${top_srcdir}/common/base-typemaps.i
diff --git a/gnucash/gnome-utils/gnc-gnome-utils.c b/gnucash/gnome-utils/gnc-gnome-utils.c
index 8f931f3..85a934b 100644
--- a/gnucash/gnome-utils/gnc-gnome-utils.c
+++ b/gnucash/gnome-utils/gnc-gnome-utils.c
@@ -24,9 +24,6 @@
 #include <config.h>
 
 #include <glib/gi18n.h>
-#ifdef HAVE_X11_XLIB_H
-# include <X11/Xlib.h>
-#endif
 #include <libxml/xmlIO.h>
 
 #include "gnc-prefs-utils.h"
@@ -640,28 +637,6 @@ gnc_ui_check_events (gpointer not_used)
     return TRUE;
 }
 
-#ifdef HAVE_X11_XLIB_H
-static int
-gnc_x_error (Display *display, XErrorEvent *error)
-{
-    if (error->error_code)
-    {
-        char buf[64];
-
-        XGetErrorText (display, error->error_code, buf, 63);
-
-        g_warning ("X-ERROR **: %s\n  serial %ld error_code %d "
-                   "request_code %d minor_code %d\n",
-                   buf,
-                   error->serial,
-                   error->error_code,
-                   error->request_code,
-                   error->minor_code);
-    }
-
-    return 0;
-}
-#endif
 
 int
 gnc_ui_start_event_loop (void)
@@ -673,10 +648,6 @@ gnc_ui_start_event_loop (void)
     id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 10000, /* 10 secs */
                              gnc_ui_check_events, NULL, NULL);
 
-#ifdef HAVE_X11_XLIB_H
-    XSetErrorHandler (gnc_x_error);
-#endif
-
     /* Enter gnome event loop */
     gtk_main ();
 

commit 5ca2834bd0587e57b32eac77cd8089ca77072b23
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Fri Oct 27 14:53:08 2017 -0600

    cashflow-barchart: split option "show money in/out" into two separate ones
    
    The report had two display options: one to control the display of
    money in/out and another one to control the display of net flow.
    In this commit we split the first option into two separate ones to
    allow toggling the display of money in, out and net independently.

diff --git a/gnucash/report/standard-reports/cashflow-barchart.scm b/gnucash/report/standard-reports/cashflow-barchart.scm
index 3d13d24..6c1d0fa 100644
--- a/gnucash/report/standard-reports/cashflow-barchart.scm
+++ b/gnucash/report/standard-reports/cashflow-barchart.scm
@@ -49,7 +49,8 @@
 (define optname-accounts (N_ "Accounts"))
 (define optname-include-trading-accounts (N_ "Include Trading Accounts in report"))
 ;; Display
-(define optname-show-inout (N_ "Show Money In/Out"))
+(define optname-show-in (N_ "Show Money In"))
+(define optname-show-out (N_ "Show Money Out"))
 (define optname-show-net (N_ "Show Net Flow"))
 (define optname-show-table (N_ "Show Table"))
 (define optname-plot-width (N_ "Plot Width"))
@@ -106,25 +107,31 @@
     (gnc:register-option
      options
      (gnc:make-simple-boolean-option
-      gnc:pagename-display optname-show-inout
-      "a" (N_ "Show money in/out?") #t))
+      gnc:pagename-display optname-show-in
+      "a" (N_ "Show money in?") #t))
+
+    (gnc:register-option
+     options
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-out
+      "b" (N_ "Show money out?") #t))
 
     (gnc:register-option
      options
      (gnc:make-simple-boolean-option
       gnc:pagename-display optname-show-net
-      "b" (N_ "Show net money flow?") #t))
+      "c" (N_ "Show net money flow?") #t))
 
     (gnc:register-option
      options
      (gnc:make-simple-boolean-option
       gnc:pagename-display optname-show-table
-      "c" (N_ "Display a table of the selected data.") #f))
+      "d" (N_ "Display a table of the selected data.") #f))
 
     ;; Plot size options
     (gnc:options-add-plot-size!
      options gnc:pagename-display
-     optname-plot-width optname-plot-height "d" (cons 'percent 100.0) (cons 'percent 100.0))
+     optname-plot-width optname-plot-height "e" (cons 'percent 100.0) (cons 'percent 100.0))
 
     ;; Set the general page as default option tab
     (gnc:options-set-default-section options gnc:pagename-general)
@@ -170,7 +177,8 @@
                        price-source report-currency to-date-tp))
 
          (interval (get-option gnc:pagename-general optname-stepsize))
-         (show-inout? (get-option gnc:pagename-display optname-show-inout))
+         (show-in? (get-option gnc:pagename-display optname-show-in))
+         (show-out? (get-option gnc:pagename-display optname-show-out))
          (show-net? (get-option gnc:pagename-display optname-show-net))
          (show-table? (get-option gnc:pagename-display optname-show-table))
          (height (get-option gnc:pagename-display optname-plot-height))
@@ -281,11 +289,16 @@
            dates-list)
 
           ;; flip result lists (they were built by appending to the front)
-          (set! in-list (reverse in-list))
-          (set! out-list (reverse out-list))
-
-          (set! total-in (apply monetary+ in-list))
-          (set! total-out (apply monetary+ out-list))
+          (if show-in?
+              (begin
+                (set! in-list (reverse in-list))
+                (set! total-in (apply monetary+ in-list))
+                ))
+          (if show-out?
+              (begin
+                (set! out-list (reverse out-list))
+                (set! total-out (apply monetary+ out-list))
+		))
 
           (if show-net?
               (begin
@@ -306,27 +319,26 @@
           (gnc:html-barchart-set-y-axis-label!
            chart (gnc-commodity-get-mnemonic report-currency))
 
-          (if show-inout?
-              (begin
-                (add-column! (map monetary->double in-list))
-                (add-column! (map monetary->double out-list))
-                ))
+          (if show-in?
+              (add-column! (map monetary->double in-list)))
+          (if show-out?
+              (add-column! (map monetary->double out-list)))
           (if show-net?
               (add-column! (map monetary->double net-list)))
 
           ;; Legend labels, colors
           (gnc:html-barchart-set-col-labels!
            chart (append
-                  (if show-inout?
-                      (list (_ "Money In") (_ "Money Out")) '())
-                  (if show-net?
-                      (list (_ "Net Flow")) '())))
+                  (if show-in? (list (_ "Money In")) '())
+                  (if show-out? (list (_ "Money Out")) '())
+                  (if show-net? (list (_ "Net Flow")) '())
+                  ))
           (gnc:html-barchart-set-col-colors!
            chart (append
-                  (if show-inout?
-                      '("blue" "red") '())
-                  (if show-net?
-                      '("green") '())))
+                  (if show-in? '("blue") '())
+                  (if show-out? '("red") '())
+                  (if show-net? '("green") '())
+                  ))
           (gnc:report-percent-done 95)
 
           ;; If we have no data in the plot, display warning message
@@ -342,21 +354,19 @@
               (let* ((table (gnc:make-html-table)))
                 (gnc:html-table-set-col-headers!
                  table (append (list (_ "Date"))
-                               (if show-inout?
-                                   (list (_ "Money In") (_ "Money Out")) '())
-                               (if show-net?
-                                   (list (_ "Net Flow")) '())
+                               (if show-in? (list (_ "Money In")) '())
+                               (if show-out? (list (_ "Money Out")) '())
+                               (if show-net? (list (_ "Net Flow")) '())
                                ))
 
                 (gnc:html-document-add-object!
                  doc (gnc:make-html-text (gnc:html-markup-h3 (_ "Overview:"))))
                 (gnc:html-table-append-column! table (append date-string-list (list "Total")))
 
-                (if show-inout?
-                    (begin
-                      (gnc:html-table-append-column! table (append in-list (list total-in)))
-                      (gnc:html-table-append-column! table (append out-list (list total-out)))
-                      ))
+                (if show-in?
+                    (gnc:html-table-append-column! table (append in-list (list total-in))))
+                (if show-out?
+                    (gnc:html-table-append-column! table (append out-list (list total-out))))
                 (if show-net?
                     (gnc:html-table-append-column! table (append net-list (list total-net))))
 

commit 44df91adcaaa718b97b71cd4d16c13a4c24acc5d
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Fri Oct 27 15:21:57 2017 -0600

    cashflow-barchart: delete unnecessary intermediate lists
    
    These intermediate lists *-value-list hold the double values needed
    by the barchart. We can easily create these lists on the fly,
    there's no need to store them in a separate variable.
    
    The same is done to include total values in the table, we can easily
    append the total value on the fly.

diff --git a/gnucash/report/standard-reports/cashflow-barchart.scm b/gnucash/report/standard-reports/cashflow-barchart.scm
index 439f257..3d13d24 100644
--- a/gnucash/report/standard-reports/cashflow-barchart.scm
+++ b/gnucash/report/standard-reports/cashflow-barchart.scm
@@ -220,9 +220,6 @@
                (total-in #f)
                (total-out #f)
                (total-net #f)
-               (in-value-list #f)
-               (out-value-list #f)
-               (net-value-list #f)
                )
 
           ;; Helper function to convert currencies
@@ -289,15 +286,12 @@
 
           (set! total-in (apply monetary+ in-list))
           (set! total-out (apply monetary+ out-list))
-          (set! in-value-list (map monetary->double in-list))
-          (set! out-value-list (map monetary->double out-list))
 
           (if show-net?
               (begin
                 (set! net-list (reverse net-list))
                 (set! total-net (apply monetary+ net-list))
-                (set! net-value-list (map monetary->double net-list)))
-              )
+                ))
           (gnc:report-percent-done 90)
 
           (gnc:html-barchart-set-title! chart report-title)
@@ -314,11 +308,11 @@
 
           (if show-inout?
               (begin
-                (add-column! in-value-list)
-                (add-column! out-value-list)
+                (add-column! (map monetary->double in-list))
+                (add-column! (map monetary->double out-list))
                 ))
           (if show-net?
-              (add-column! net-value-list))
+              (add-column! (map monetary->double net-list)))
 
           ;; Legend labels, colors
           (gnc:html-barchart-set-col-labels!
@@ -346,12 +340,6 @@
 
           (if (and non-zeros show-table?)
               (let* ((table (gnc:make-html-table)))
-                (set! date-string-list (append date-string-list (list "Total")))
-                (set! in-list (append in-list (list total-in)))
-                (set! out-list (append out-list (list total-out)))
-                (if show-net?
-                    (set! net-list (append net-list (list total-net))))
-
                 (gnc:html-table-set-col-headers!
                  table (append (list (_ "Date"))
                                (if show-inout?
@@ -362,15 +350,15 @@
 
                 (gnc:html-document-add-object!
                  doc (gnc:make-html-text (gnc:html-markup-h3 (_ "Overview:"))))
-                (gnc:html-table-append-column! table date-string-list)
+                (gnc:html-table-append-column! table (append date-string-list (list "Total")))
 
                 (if show-inout?
                     (begin
-                      (gnc:html-table-append-column! table in-list)
-                      (gnc:html-table-append-column! table out-list)
+                      (gnc:html-table-append-column! table (append in-list (list total-in)))
+                      (gnc:html-table-append-column! table (append out-list (list total-out)))
                       ))
                 (if show-net?
-                    (gnc:html-table-append-column! table net-list))
+                    (gnc:html-table-append-column! table (append net-list (list total-net))))
 
                 ;; set numeric columns to align right
                 (for-each

commit 9cb8a3c87abc80be4db2b12ef60faac6405d6071
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Fri Oct 27 14:20:11 2017 -0600

    cashflow-barchart: use direct gnc-monetary math instead of collectors
    
    Operate between gnc-monetary objects instead of using collectors. The
    resulting code is simpler and easier to read.

diff --git a/gnucash/report/standard-reports/cashflow-barchart.scm b/gnucash/report/standard-reports/cashflow-barchart.scm
index 0589a34..439f257 100644
--- a/gnucash/report/standard-reports/cashflow-barchart.scm
+++ b/gnucash/report/standard-reports/cashflow-barchart.scm
@@ -217,12 +217,12 @@
                (in-list '())
                (out-list '())
                (net-list '())
+               (total-in #f)
+               (total-out #f)
+               (total-net #f)
                (in-value-list #f)
                (out-value-list #f)
                (net-value-list #f)
-               (in-total-collector (gnc:make-commodity-collector))
-               (out-total-collector (gnc:make-commodity-collector))
-               (net-total-collector (gnc:make-commodity-collector))
                )
 
           ;; Helper function to convert currencies
@@ -236,6 +236,22 @@
             (gnc:sum-collector-commodity
              collector report-currency exchange-fn)
             )
+
+          ;; Add two or more gnc-monetary objects
+          (define (monetary+ a . blist)
+            (if (null? blist)
+                a
+                (let ((b (apply monetary+ blist)))
+                  (if (and (gnc:gnc-monetary? a) (gnc:gnc-monetary? b))
+                      (let ((same-currency? (gnc-commodity-equal (gnc:gnc-monetary-commodity a) (gnc:gnc-monetary-commodity b)))
+                            (amount (gnc-numeric-add (gnc:gnc-monetary-amount a) (gnc:gnc-monetary-amount b) GNC-DENOM-AUTO GNC-RND-ROUND)))
+                        (if same-currency?
+                            (gnc:make-gnc-monetary (gnc:gnc-monetary-commodity a) amount)
+                            (warn "incompatible currencies in monetary+: " a b)))
+                      (warn "wrong arguments for monetary+: " a b)))
+                )
+            )
+
           ;; Convert gnc:monetary to number (used to generate data for the chart)
           (define (monetary->double monetary)
             (gnc-numeric-to-double (gnc:gnc-monetary-amount monetary))
@@ -257,35 +273,29 @@
                     (result (cashflow-barchart-calc-money-in-out settings))
                     (money-in-collector (cdr (assq 'money-in-collector result)))
                     (money-out-collector (cdr (assq 'money-out-collector result)))
-                    (money-net-collector (gnc:make-commodity-collector))
-                    (money-in-monetary (sum-collector money-in-collector))
-                    (money-out-monetary (sum-collector money-out-collector))
-                    (money-net-monetary #f)
+                    (money-in (sum-collector money-in-collector))
+                    (money-out (sum-collector money-out-collector))
+                    (money-net (monetary+ money-in (gnc:monetary-neg money-out)))
                     )
-               (money-net-collector 'merge money-in-collector #f)
-               (money-net-collector 'minusmerge money-out-collector #f)
-               (set! money-net-monetary (sum-collector money-net-collector))
-               (set! in-list (cons money-in-monetary in-list))
-               (set! out-list (cons money-out-monetary out-list))
-               (set! net-list (cons money-net-monetary net-list))
-               (in-total-collector 'merge money-in-collector #f)
-               (out-total-collector 'merge money-out-collector #f)
+               (set! in-list (cons money-in in-list))
+               (set! out-list (cons money-out out-list))
+               (set! net-list (cons money-net net-list))
                ))
            dates-list)
 
-          (net-total-collector 'merge in-total-collector #f)
-          (net-total-collector 'minusmerge out-total-collector #f)
-
           ;; flip result lists (they were built by appending to the front)
           (set! in-list (reverse in-list))
           (set! out-list (reverse out-list))
 
+          (set! total-in (apply monetary+ in-list))
+          (set! total-out (apply monetary+ out-list))
           (set! in-value-list (map monetary->double in-list))
           (set! out-value-list (map monetary->double out-list))
 
           (if show-net?
               (begin
                 (set! net-list (reverse net-list))
+                (set! total-net (apply monetary+ net-list))
                 (set! net-value-list (map monetary->double net-list)))
               )
           (gnc:report-percent-done 90)
@@ -337,10 +347,10 @@
           (if (and non-zeros show-table?)
               (let* ((table (gnc:make-html-table)))
                 (set! date-string-list (append date-string-list (list "Total")))
-                (set! in-list (append in-list (list (sum-collector in-total-collector))))
-                (set! out-list (append out-list (list (sum-collector out-total-collector))))
+                (set! in-list (append in-list (list total-in)))
+                (set! out-list (append out-list (list total-out)))
                 (if show-net?
-                    (set! net-list (append net-list (list (sum-collector net-total-collector)))))
+                    (set! net-list (append net-list (list total-net))))
 
                 (gnc:html-table-set-col-headers!
                  table (append (list (_ "Date"))

commit 6e3d47819d6f2cefed18b70656320fc50c790962
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Thu Oct 12 15:39:19 2017 -0600

    report: render linechart with requested line colors
    
    A report can specify the bar colors of a barchart with a call to:
       (gnc:html-linechart-set-col-colors! chart (list "blue" "red"))
    However, these colors were ignored when rendering the linechart.
    
    This patch adds the jqplot option "seriesColors" to pass
    the requested bar colors to jqplot. If no colors are requested,
    we let jqplot use default colors by setting "seriesColors: false".

diff --git a/gnucash/report/report-system/html-linechart.scm b/gnucash/report/report-system/html-linechart.scm
index ced16fc..927836f 100644
--- a/gnucash/report/report-system/html-linechart.scm
+++ b/gnucash/report/report-system/html-linechart.scm
@@ -388,8 +388,10 @@
                       (gnc:html-linechart-row-labels linechart)))
          (col-labels (catenate-escaped-strings
                       (gnc:html-linechart-col-labels linechart)))
-         (col-colors (catenate-escaped-strings
-                      (gnc:html-linechart-col-colors linechart)))
+         ;; convert color list to string with valid js array of strings, example: "\"blue\", \"red\""
+         (colors-str (string-join (map (lambda (color)
+                                         (string-append "\"" color "\""))
+                                       (gnc:html-linechart-col-colors linechart)) ", "))
          (line-width (gnc:html-linechart-line-width linechart))
          (series-data-start (lambda (series-index)
                          (push "var d")
@@ -501,7 +503,8 @@
                    cursor: {
                        show: true,
                        zoom: true
-                   }
+                   },
+                   seriesColors: false,
                 };\n")
 
             (push "  options.stackSeries = ")
@@ -546,6 +549,13 @@
                 (push "  options.axes.yaxis.label = \"")
                 (push y-label)
                 (push "\";\n")))
+	    (if (not (equal? colors-str ""))
+                (begin            ; example: options.seriesColors= ["blue", "red"];
+                  (push "options.seriesColors = [")
+                  (push colors-str)
+                  (push "];\n")
+                  )
+                )
 
             ;; adjust the date string format to the one given by the preferences
             (push "  options.axes.xaxis.tickOptions.formatString = '")

commit d6d1549a40d4c1ed0b3aeef62779db24c6c38a28
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Thu Oct 12 15:32:58 2017 -0600

    report: render piechart with requested colors
    
    A report can specify the pie chart colors with a call to:
       (gnc:html-piechart-set-colors! chart (list "blue" "red"))
    However, these colors were ignored when rendering the piechart.
    
    This patch adds the jqplot option "seriesColors" to pass
    the requested colors to jqplot. If no colors are requested,
    we let jqplot use default colors by setting "seriesColors: false".

diff --git a/gnucash/report/report-system/html-piechart.scm b/gnucash/report/report-system/html-piechart.scm
index 0df736a..f8b74a8 100644
--- a/gnucash/report/report-system/html-piechart.scm
+++ b/gnucash/report/report-system/html-piechart.scm
@@ -200,6 +200,10 @@
            (gnc:html-piechart-button-3-legend-urls piechart)))
          (data 
           (ensure-positive-numbers (gnc:html-piechart-data piechart)))
+         ;; convert color list to string with valid js array of strings, example: "\"blue\", \"red\""
+         (colors-str (string-join (map (lambda (color)
+                                         (string-append "\"" color "\""))
+                                       (gnc:html-piechart-colors piechart)) ", "))
          ; Use a unique chart-id for each chart. This prevents chart
          ; clashed on multi-column reports
          (chart-id (string-append "chart-" (number->string (random 999999)))))
@@ -247,6 +251,7 @@
                          show: false },
                     cursor: {
                          showTooltip: false },
+                    seriesColors: false,
                    };\n")
 
             (if title
@@ -259,6 +264,13 @@
                 (push "  options.title += \" (")
                 (push (jqplot-escape-string subtitle))
                 (push ")\";\n")))
+            (if (not (equal? colors-str ""))
+                (begin            ; example: options.seriesColors= ["blue", "red"];
+                  (push "options.seriesColors = [")
+                  (push colors-str)
+                  (push "];\n")
+                  )
+                )
 
             (push "$.jqplot.config.enablePlugins = true;\n")
             (push "$(document).ready(function() {

commit 3926535e67a1f559b67b7e4494bc41c8426387cd
Author: Jose Marino <jmarino at users.noreply.github.com>
Date:   Thu Oct 12 15:11:00 2017 -0600

    report: render barchart with requested bar colors
    
    A report can specify the bar colors of a barchart with a call to:
       (gnc:html-barchart-set-col-colors! chart (list "blue" "red"))
    However, these colors were ignored when rendering the barchart.
    
    This patch adds the jqplot option "seriesColors" to pass
    the requested bar colors to jqplot. If no colors are requested,
    we let jqplot use default colors by setting "seriesColors: false".

diff --git a/gnucash/report/report-system/html-barchart.scm b/gnucash/report/report-system/html-barchart.scm
index be937f6..f172fa1 100644
--- a/gnucash/report/report-system/html-barchart.scm
+++ b/gnucash/report/report-system/html-barchart.scm
@@ -353,8 +353,10 @@
                       (gnc:html-barchart-row-labels barchart)))
          (col-labels (catenate-escaped-strings 
                       (gnc:html-barchart-col-labels barchart)))
-         (col-colors (catenate-escaped-strings 
-                      (gnc:html-barchart-col-colors barchart)))
+         ;; convert color list to string with valid js array of strings, example: "\"blue\", \"red\""
+         (colors-str (string-join (map (lambda (color)
+					 (string-append "\"" color "\""))
+				       (gnc:html-barchart-col-colors barchart)) ", "))
          (series-data-start (lambda (series-index)
                          (push "var d")
                          (push series-index)
@@ -476,6 +478,7 @@
                        showTooltip: false,
                        zoom: true,
                    },
+                   seriesColors: false,
                 };\n")
 
             (push "  options.stackSeries = ")
@@ -506,6 +509,13 @@
                 (push y-label)
                 (push "\";\n")))
             (push "  options.axes.xaxis.ticks = all_ticks;\n")
+            (if (not (equal? colors-str ""))
+                (begin            ; example: options.seriesColors= ["blue", "red"];
+                  (push "options.seriesColors = [")
+                  (push colors-str)
+                  (push "];\n")
+                  )
+                )
 
 
             (push "$.jqplot.config.enablePlugins = true;\n")



Summary of changes:
 CMakeLists.txt                                     |   4 -
 common/cmake_modules/GncAddTest.cmake              |   7 ++
 common/config.h.cmake.in                           |   3 -
 configure.ac                                       |  11 +-
 gnucash/gnome-utils/Makefile.am                    |   4 -
 gnucash/gnome-utils/gnc-gnome-utils.c              |  29 -----
 gnucash/import-export/aqb/gnc-gwen-gui.c           |   4 +-
 gnucash/report/report-system/html-barchart.scm     |  14 ++-
 gnucash/report/report-system/html-linechart.scm    |  16 ++-
 gnucash/report/report-system/html-piechart.scm     |  12 ++
 gnucash/report/report-system/test/CMakeLists.txt   |  27 ++--
 .../report/standard-reports/cashflow-barchart.scm  | 140 +++++++++++----------
 .../report/standard-reports/category-barchart.scm  | 101 ++++++++++-----
 gnucash/report/standard-reports/net-barchart.scm   |  52 +++++---
 gnucash/report/standard-reports/net-linechart.scm  |  56 +++++----
 .../report/standard-reports/test/CMakeLists.txt    |  12 +-
 gnucash/report/standard-reports/test/Makefile.am   |   1 +
 .../test/test-cashflow-barchart.scm                |   2 -
 .../test/test-generic-category-report.scm          |  23 ++--
 .../test/test-generic-net-barchart.scm             |  41 +++---
 .../test/test-generic-net-linechart.scm            |  25 ++--
 21 files changed, 334 insertions(+), 250 deletions(-)



More information about the gnucash-changes mailing list