gnucash maint: Multiple changes pushed

Christopher Lam clam at code.gnucash.org
Tue Jun 18 11:30:23 EDT 2019


Updated	 via  https://github.com/Gnucash/gnucash/commit/c3cf5e28 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a44a1a4c (commit)
	 via  https://github.com/Gnucash/gnucash/commit/d16b1380 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a1ad9da0 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3b187a12 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a33302f1 (commit)
	from  https://github.com/Gnucash/gnucash/commit/410ae957 (commit)



commit c3cf5e28089c06ca9b946cdc001d47a2c58887a9
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Jun 18 22:23:01 2019 +0800

    Deprecate unused code related to gnc:colspans-are-working-right
    
    colspans code has never been fixed. remove unused code.

diff --git a/gnucash/report/report-system/html-acct-table.scm b/gnucash/report/report-system/html-acct-table.scm
index cee71871d..b013351df 100644
--- a/gnucash/report/report-system/html-acct-table.scm
+++ b/gnucash/report/report-system/html-acct-table.scm
@@ -497,7 +497,9 @@
 
 ;; this is to work around a bug in the HTML export sytmem
 ;; which causes COLSPAN= attributes not to be exported (!!)
-(define gnc:colspans-are-working-right #f)
+(define gnc:colspans-are-working-right
+  ;; should be deprecated
+  #f)
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;  <html-acct-table> class
@@ -928,14 +930,6 @@
     (traverse-accounts! toplvl-accts 0 0
                         (calculate-balances accounts start-date end-date get-balance-fn))
     
-    ;; set the column-header colspan
-    (if gnc:colspans-are-working-right
-	(if (gnc:html-table-cell? column-header)
-	    (gnc:html-table-cell-set-colspan! column-header
-					      (+ disp-depth-reached 1 indent))
-	    )
-	)
-    
     ;; now set the account-colspan entries
     ;; he he... (let ((x 0)) (while (< x 5) (display x) (set! x (+ x 1))))
     ;; now I know how to loop in scheme... yay!
@@ -1094,13 +1088,9 @@
          amount-colspan    ;; defaults to one
          amount-markup)    ;; optional
   (let* ((lbl-depth (or label-depth 0))
-	 (lbl-colspan (if gnc:colspans-are-working-right
-			  (or label-colspan 1)
-			  1))
+	 (lbl-colspan 1)
 	 (amt-depth (or amount-depth (+ lbl-depth lbl-colspan)))
-	 (amt-colspan (if gnc:colspans-are-working-right
-			  (or amount-colspan 1)
-			  1))
+	 (amt-colspan 1)
 	 (tbl-width (or table-width (+ amt-depth amt-colspan)))
 	 (row
 	  (append
diff --git a/gnucash/report/standard-reports/balance-sheet.scm b/gnucash/report/standard-reports/balance-sheet.scm
index d3d2b2e3b..807ebb5e7 100644
--- a/gnucash/report/standard-reports/balance-sheet.scm
+++ b/gnucash/report/standard-reports/balance-sheet.scm
@@ -733,8 +733,6 @@
 	  (gnc:report-percent-done 100)
 	  
 	  ;; if sending the report to a file, do so now
-	  ;; however, this still doesn't seem to get around the
-	  ;; colspan bug... cf. gnc:colspans-are-working-right
 	  (if filename
 	      (let* ((port (open-output-file filename)))
                 (gnc:display-report-list-item
diff --git a/gnucash/report/standard-reports/budget-balance-sheet.scm b/gnucash/report/standard-reports/budget-balance-sheet.scm
index 0948bdef0..7adad833c 100644
--- a/gnucash/report/standard-reports/budget-balance-sheet.scm
+++ b/gnucash/report/standard-reports/budget-balance-sheet.scm
@@ -903,8 +903,6 @@
 	  (gnc:report-percent-done 100)
 	  
 	  ;; if sending the report to a file, do so now
-	  ;; however, this still doesn't seem to get around the
-	  ;; colspan bug... cf. gnc:colspans-are-working-right
 	  (if filename
 	      (let* ((port (open-output-file filename)))
                 (gnc:display-report-list-item
diff --git a/gnucash/report/standard-reports/equity-statement.scm b/gnucash/report/standard-reports/equity-statement.scm
index a687bd074..2309be610 100644
--- a/gnucash/report/standard-reports/equity-statement.scm
+++ b/gnucash/report/standard-reports/equity-statement.scm
@@ -683,8 +683,6 @@
 	  (gnc:report-percent-done 100)
 	  
 	  ;; if sending the report to a file, do so now
-	  ;; however, this still doesn't seem to get around the
-	  ;; colspan bug... cf. gnc:colspans-are-working-right
 	  (if filename
 	      (let* ((port (open-output-file filename)))
                 (gnc:display-report-list-item
diff --git a/gnucash/report/standard-reports/trial-balance.scm b/gnucash/report/standard-reports/trial-balance.scm
index 4f6c8c7da..397c6259c 100644
--- a/gnucash/report/standard-reports/trial-balance.scm
+++ b/gnucash/report/standard-reports/trial-balance.scm
@@ -714,31 +714,17 @@
 		(set! parent-headings
 		      (apply append
 			     (map
-			      (if gnc:colspans-are-working-right
-				  (lambda (heading)
-				    (list 
-				     (gnc:make-html-table-cell/size/markup
-				      1 2 "th" heading)
-				     )
-				    )
-				  (lambda (heading)
-				    (list
-				     (gnc:make-html-table-cell/size/markup
-				      1 1 "th" heading)
-				     (gnc:html-make-empty-cell)
-				     )
-				    )
-				  )
+                              (lambda (heading)
+				(list
+				 (gnc:make-html-table-cell/size/markup 1 1 "th" heading)
+				 (gnc:html-make-empty-cell)))
 			      headings)
 			     )
 		      )
 		(gnc:html-table-append-row!
 		 build-table
 		 (append
-		  (if gnc:colspans-are-working-right
-		      (list (gnc:make-html-table-cell/size 1 account-cols #f))
-		      (gnc:html-make-empty-cells account-cols)
-		      )
+                  (gnc:html-make-empty-cells account-cols)
 		  parent-headings)
 		 )
 		(set! header-rows (+ header-rows 1))
@@ -1187,11 +1173,7 @@
 		 build-table
 		 "primary-subheading"
 		 (append
-		  (if gnc:colspans-are-working-right
-		      (list (gnc:make-html-table-cell/size
-			     1 (+ account-cols (* 2 is-col)) #f))
-		      (gnc:html-make-empty-cells (+ account-cols (* 2 is-col)))
-		      )
+                  (gnc:html-make-empty-cells (+ account-cols (* 2 is-col)))
 		  (list
 		   (tot-abs-amt-cell (if is-credit? tot-is is-debits))
 		   (tot-abs-amt-cell (if is-credit? is-credits tot-is))
@@ -1217,8 +1199,6 @@
 	  (gnc:report-percent-done 100)
 	  
 	  ;; if sending the report to a file, do so now
-	  ;; however, this still doesn't seem to get around the
-	  ;; colspan bug... cf. gnc:colspans-are-working-right
 	  (if filename
 	      (let* ((port (open-output-file filename)))
                 (gnc:display-report-list-item

commit a44a1a4c2339011a5e686ec74bf1b3738748d31d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Jun 18 08:03:28 2019 +0800

    Deprecate unused function gnc:second-html-build-acct-table
    
    and ensure gnc:html-build-acct-table is redefined to the former
    gnc:first-html-build-acct-table, and gnc:first-html-build-acct-table
    redirects to gnc:html-build-acct-table.
    
    It would seem gnc:second-html-build-acct-table has never been used.

diff --git a/gnucash/report/report-system/html-acct-table.scm b/gnucash/report/report-system/html-acct-table.scm
index af818217d..cee71871d 100644
--- a/gnucash/report/report-system/html-acct-table.scm
+++ b/gnucash/report/report-system/html-acct-table.scm
@@ -1373,6 +1373,8 @@
   ;; presently unimplemented.  many of these functions are better left
   ;; to the renderer, anyway.  but if you *really* need them, you may
   ;; still use gnc:first-html-build-acct-table.
+  (issue-deprecation-warning
+   "gnc:second-html-build-acct-table is unused. use gnc:html-build-acct-table.")
   (let* ((env (list
 	       (list 'start-date start-date)
 	       (list 'end-date end-date)
diff --git a/gnucash/report/report-system/html-utilities.scm b/gnucash/report/report-system/html-utilities.scm
index f5160e5c1..5aa6663a8 100644
--- a/gnucash/report/report-system/html-utilities.scm
+++ b/gnucash/report/report-system/html-utilities.scm
@@ -388,6 +388,12 @@
 ;; <int> start-percent, delta-percent: Fill in the [start:start+delta]
 ;; section of the progress bar while running this function.
 ;;
+
+(define (gnc:first-html-build-acct-table . args)
+  (issue-deprecation-warning
+   "gnc:first-html-build-acct-table is deprecated. use gnc:html-build-acct-table.")
+  (apply gnc:html-build-acct-table args))
+
 (define (gnc:html-build-acct-table 
 	 start-date end-date 
 	 tree-depth show-subaccts? accounts 
@@ -396,37 +402,6 @@
 	 show-total? get-total-fn
 	 total-name group-types? show-parent-balance? show-parent-total? 
 	 show-other-curr? report-commodity exchange-fn show-zero-entries?)
-  ;; Select, here, which version of gnc:html-build-acct-table you want
-  ;; to use by default.
-  (define fn-version 'first)
-  (if (equal? fn-version 'second)
-      (gnc:second-html-build-acct-table 
-       start-date end-date 
-       tree-depth show-subaccts? accounts 
-       start-percent delta-percent
-       show-col-headers?
-       show-total? get-total-fn
-       total-name group-types? show-parent-balance? show-parent-total? 
-       show-other-curr? report-commodity exchange-fn show-zero-entries?)
-      (gnc:first-html-build-acct-table 
-       start-date end-date 
-       tree-depth show-subaccts? accounts 
-       start-percent delta-percent
-       show-col-headers?
-       show-total? get-total-fn
-       total-name group-types? show-parent-balance? show-parent-total? 
-       show-other-curr? report-commodity exchange-fn show-zero-entries?)
-      )
-  )
-
-(define (gnc:first-html-build-acct-table 
-	 start-date end-date 
-	 tree-depth show-subaccts? accounts 
-	 start-percent delta-percent
-	 show-col-headers?
-	 show-total? get-total-fn
-	 total-name group-types? show-parent-balance? show-parent-total? 
-	 show-other-curr? report-commodity exchange-fn show-zero-entries?)
   (let ((table (gnc:make-html-table))
 	(work-to-do 0)
 	(work-done 0)

commit d16b1380c592f7e56fb9315bba91e9e133dee5a3
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Jun 18 22:19:40 2019 +0800

    [html-acct-table] Further deprecate unused functions

diff --git a/gnucash/report/report-system/html-acct-table.scm b/gnucash/report/report-system/html-acct-table.scm
index 6fa5f2fd3..af818217d 100644
--- a/gnucash/report/report-system/html-acct-table.scm
+++ b/gnucash/report/report-system/html-acct-table.scm
@@ -989,6 +989,7 @@
   (gnc:html-table-num-rows (gnc:_html-acct-table-matrix_ acct-table)))
 
 (define (gnc:html-acct-table-num-cols acct-table)
+  (issue-deprecation-warning "gnc:html-acct-table-num-cols is unused.")
   (- (gnc:html-table-num-columns (gnc:_html-acct-table-matrix_ acct-table)) 1))
 
 (define (gnc:html-acct-table-get-cell acct-table row col)
@@ -1015,6 +1016,7 @@
   (gnc:html-acct-table-set-cell! acct-table row -1 env))
 
 (define (gnc:html-acct-table-append-row! acct-table newrow)
+  (issue-deprecation-warning "gnc:html-acct-table-append-row! is unused.")
   (gnc:html-table-append-row!
    (gnc:_html-acct-table-matrix_ acct-table)
    (map
@@ -1022,6 +1024,7 @@
     newrow)))
 
 (define (gnc:html-acct-table-prepend-row! acct-table newrow)
+  (issue-deprecation-warning "gnc:html-acct-table-prepend-row! is unused.")
   (gnc:html-table-prepend-row!
    (gnc:_html-acct-table-matrix_ acct-table)
    (map
@@ -1029,6 +1032,7 @@
     newrow)))
 
 (define (gnc:html-acct-table-append-col! acct-table newcol)
+  (issue-deprecation-warning "gnc:html-acct-table-append-col! is unused.")
   (gnc:html-table-append-col!
    (gnc:_html-acct-table-matrix_ acct-table)
    (map
@@ -1036,6 +1040,7 @@
     newcol)))
 
 (define (gnc:html-acct-table-prepend-col! acct-table newrow)
+  (issue-deprecation-warning "gnc:html-acct-table-prepend-col! is unused.")
   (gnc:html-table-prepend-col!
    (gnc:_html-acct-table-matrix_ acct-table)
    (map
@@ -1043,15 +1048,14 @@
     newcol)))
 
 (define (gnc:html-acct-table-remove-last-row! acct-table)
+  (issue-deprecation-warning "gnc:html-acct-table-remove-last-row! is unused.")
   (gnc:html-table-remove-last-row! (gnc:_html-acct-table-matrix_ acct-table)))
 
-;; don't think we need this.
-;;(define (gnc:identity i) i)
-
 (define (gnc:html-acct-table-render acct-table doc)
   ;; this will be used if we ever decide to let the utility object
   ;; render a document by calling thunks registered in the row-envs...
   ;; but, for now, this (optional) feature is left unimplemented...
+  (issue-deprecation-warning "gnc:html-acct-table-render is unused.")
   #f
   )
 

commit a1ad9da03ff5062d79f789e8be42326aa466adba
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jun 17 22:14:17 2019 +0800

    Bug 797277 - Assets over time ignores nested liabilities
    
    This is caused by the omission of selected accounts' descendant
    accounts during generation of accounts-balances-alist.
    
    The subsequent function account->balance-list was querying the
    accounts-balances-alist for subaccounts' (of any account-type)
    balances but these were missing.
    
    This commit ensures all selected accounts (whose types depended on the
    chart-type), and all their descendant accounts (of any account-type)
    were scanned to generate the account-balances-list.

diff --git a/gnucash/report/standard-reports/category-barchart.scm b/gnucash/report/standard-reports/category-barchart.scm
index ae3a6ab88..43ba7acb2 100644
--- a/gnucash/report/standard-reports/category-barchart.scm
+++ b/gnucash/report/standard-reports/category-barchart.scm
@@ -373,7 +373,10 @@ developing over time"))
                                     (not (xaccTransGetIsClosingTxn
                                           (xaccSplitGetParent s))))
                                 (xaccSplitGetAmount s))))))))
-             accounts))
+             ;; all selected accounts (of report-specific type), *and*
+             ;; their descendants (of any type) need to be scanned.
+             (delete-duplicates
+              (append accounts (gnc:acccounts-get-all-subaccounts accounts)))))
 
           ;; Creates the <balance-list> to be used in the function
           ;; below.

commit 3b187a1282da0783bc3e4888ed4143cd1d5886e9
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Tue Jun 18 22:54:12 2019 +0800

    [html-utilities] tighten code
    
    using list-ref and length repeatedly is usually less efficient than
    testing against null?

diff --git a/gnucash/report/report-system/html-utilities.scm b/gnucash/report/report-system/html-utilities.scm
index 202651211..f5160e5c1 100644
--- a/gnucash/report/report-system/html-utilities.scm
+++ b/gnucash/report/report-system/html-utilities.scm
@@ -122,13 +122,11 @@
                             "#F012BE" "#3D9970" "#39CCCC" "#f39c12"
                             "#e74c3c" "#e67e22" "#9b59b6" "#8e44ad"
                             "#16a085" "#d35400"))
-  (define (assign-colors i)
-    (if (<= num-colors i)
-        '()
-        (cons (list-ref base-colors
-                        (modulo i (length base-colors)))
-              (assign-colors (+ i 1)))))
-  (assign-colors 0))
+  (let lp ((i 0) (result '()) (colors base-colors))
+    (cond
+     ((>= num-colors i) (reverse result))
+     ((null? colors)    (lp (1+ i) (cons (car colors) result) base-colors))
+     (else              (lp (1+ i) (cons (car colors) result) (cdr colors))))))
 
 ;; Appends a horizontal ruler to a html-table with the specified
 ;; colspan at, optionally, the specified column.
@@ -183,9 +181,6 @@
 	 table tree-depth
 	 current-depth my-name my-balance 
 	 reverse-balance? row-style boldface? group-header-line?)
-  ;; just a stupid little helper
-  (define (identity a)
-    a)
   (gnc:html-table-append-row/markup! 
    table
    row-style

commit a33302f1e6897cd69316e2926273df4377647476
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Jun 15 08:49:35 2019 +0800

    [trep-engine] addendum forgot to close file-port in 497e18c36
    
    we can use call-with-input-file which automatically closes file port
    when lambda is completed.

diff --git a/gnucash/report/standard-reports/test/test-transaction.scm b/gnucash/report/standard-reports/test/test-transaction.scm
index 4e1efcdda..8f23333d4 100644
--- a/gnucash/report/standard-reports/test/test-transaction.scm
+++ b/gnucash/report/standard-reports/test/test-transaction.scm
@@ -883,13 +883,14 @@
                (renderer (gnc:report-template-renderer template)))
           ;; run the renderer, ignore its output. we'll query the csv export.
           (renderer report #:export-type 'csv #:filename "/tmp/export.csv"))
-        (let ((f (open-file "/tmp/export.csv" "r")))
-          (let lp ((c (read-char f)) (out '()))
-            (if (eof-object? c)
-                (string=?
-                 "\"from\",\"01/01/69\"\n\"to\",\"12/31/70\"\n\"Amount (GBP)\",2.15\n\"Amount\",3.0"
-                 (reverse-list->string out))
-                (lp (read-char f) (cons c out)))))))
+        (let ((call-with-input-file "/tmp/export.csv"))
+          (lambda (f)
+            (let lp ((c (read-char f)) (out '()))
+              (if (eof-object? c)
+                  (string=?
+                   "\"from\",\"01/01/69\"\n\"to\",\"12/31/70\"\n\"Amount (GBP)\",2.15\n\"Amount\",3.0"
+                   (reverse-list->string out))
+                  (lp (read-char f) (cons c out))))))))
     (test-end "csv-export")))
 
 (define (reconcile-tests)



Summary of changes:
 gnucash/report/report-system/html-acct-table.scm   | 32 ++++++-------
 gnucash/report/report-system/html-utilities.scm    | 52 +++++-----------------
 gnucash/report/standard-reports/balance-sheet.scm  |  2 -
 .../standard-reports/budget-balance-sheet.scm      |  2 -
 .../report/standard-reports/category-barchart.scm  |  5 ++-
 .../report/standard-reports/equity-statement.scm   |  2 -
 .../standard-reports/test/test-transaction.scm     | 15 ++++---
 gnucash/report/standard-reports/trial-balance.scm  | 32 +++----------
 8 files changed, 43 insertions(+), 99 deletions(-)



More information about the gnucash-changes mailing list