gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Sat Dec 5 10:59:17 EST 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/424676c3 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d2f1cc0e (commit)
	from  https://github.com/Gnucash/gnucash/commit/9fb38e53 (commit)



commit 424676c31a5527a3d7bb7429ee0e4b7db2adad7e
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 5 05:45:56 2020 +0800

    [report-utilities] centralise gnc:not-all-zeros
    
    it is used by old chart module *and* reports

diff --git a/gnucash/report/html-barchart.scm b/gnucash/report/html-barchart.scm
index 76e2a10ab..6671e9c1a 100644
--- a/gnucash/report/html-barchart.scm
+++ b/gnucash/report/html-barchart.scm
@@ -249,17 +249,6 @@
        (set! rownum (+ 1 rownum)))
      newcol)))
 
-(define (gnc:not-all-zeros data)
-  (define (myor list)
-    (begin 
-      (gnc:debug "list" list)
-      (if (null? list) #f
-	  (or (car list) (myor (cdr list))))))
-
-  (cond ((number? data) (not (= 0 data)))
-	((list? data) (myor (map gnc:not-all-zeros data)))
-	(else #f)))
-
 (define (gnc:html-barchart-prepend-column! barchart newcol)
   (let ((rows (gnc:html-barchart-data barchart))
         (this-row #f)
diff --git a/gnucash/report/html-linechart.scm b/gnucash/report/html-linechart.scm
index faf3ec2de..56135e051 100644
--- a/gnucash/report/html-linechart.scm
+++ b/gnucash/report/html-linechart.scm
@@ -304,17 +304,6 @@
        (set! rownum (+ 1 rownum)))
      newcol)))
 
-(define (gnc:not-all-zeros data)
-  (define (myor list)
-    (begin
-      (gnc:debug "list" list)
-      (if (null? list) #f
-	  (or (car list) (myor (cdr list))))))
-
-  (cond ((number? data) (not (= 0 data)))
-	((list? data) (myor (map gnc:not-all-zeros data)))
-	(else #f)))
-
 (define (gnc:html-linechart-prepend-column! linechart newcol)
   (let ((rows (gnc:html-linechart-data linechart))
         (this-row #f)
diff --git a/gnucash/report/html-piechart.scm b/gnucash/report/html-piechart.scm
index fb6f3a3e6..2bc56d1dc 100644
--- a/gnucash/report/html-piechart.scm
+++ b/gnucash/report/html-piechart.scm
@@ -151,14 +151,6 @@
 (define gnc:html-piechart-set-button-3-legend-urls!
   (record-modifier <html-piechart> 'button-3-legend-urls))
 
-(define (gnc:not-all-zeros data)
-  (define (myor list)
-    (if (null? list) #f
-        (or (car list) (myor (cdr list)))))
-  (cond ((number? data) (not (= 0 data)))
-	((list? data) (myor (map gnc:not-all-zeros data)))
-	(else #f)))
-
 (define (gnc:html-piechart-render piechart doc)
   (let* ((chart (gnc:make-html-chart))
          (title (gnc:html-piechart-title piechart))
diff --git a/gnucash/report/html-scatter.scm b/gnucash/report/html-scatter.scm
index d16f92569..77ebf5aa8 100644
--- a/gnucash/report/html-scatter.scm
+++ b/gnucash/report/html-scatter.scm
@@ -132,14 +132,6 @@
        scatter
        (cons newpoint (gnc:html-scatter-data scatter)))))
 
-(define (gnc:not-all-zeros data)
-  (define (myor list)
-    (if (null? list) #f
-        (or (car list) (myor (cdr list)))))
-  (cond ((number? data) (not (= 0 data)))
-	((list? data) (myor (map gnc:not-all-zeros data)))
-	(else #f)))
-
 ;; The Renderer
 (define (gnc:html-scatter-render scatter doc)
   (let* ((chart (gnc:make-html-chart))
diff --git a/gnucash/report/report-utilities.scm b/gnucash/report/report-utilities.scm
index d3eb1d69d..5ec7f65f9 100644
--- a/gnucash/report/report-utilities.scm
+++ b/gnucash/report/report-utilities.scm
@@ -974,6 +974,12 @@ query instead.")
 
 ;; ***************************************************************************
 
+(define (gnc:not-all-zeros data)
+  (cond
+   ((number? data) (not (= 0 data)))
+   ((pair? data) (any gnc:not-all-zeros data))
+   (else #f)))
+
 ;; Adds "file:///" to the beginning of a URL if it doesn't already exist
 ;;
 ;; @param url URL

commit d2f1cc0e379cfcf7bece0c2373613aa67ccb9a02
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Dec 5 05:43:43 2020 +0800

    [report-utilities] test gnc:not-all-zeros

diff --git a/gnucash/report/test/test-report-utilities.scm b/gnucash/report/test/test-report-utilities.scm
index 7cb732581..2d1437a13 100644
--- a/gnucash/report/test/test-report-utilities.scm
+++ b/gnucash/report/test/test-report-utilities.scm
@@ -521,6 +521,26 @@
       5
       (gnc:get-current-account-tree-depth))
 
+    (test-equal "gnc:not-all-zeros #t"
+      #t
+      (gnc:not-all-zeros '((((((1 2 3) 3 5 6 ((4 8))) (2 3)) (3 4 (5)))))))
+
+    (test-equal "gnc:not-all-zeros #f"
+      #f
+      (gnc:not-all-zeros '((((((0 0 0) 0 0 0 ((0 0))) (0 0)) (0 0 (0)))))))
+
+    (test-equal "gnc:not-all-zeros #f"
+      #f
+      (gnc:not-all-zeros 'sym))
+
+    (test-equal "gnc:not-all-zeros #f"
+      #f
+      (gnc:not-all-zeros '()))
+
+    (test-equal "gnc:not-all-zeros #t"
+      #t
+      (gnc:not-all-zeros '(1)))
+
     (test-equal "gnc:accounts-and-all-descendants"
       (list (account-lookup "GBP Bank")
             (account-lookup "GBP Savings")



Summary of changes:
 gnucash/report/html-barchart.scm              | 11 -----------
 gnucash/report/html-linechart.scm             | 11 -----------
 gnucash/report/html-piechart.scm              |  8 --------
 gnucash/report/html-scatter.scm               |  8 --------
 gnucash/report/report-utilities.scm           |  6 ++++++
 gnucash/report/test/test-report-utilities.scm | 20 ++++++++++++++++++++
 6 files changed, 26 insertions(+), 38 deletions(-)



More information about the gnucash-changes mailing list