gnucash maint: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Mon Jun 4 08:09:48 EDT 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/06808469 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/aeb25313 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5093a8fb (commit)
	 via  https://github.com/Gnucash/gnucash/commit/0dc9a115 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/5532de04 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/7927597b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/39e97604 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/03b57e51 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/879ec75f (commit)
	 via  https://github.com/Gnucash/gnucash/commit/e9535bfa (commit)
	 via  https://github.com/Gnucash/gnucash/commit/aafd46a4 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/98964f7a (commit)
	from  https://github.com/Gnucash/gnucash/commit/eb67baba (commit)



commit 06808469d0a1c2483f18760a7b025abd4d57fdba
Merge: aeb2531 5093a8f
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Mon Jun 4 13:44:42 2018 +0200

    Merge branch 'maint-eradicate-gtkhtml' of https://github.com/christopherlam/gnucash into maint


commit aeb2531350b296bf6a4b8215915aba58062a5cf6
Merge: eb67bab 0dc9a11
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Mon Jun 4 11:46:46 2018 +0200

    Merge branch 'maint-scheme-more-progress' of https://github.com/christopherlam/gnucash into maint


commit 5093a8fb141e4df3bf2fad3b7757047b992d1693
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jun 4 11:01:23 2018 +0800

    [webkit] eradicate gtkhtml in .scm
    
    This commit does away with anything gtkhtml related. Some variables eg
    css? must remain because they're used later on.

diff --git a/gnucash/report/business-reports/balsheet-eg.eguile.scm b/gnucash/report/business-reports/balsheet-eg.eguile.scm
index 1bcec52..c7a91f1 100644
--- a/gnucash/report/business-reports/balsheet-eg.eguile.scm
+++ b/gnucash/report/business-reports/balsheet-eg.eguile.scm
@@ -153,9 +153,6 @@
 
 </head>
 <body>
-<?scm (if (not css?) (begin ?>
-  <table border="0" cellpadding="16"><tr><td> <!-- hack for GTKHTML -->
-<?scm )) ?>
 <h3><?scm:d coyname ?></h3>
 <h2><?scm:d reportname ?> <?scm:d (qof-print-date opt-date) ?></h2>
 
@@ -314,10 +311,6 @@
 <br clear="both">
 <p><?scm:d opt-extra-notes ?>
 
-<?scm (if (not css?) (begin ?>
-  </table> <!-- hack for GTKHTML -->
-<?scm )) ?>
-
 </body>
 </html>
 
diff --git a/gnucash/report/business-reports/balsheet-eg.scm b/gnucash/report/business-reports/balsheet-eg.scm
index d5717a9..d1b5cf2 100644
--- a/gnucash/report/business-reports/balsheet-eg.scm
+++ b/gnucash/report/business-reports/balsheet-eg.scm
@@ -433,8 +433,6 @@
          ;; XXX I haven't found a way to get the book for which the report was opened here
          (coyname (or (gnc:company-info (gnc-get-current-book) gnc:*company-name*) ""))
 
-         (css? (gnc-html-engine-supports-css))
-
          (html #f))
 
     ;; end of all the lets.  time for some real code
@@ -458,8 +456,7 @@
 
     (define (foreignstyle item)
       ;; apply styling for amount in foreign currency
-      (if css?
-        (string-append "<span class=\"foreign\">" item "</span>"))
+        (string-append "<span class=\"foreign\">" item "</span>")
         (string-append "<small><i>" item "</i></small>"))
 
     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -671,13 +668,7 @@
     (set! html (eguile-file-to-string opt-template-file (the-environment)))
     (gnc:debug "balsheet-eg.scm - generated html:") (gnc:debug html)
     (gnc:report-finished)
-    (if css? ; return report as document or html, depending on version
-      html
-      (let ((document (gnc:make-html-document)))
-        (gnc:html-document-add-object! document html)
-        document))
-
-    ))
+    html))
 
 (gnc:define-report
   'version 1
diff --git a/gnucash/report/business-reports/receipt.scm b/gnucash/report/business-reports/receipt.scm
index 6ee7250..9fb8614 100644
--- a/gnucash/report/business-reports/receipt.scm
+++ b/gnucash/report/business-reports/receipt.scm
@@ -240,22 +240,14 @@
          (opt-amount-due-heading    (opt-value headingpage2 optname-amount-due))
          (opt-payment-recd-heading  (opt-value headingpage2 optname-payment-recd))
          (opt-extra-notes           (opt-value notespage    optname-extra-notes))
-         (css? #t) ;(and (defined? 'gnc-html-engine-supports-css) (gnc-html-engine-supports-css)))
-         (html #f))
-
-    (set! html (eguile-file-to-string
+         (css? #t)
+         (html (eguile-file-to-string
                  opt-template-file
-                 (the-environment)))
+                 (the-environment))))
 
-    (gnc:debug "receipt.scm: css? is " css?)
-    (gnc:debug "receipt.scm: defined is " (defined? 'gnc-html-engine-supports-css))
     (gnc:debug "receipt.scm - generated html:") (gnc:debug html)
 
-    (if css? ; return report as document or html, depending on version
-      html
-      (let ((document (gnc:make-html-document)))
-        (gnc:html-document-add-object! document html)
-        document))))
+    html))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Define the report
diff --git a/gnucash/report/business-reports/taxinvoice.scm b/gnucash/report/business-reports/taxinvoice.scm
index 054b18f..fe94e64 100644
--- a/gnucash/report/business-reports/taxinvoice.scm
+++ b/gnucash/report/business-reports/taxinvoice.scm
@@ -306,22 +306,14 @@
          (opt-jobname-text          (opt-value headingpage2 optname-jobname-text))
          (opt-extra-css             (opt-value notespage    optname-extra-css)) 
          (opt-extra-notes           (opt-value notespage    optname-extra-notes)) 
-         (css? #t) ;(and (defined? 'gnc-html-engine-supports-css) (gnc-html-engine-supports-css)))
-         (html #f))
-
-    (set! html (eguile-file-to-string 
+         (css? #t)
+         (html (eguile-file-to-string
                  opt-template-file
-                 (the-environment)))
+                 (the-environment))))
 
-    (gnc:debug "taxinvoice.scm: css? is " css?)
-    (gnc:debug "taxinvoice.scm: defined is " (defined? 'gnc-html-engine-supports-css))
     (gnc:debug "taxinvoice.scm - generated html:") (gnc:debug html)
 
-    (if css? ; return report as document or html, depending on version 
-      html 
-      (let ((document (gnc:make-html-document)))
-        (gnc:html-document-add-object! document html)
-        document))))
+    html))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Define the report
diff --git a/gnucash/report/locale-specific/us/taxtxf.scm b/gnucash/report/locale-specific/us/taxtxf.scm
index 76325de..f8d0818 100644
--- a/gnucash/report/locale-specific/us/taxtxf.scm
+++ b/gnucash/report/locale-specific/us/taxtxf.scm
@@ -104,7 +104,7 @@
 
 (use-modules (gnucash core-utils)) ; for gnc:version
 
-(gnc:module-load "gnucash/html" 0)   ; added for 'gnc-html-engine-supports-css'
+(gnc:module-load "gnucash/html" 0)
 (gnc:module-load "gnucash/tax/us" 0)
 (gnc:module-load "gnucash/report/report-system" 0)
 
@@ -262,13 +262,7 @@
            (list 'conv-to-report-date (N_ "Nearest report date") (N_ "Use nearest to report date.")))
     )))
 
-  (if (gnc-html-engine-supports-css)
-      #t
-      (gnc:register-tax-option
-       (gnc:make-simple-boolean-option
-        gnc:pagename-display (N_ "Shade alternate transactions")
-        "n" (N_ "Shade background of alternate transactions, if more than one displayed.") #f))
-  )
+  #t
 
   (gnc:options-set-default-section options gnc:pagename-general)
 
@@ -2063,10 +2057,7 @@
                                      "Do not print Action:Memo data")
                                     (get-option gnc:pagename-display
                                      "Do not print T-Num:Memo data")))
-         (shade-alternate-transactions? (if (gnc-html-engine-supports-css)
-                                            #t
-                                            (get-option gnc:pagename-display
-                                               "Shade alternate transactions")))
+         (shade-alternate-transactions? #t)
          (currency-conversion-date (get-option gnc:pagename-display
                                  "Currency conversion date"))
          (user-sel-accnts (get-option gnc:pagename-accounts
@@ -3058,7 +3049,7 @@
               #f) ;;end of if
           #f) ;;end of if
           (begin  ; else do tax report
-             (if (gnc-html-engine-supports-css)
+             (if #t                     ;does gcn-html-engine-support-css? #t!
                  (begin ;; this is for webkit
                   (gnc:html-document-set-style!
                    doc "header-just-top"
@@ -3101,65 +3092,6 @@
                    'tag "td"
                    'attribute (list "class" "number-cell neg")
                    'attribute (list "valign" "bottom"))
-                 )
-                 (begin ;; this is for gtkhtml
-                  (gnc:html-document-set-style!
-                   doc "header-just-top"
-                   'tag "th"
-                   'attribute (list "align" "left")
-                   'attribute (list "valign" "top"))
-
-                  (gnc:html-document-set-style!
-                   doc "header-just-bot"
-                   'tag "th"
-                   'attribute (list "align" "left")
-                   'attribute (list "valign" "bottom"))
-
-                  (gnc:html-document-set-style!
-                   doc "column-heading-center"
-                   'tag "th"
-                   'attribute (list "align" "center")
-                   'attribute (list "valign" "bottom"))
-
-                  (gnc:html-document-set-style!
-                   doc "tran-detail"
-                   'tag "tr"
-                   'attribute (list "valign" "top"))
-
-                  (gnc:html-document-set-style!
-                   doc "tran-detail-shade"
-                   'tag "tr"
-                   'attribute (list "valign" "top")
-                   'attribute (list "bgcolor" "grey"))
-
-                  (gnc:html-document-set-style!
-                   doc "column-heading-right"
-                   'tag "th"
-                   'attribute (list "align" "right"))
-
-                  (gnc:html-document-set-style!
-                   doc "text-cell-center"
-                   'tag "td"
-                   'attribute (list "align" "center"))
-
-                  (gnc:html-document-set-style!
-                   doc "number-cell-bot"
-                   'tag "td"
-                   'attribute (list "align" "right")
-                   'attribute (list "nowrap" "nowrap")
-                   'attribute (list "valign" "bottom"))
-
-                  (gnc:html-document-set-style!
-                   doc "number-cell-bot-neg"
-                   'tag "td"
-                   'attribute (list "align" "right")
-                   'attribute (list "nowrap" "nowrap")
-                   'attribute (list "valign" "bottom"))
-
-                  (gnc:html-document-set-style!
-                   doc "date-cell"
-                   'tag "td"
-                   'attribute (list "nowrap" "nowrap"))
                  ))
 
              (gnc:html-document-set-style!
@@ -3469,10 +3401,7 @@
                              ;; currency conversion date
                              "      ~a <br/>"
                              ;; alternate transaction shading
-                             (if (gnc-html-engine-supports-css)
-                                 ""
-                                 "      ~a <br/>"
-                             ))
+                             "")
                              (if (not (null? user-sel-accnts))
                                  "Subset of accounts"
                                  "No accounts (none = all accounts)")
@@ -3501,11 +3430,6 @@
                                          'conv-to-tran-date)
                                  "PriceDB lookups nearest to transaction date"
                                  "PriceDB lookups nearest to report end date")
-                             (if (not (gnc-html-engine-supports-css))
-                                 (if shade-alternate-transactions?
-                                     "Shade alternate transactions"
-                                     "Do not shade alternate transactions")
-                             )
                           )
                         ))))
 
diff --git a/gnucash/report/report-system/html-document.scm b/gnucash/report/report-system/html-document.scm
index e9c77e8..8325da6 100644
--- a/gnucash/report/report-system/html-document.scm
+++ b/gnucash/report/report-system/html-document.scm
@@ -140,7 +140,6 @@
                (push (lambda (l) (set! retval (cons l retval))))
                (objs (gnc:html-document-objects doc))
                (work-to-do (length objs))
-               (css? (gnc-html-engine-supports-css))
                (work-done 0)
                (title (gnc:html-document-title doc)))
           ;; compile the doc style
@@ -160,9 +159,8 @@
                 (push "<html>\n")
                 (push "<head>\n")
                 (push "<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />\n")
-                (if css?
-                  (if style-text
-                    (push (list "</style>" style-text "<style type=\"text/css\">\n"))))
+                (if style-text
+                    (push (list "</style>" style-text "<style type=\"text/css\">\n")))
                 (let ((title (gnc:html-document-title doc)))
                   (if title
                       (push (list "</title>" title "<title>\n"))))
diff --git a/gnucash/report/stylesheets/stylesheet-easy.scm b/gnucash/report/stylesheets/stylesheet-easy.scm
index 8f6f9b2..c380acd 100644
--- a/gnucash/report/stylesheets/stylesheet-easy.scm
+++ b/gnucash/report/stylesheets/stylesheet-easy.scm
@@ -33,7 +33,7 @@
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
 
-(gnc:module-load "gnucash/html" 0)   ; added for 'gnc-html-engine-supports-css'
+(gnc:module-load "gnucash/html" 0)
 (gnc:module-load "gnucash/report/report-system" 0)
 
 (define (easy-options)
@@ -227,143 +227,70 @@
 ;;;;
 ;;;;
 ;;;;
-    (if (gnc-html-engine-supports-css)
-        (begin ;; this is for webkit
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-left"
-             'tag "th"
-             'attribute (list "class" "column-heading-left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-center"
-             'tag "th"
-             'attribute (list "class" "column-heading-center"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-right"
-             'tag "th"
-             'attribute (list "class" "column-heading-right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "date-cell"
-             'tag "td"
-             'attribute (list "class" "date-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "anchor-cell"
-             'tag "td"
-             'attribute (list "class" "anchor-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell"
-             'tag "td"
-             'attribute (list "class" "number-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell-neg"
-             'tag "td"
-             'attribute (list "class" "number-cell neg"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-header"
-             'tag "th"
-             'attribute (list "class" "number-header"))
-
-          (gnc:html-document-set-style!
-             ssdoc "text-cell"
-             'tag "td"
-             'attribute (list "class" "text-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell"
-             'tag '("td")
-             'attribute (list "class" "total-number-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell-neg"
-             'tag '("td")
-             'attribute (list "class" "total-number-cell neg"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-label-cell"
-             'tag '("td")
-             'attribute (list "class" "total-label-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "centered-label-cell"
-             'tag '("td")
-             'attribute (list "class" "centered-label-cell"))
-        )
-        (begin ;; this is for gtkhtml
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-left"
-             'tag "th"
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-center"
-             'tag "th"
-             'attribute (list "align" "center"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-right"
-             'tag "th"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "date-cell"
-             'tag "td"
-             'attribute (list "nowrap" "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "anchor-cell"
-             'tag "td"
-             'attribute (list "align" "left")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell"
-             'tag "td"
-             'attribute (list "align" "right")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell-neg"
-             'tag "td"
-             'attribute (list "align" "right")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-header"
-             'tag "th"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "text-cell"
-             'tag "td"
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell"
-             'tag '("td")
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell-neg"
-             'tag '("td")
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-label-cell"
-             'tag '("td")
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "centered-label-cell"
-             'tag '("td")
-             'attribute (list "align" "center"))
-        )
-    )
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-left"
+     'tag "th"
+     'attribute (list "class" "column-heading-left"))
+
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-center"
+     'tag "th"
+     'attribute (list "class" "column-heading-center"))
+
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-right"
+     'tag "th"
+     'attribute (list "class" "column-heading-right"))
+
+    (gnc:html-document-set-style!
+     ssdoc "date-cell"
+     'tag "td"
+     'attribute (list "class" "date-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "anchor-cell"
+     'tag "td"
+     'attribute (list "class" "anchor-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-cell"
+     'tag "td"
+     'attribute (list "class" "number-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-cell-neg"
+     'tag "td"
+     'attribute (list "class" "number-cell neg"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-header"
+     'tag "th"
+     'attribute (list "class" "number-header"))
+
+    (gnc:html-document-set-style!
+     ssdoc "text-cell"
+     'tag "td"
+     'attribute (list "class" "text-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-number-cell"
+     'tag '("td")
+     'attribute (list "class" "total-number-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-number-cell-neg"
+     'tag '("td")
+     'attribute (list "class" "total-number-cell neg"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-label-cell"
+     'tag '("td")
+     'attribute (list "class" "total-label-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "centered-label-cell"
+     'tag '("td")
+     'attribute (list "class" "centered-label-cell"))
 
     (if (and bgpixmap
 	     (not (string=? bgpixmap "")))
diff --git a/gnucash/report/stylesheets/stylesheet-fancy.scm b/gnucash/report/stylesheets/stylesheet-fancy.scm
index 902e21c..2ea37d3 100644
--- a/gnucash/report/stylesheets/stylesheet-fancy.scm
+++ b/gnucash/report/stylesheets/stylesheet-fancy.scm
@@ -27,7 +27,7 @@
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
 
-(gnc:module-load "gnucash/html" 0)   ; added for 'gnc-html-engine-supports-css'
+(gnc:module-load "gnucash/html" 0)
 (gnc:module-load "gnucash/report/report-system" 0)
 
 (define (fancy-options)
@@ -222,143 +222,70 @@
 ;;;;
 ;;;;
 ;;;;
-    (if (gnc-html-engine-supports-css)
-        (begin ;; this is for webkit
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-left"
-             'tag "th"
-             'attribute (list "class" "column-heading-left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-center"
-             'tag "th"
-             'attribute (list "class" "column-heading-center"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-right"
-             'tag "th"
-             'attribute (list "class" "column-heading-right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "date-cell"
-             'tag "td"
-             'attribute (list "class" "date-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "anchor-cell"
-             'tag "td"
-             'attribute (list "class" "anchor-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell"
-             'tag "td"
-             'attribute (list "class" "number-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell-neg"
-             'tag "td"
-             'attribute (list "class" "number-cell neg"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-header"
-             'tag "th"
-             'attribute (list "class" "number-header"))
-
-          (gnc:html-document-set-style!
-             ssdoc "text-cell"
-             'tag "td"
-             'attribute (list "class" "text-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell"
-             'tag '("td")
-             'attribute (list "class" "total-number-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell-neg"
-             'tag '("td")
-             'attribute (list "class" "total-number-cell neg"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-label-cell"
-             'tag '("td")
-             'attribute (list "class" "total-label-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "centered-label-cell"
-             'tag '("td")
-             'attribute (list "class" "centered-label-cell"))
-        )
-        (begin ;; this is for gtkhtml
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-left"
-             'tag "th"
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-center"
-             'tag "th"
-             'attribute (list "align" "center"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-right"
-             'tag "th"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "date-cell"
-             'tag "td"
-             'attribute (list "nowrap" "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "anchor-cell"
-             'tag "td"
-             'attribute (list "align" "left")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell"
-             'tag "td"
-             'attribute (list "align" "right")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell-neg"
-             'tag "td"
-             'attribute (list "align" "right")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-header"
-             'tag "th"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "text-cell"
-             'tag "td"
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell"
-             'tag '("td")
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell-neg"
-             'tag '("td")
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-label-cell"
-             'tag '("td")
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "centered-label-cell"
-             'tag '("td")
-             'attribute (list "align" "center"))
-        )
-    )
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-left"
+     'tag "th"
+     'attribute (list "class" "column-heading-left"))
+
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-center"
+     'tag "th"
+     'attribute (list "class" "column-heading-center"))
+
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-right"
+     'tag "th"
+     'attribute (list "class" "column-heading-right"))
+
+    (gnc:html-document-set-style!
+     ssdoc "date-cell"
+     'tag "td"
+     'attribute (list "class" "date-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "anchor-cell"
+     'tag "td"
+     'attribute (list "class" "anchor-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-cell"
+     'tag "td"
+     'attribute (list "class" "number-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-cell-neg"
+     'tag "td"
+     'attribute (list "class" "number-cell neg"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-header"
+     'tag "th"
+     'attribute (list "class" "number-header"))
+
+    (gnc:html-document-set-style!
+     ssdoc "text-cell"
+     'tag "td"
+     'attribute (list "class" "text-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-number-cell"
+     'tag '("td")
+     'attribute (list "class" "total-number-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-number-cell-neg"
+     'tag '("td")
+     'attribute (list "class" "total-number-cell neg"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-label-cell"
+     'tag '("td")
+     'attribute (list "class" "total-label-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "centered-label-cell"
+     'tag '("td")
+     'attribute (list "class" "centered-label-cell"))
 
     (if (and bgpixmap
 	     (not (string=? bgpixmap "")))
diff --git a/gnucash/report/stylesheets/stylesheet-footer.scm b/gnucash/report/stylesheets/stylesheet-footer.scm
index afb41f1..37a198a 100644
--- a/gnucash/report/stylesheets/stylesheet-footer.scm
+++ b/gnucash/report/stylesheets/stylesheet-footer.scm
@@ -38,7 +38,7 @@
 (use-modules (gnucash gnc-module))
 (use-modules (gnucash gettext))
 
-(gnc:module-load "gnucash/html" 0)   ; added for 'gnc-html-engine-supports-css'
+(gnc:module-load "gnucash/html" 0)
 (gnc:module-load "gnucash/report/report-system" 0)
 
 (define (footer-options)
@@ -241,143 +241,70 @@
 ;;;;
 ;;;;
 ;;;;
-    (if (gnc-html-engine-supports-css)
-        (begin ;; this is for webkit
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-left"
-             'tag "th"
-             'attribute (list "class" "column-heading-left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-center"
-             'tag "th"
-             'attribute (list "class" "column-heading-center"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-right"
-             'tag "th"
-             'attribute (list "class" "column-heading-right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "date-cell"
-             'tag "td"
-             'attribute (list "class" "date-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "anchor-cell"
-             'tag "td"
-             'attribute (list "class" "anchor-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell"
-             'tag "td"
-             'attribute (list "class" "number-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell-neg"
-             'tag "td"
-             'attribute (list "class" "number-cell neg"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-header"
-             'tag "th"
-             'attribute (list "class" "number-header"))
-
-          (gnc:html-document-set-style!
-             ssdoc "text-cell"
-             'tag "td"
-             'attribute (list "class" "text-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell"
-             'tag '("td")
-             'attribute (list "class" "total-number-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell-neg"
-             'tag '("td")
-             'attribute (list "class" "total-number-cell neg"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-label-cell"
-             'tag '("td")
-             'attribute (list "class" "total-label-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "centered-label-cell"
-             'tag '("td")
-             'attribute (list "class" "centered-label-cell"))
-        )
-        (begin ;; this is for gtkhtml
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-left"
-             'tag "th"
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-center"
-             'tag "th"
-             'attribute (list "align" "center"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-right"
-             'tag "th"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "date-cell"
-             'tag "td"
-             'attribute (list "nowrap" "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "anchor-cell"
-             'tag "td"
-             'attribute (list "align" "left")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell"
-             'tag "td"
-             'attribute (list "align" "right")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell-neg"
-             'tag "td"
-             'attribute (list "align" "right")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-header"
-             'tag "th"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "text-cell"
-             'tag "td"
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell"
-             'tag '("td")
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell-neg"
-             'tag '("td")
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-label-cell"
-             'tag '("td")
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "centered-label-cell"
-             'tag '("td")
-             'attribute (list "align" "center"))
-        )
-    )
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-left"
+     'tag "th"
+     'attribute (list "class" "column-heading-left"))
+
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-center"
+     'tag "th"
+     'attribute (list "class" "column-heading-center"))
+
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-right"
+     'tag "th"
+     'attribute (list "class" "column-heading-right"))
+
+    (gnc:html-document-set-style!
+     ssdoc "date-cell"
+     'tag "td"
+     'attribute (list "class" "date-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "anchor-cell"
+     'tag "td"
+     'attribute (list "class" "anchor-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-cell"
+     'tag "td"
+     'attribute (list "class" "number-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-cell-neg"
+     'tag "td"
+     'attribute (list "class" "number-cell neg"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-header"
+     'tag "th"
+     'attribute (list "class" "number-header"))
+
+    (gnc:html-document-set-style!
+     ssdoc "text-cell"
+     'tag "td"
+     'attribute (list "class" "text-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-number-cell"
+     'tag '("td")
+     'attribute (list "class" "total-number-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-number-cell-neg"
+     'tag '("td")
+     'attribute (list "class" "total-number-cell neg"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-label-cell"
+     'tag '("td")
+     'attribute (list "class" "total-label-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "centered-label-cell"
+     'tag '("td")
+     'attribute (list "class" "centered-label-cell"))
 
     (if (and bgpixmap
 	     (not (string=? bgpixmap "")))
diff --git a/gnucash/report/stylesheets/stylesheet-head-or-tail.scm b/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
index d78e931..f6a279c 100644
--- a/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
+++ b/gnucash/report/stylesheets/stylesheet-head-or-tail.scm
@@ -40,7 +40,7 @@
 (use-modules (gnucash core-utils)) ; for gnc:version
 (use-modules (gnucash gettext))
 
-(gnc:module-load "gnucash/html" 0)   ; added for 'gnc-html-engine-supports-css'
+(gnc:module-load "gnucash/html" 0)
 (gnc:module-load "gnucash/report/report-system" 0)
 
 (define (head-or-tail-options)
@@ -306,143 +306,70 @@
 ;;;;
 ;;;;
 ;;;;
-    (if (gnc-html-engine-supports-css)
-        (begin ;; this is for webkit
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-left"
-             'tag "th"
-             'attribute (list "class" "column-heading-left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-center"
-             'tag "th"
-             'attribute (list "class" "column-heading-center"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-right"
-             'tag "th"
-             'attribute (list "class" "column-heading-right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "date-cell"
-             'tag "td"
-             'attribute (list "class" "date-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "anchor-cell"
-             'tag "td"
-             'attribute (list "class" "anchor-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell"
-             'tag "td"
-             'attribute (list "class" "number-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell-neg"
-             'tag "td"
-             'attribute (list "class" "number-cell neg"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-header"
-             'tag "th"
-             'attribute (list "class" "number-header"))
-
-          (gnc:html-document-set-style!
-             ssdoc "text-cell"
-             'tag "td"
-             'attribute (list "class" "text-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell"
-             'tag '("td")
-             'attribute (list "class" "total-number-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell-neg"
-             'tag '("td")
-             'attribute (list "class" "total-number-cell neg"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-label-cell"
-             'tag '("td")
-             'attribute (list "class" "total-label-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "centered-label-cell"
-             'tag '("td")
-             'attribute (list "class" "centered-label-cell"))
-        )
-        (begin ;; this is for gtkhtml
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-left"
-             'tag "th"
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-center"
-             'tag "th"
-             'attribute (list "align" "center"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-right"
-             'tag "th"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "date-cell"
-             'tag "td"
-             'attribute (list "nowrap" "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "anchor-cell"
-             'tag "td"
-             'attribute (list "align" "left")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell"
-             'tag "td"
-             'attribute (list "align" "right")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell-neg"
-             'tag "td"
-             'attribute (list "align" "right")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-header"
-             'tag "th"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "text-cell"
-             'tag "td"
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell"
-             'tag '("td")
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell-neg"
-             'tag '("td")
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-label-cell"
-             'tag '("td")
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "centered-label-cell"
-             'tag '("td")
-             'attribute (list "align" "center"))
-        )
-    )
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-left"
+     'tag "th"
+     'attribute (list "class" "column-heading-left"))
+
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-center"
+     'tag "th"
+     'attribute (list "class" "column-heading-center"))
+
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-right"
+     'tag "th"
+     'attribute (list "class" "column-heading-right"))
+
+    (gnc:html-document-set-style!
+     ssdoc "date-cell"
+     'tag "td"
+     'attribute (list "class" "date-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "anchor-cell"
+     'tag "td"
+     'attribute (list "class" "anchor-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-cell"
+     'tag "td"
+     'attribute (list "class" "number-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-cell-neg"
+     'tag "td"
+     'attribute (list "class" "number-cell neg"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-header"
+     'tag "th"
+     'attribute (list "class" "number-header"))
+
+    (gnc:html-document-set-style!
+     ssdoc "text-cell"
+     'tag "td"
+     'attribute (list "class" "text-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-number-cell"
+     'tag '("td")
+     'attribute (list "class" "total-number-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-number-cell-neg"
+     'tag '("td")
+     'attribute (list "class" "total-number-cell neg"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-label-cell"
+     'tag '("td")
+     'attribute (list "class" "total-label-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "centered-label-cell"
+     'tag '("td")
+     'attribute (list "class" "centered-label-cell"))
 
     (if (and bgpixmap
 	     (not (string=? bgpixmap "")))
diff --git a/gnucash/report/stylesheets/stylesheet-plain.scm b/gnucash/report/stylesheets/stylesheet-plain.scm
index 7a60ac4..511f00d 100644
--- a/gnucash/report/stylesheets/stylesheet-plain.scm
+++ b/gnucash/report/stylesheets/stylesheet-plain.scm
@@ -31,7 +31,7 @@
 (use-modules (srfi srfi-13))
 (use-modules (srfi srfi-14))
 
-(gnc:module-load "gnucash/html" 0)   ; added for 'gnc-html-engine-supports-css'
+(gnc:module-load "gnucash/html" 0)
 (gnc:module-load "gnucash/report/report-system" 0)
 
 ;; plain style sheet
@@ -123,143 +123,70 @@
        'attribute (list "cellspacing" spacing)
        'attribute (list "cellpadding" padding))
 
-    (if (gnc-html-engine-supports-css)
-        (begin ;; this is for webkit
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-left"
-             'tag "th"
-             'attribute (list "class" "column-heading-left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-center"
-             'tag "th"
-             'attribute (list "class" "column-heading-center"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-right"
-             'tag "th"
-             'attribute (list "class" "column-heading-right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "date-cell"
-             'tag "td"
-             'attribute (list "class" "date-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "anchor-cell"
-             'tag "td"
-             'attribute (list "class" "anchor-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell"
-             'tag "td"
-             'attribute (list "class" "number-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell-neg"
-             'tag "td"
-             'attribute (list "class" "number-cell neg"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-header"
-             'tag "th"
-             'attribute (list "class" "number-header"))
-
-          (gnc:html-document-set-style!
-             ssdoc "text-cell"
-             'tag "td"
-             'attribute (list "class" "text-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell"
-             'tag "td"
-             'attribute (list "class" "total-number-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell-neg"
-             'tag "td"
-             'attribute (list "class" "total-number-cell neg"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-label-cell"
-             'tag "td"
-             'attribute (list "class" "total-label-cell"))
-
-          (gnc:html-document-set-style!
-             ssdoc "centered-label-cell"
-             'tag "td"
-             'attribute (list "class" "centered-label-cell"))
-        )
-        (begin ;; this is for gtkhtml
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-left"
-             'tag "th"
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-center"
-             'tag "th"
-             'attribute (list "align" "center"))
-
-          (gnc:html-document-set-style!
-             ssdoc "column-heading-right"
-             'tag "th"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "date-cell"
-             'tag "td"
-             'attribute (list "nowrap" "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "anchor-cell"
-             'tag "td"
-             'attribute (list "align" "left")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell"
-             'tag "td"
-             'attribute (list "align" "right")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-cell-neg"
-             'tag "td"
-             'attribute (list "align" "right")
-             'attribute (list "nowrap"))
-
-          (gnc:html-document-set-style!
-             ssdoc "number-header"
-             'tag "th"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "text-cell"
-             'tag "td"
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell"
-             'tag "td"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-number-cell-neg"
-             'tag "td"
-             'attribute (list "align" "right"))
-
-          (gnc:html-document-set-style!
-             ssdoc "total-label-cell"
-             'tag "td"
-             'attribute (list "align" "left"))
-
-          (gnc:html-document-set-style!
-             ssdoc "centered-label-cell"
-             'tag "td"
-             'attribute (list "align" "center"))
-        )
-    )
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-left"
+     'tag "th"
+     'attribute (list "class" "column-heading-left"))
+
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-center"
+     'tag "th"
+     'attribute (list "class" "column-heading-center"))
+
+    (gnc:html-document-set-style!
+     ssdoc "column-heading-right"
+     'tag "th"
+     'attribute (list "class" "column-heading-right"))
+
+    (gnc:html-document-set-style!
+     ssdoc "date-cell"
+     'tag "td"
+     'attribute (list "class" "date-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "anchor-cell"
+     'tag "td"
+     'attribute (list "class" "anchor-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-cell"
+     'tag "td"
+     'attribute (list "class" "number-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-cell-neg"
+     'tag "td"
+     'attribute (list "class" "number-cell neg"))
+
+    (gnc:html-document-set-style!
+     ssdoc "number-header"
+     'tag "th"
+     'attribute (list "class" "number-header"))
+
+    (gnc:html-document-set-style!
+     ssdoc "text-cell"
+     'tag "td"
+     'attribute (list "class" "text-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-number-cell"
+     'tag "td"
+     'attribute (list "class" "total-number-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-number-cell-neg"
+     'tag "td"
+     'attribute (list "class" "total-number-cell neg"))
+
+    (gnc:html-document-set-style!
+     ssdoc "total-label-cell"
+     'tag "td"
+     'attribute (list "class" "total-label-cell"))
+
+    (gnc:html-document-set-style!
+     ssdoc "centered-label-cell"
+     'tag "td"
+     'attribute (list "class" "centered-label-cell"))
 
     (gnc:html-document-set-style!
        ssdoc "normal-row"

commit 0dc9a115017b4608e87ffb9a36734ac01079cb8a
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Jun 2 16:46:05 2018 +0800

    [html-table] compact html-table-append-row!

diff --git a/gnucash/report/report-system/html-table.scm b/gnucash/report/report-system/html-table.scm
index 66c273e..41a615f 100644
--- a/gnucash/report/report-system/html-table.scm
+++ b/gnucash/report/report-system/html-table.scm
@@ -339,16 +339,12 @@
     
 
 (define (gnc:html-table-append-row! table newrow)
-  (let* ((dd (gnc:html-table-data table))
-	 (current-num-rows (gnc:html-table-num-rows table))
-	 (new-num-rows (+ current-num-rows 1)))
-    (if (list? newrow)
-        (set! dd (cons newrow dd))
-        (set! dd (cons (list newrow) dd)))
-    (gnc:html-table-set-num-rows-internal! 
-     table 
-     new-num-rows)
-    (gnc:html-table-set-data! table dd)
+  (let* ((current-num-rows (gnc:html-table-num-rows table))
+	 (new-num-rows (1+ current-num-rows)))
+    (gnc:html-table-set-num-rows-internal! table new-num-rows)
+    (gnc:html-table-set-data! table
+                              (cons (if (list? newrow) newrow (list newrow))
+                                    (gnc:html-table-data table)))
     new-num-rows))
 
 (define (gnc:html-table-remove-last-row! table)

commit 5532de0481888701432d592d396fbcc8a3138855
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Jun 2 16:43:31 2018 +0800

    [html-table] use srfi-1

diff --git a/gnucash/report/report-system/html-table.scm b/gnucash/report/report-system/html-table.scm
index 2f224e3..66c273e 100644
--- a/gnucash/report/report-system/html-table.scm
+++ b/gnucash/report/report-system/html-table.scm
@@ -326,14 +326,7 @@
   (record-modifier <html-table> 'num-rows))
 
 (define (gnc:html-table-num-columns table)
-  (let ((max 0))
-    (for-each 
-     (lambda (row)
-       (let ((l (length row))) 
-         (if (> l max)
-             (set! max l))))
-     (gnc:html-table-data table))
-    max))
+  (apply max (map length (gnc:html-table-data table))))
 
 (define (gnc:html-table-append-row/markup! table markup newrow)
   (let ((rownum (gnc:html-table-append-row! table newrow)))

commit 7927597b3a7e043a9993f5af5d33222f09886f82
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Jun 2 16:25:58 2018 +0800

    [html-table] gnc:html-table-set-row-style! uses cons*
    
    This cons* call creates a pair-terminated list.

diff --git a/gnucash/report/report-system/html-table.scm b/gnucash/report/report-system/html-table.scm
index 157dcdc..2f224e3 100644
--- a/gnucash/report/report-system/html-table.scm
+++ b/gnucash/report/report-system/html-table.scm
@@ -746,8 +746,5 @@
     retval))
 
 (define (gnc:html-table-set-last-row-style! table tag . rest)
-  (let ((arg-list
-         (cons table
-               (cons (1- (gnc:html-table-num-rows table))
-                     (cons tag rest)))))
-    (apply gnc:html-table-set-row-style! arg-list)))
+  (apply gnc:html-table-set-row-style!
+         (cons* table (1- (gnc:html-table-num-rows table)) tag rest)))

commit 39e976045b72e6d3cac178dc9db970b08b13bdb7
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sat Jun 2 16:25:41 2018 +0800

    [html-table] unused gnc:html-table-merge
    
    This function is not used through code.

diff --git a/gnucash/report/report-system/html-table.scm b/gnucash/report/report-system/html-table.scm
index 405e4ad..157dcdc 100644
--- a/gnucash/report/report-system/html-table.scm
+++ b/gnucash/report/report-system/html-table.scm
@@ -613,18 +613,6 @@
 ;; Feel free to contribute! :-)
 ;; 
 
-;; This function was moved here from balance-sheet.scm.
-;; This function "stacks" the two tables vertically.
-(define (gnc:html-table-merge t1 t2)
-  (begin 
-    (gnc:html-table-set-data! t1
-			      (append
-			       (gnc:html-table-data t2)
-			       (gnc:html-table-data t1)))
-    (gnc:html-table-set-num-rows-internal!
-     t1 (+ (gnc:html-table-num-rows t1)
-           (gnc:html-table-num-rows t2)))))
-
 (define (gnc:html-table-render table doc)
   (let* ((retval '())
          (push (lambda (l) (set! retval (cons l retval)))))
diff --git a/gnucash/report/report-system/report-system.scm b/gnucash/report/report-system/report-system.scm
index 3ed2b71..70943f2 100644
--- a/gnucash/report/report-system/report-system.scm
+++ b/gnucash/report/report-system/report-system.scm
@@ -620,7 +620,6 @@
 (export gnc:html-table-set-cell/tag!)
 (export gnc:html-table-append-column!)
 (export gnc:html-table-prepend-column!)
-(export gnc:html-table-merge)
 (export gnc:html-table-render)
 
 ;; html-text.scm

commit 03b57e515386039b3231c9a12f5674232c8ab972
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Fri Jun 1 17:44:09 2018 +0800

    [hello-world] amend comment from timepair to time64

diff --git a/gnucash/report/utility-reports/hello-world.scm b/gnucash/report/utility-reports/hello-world.scm
index 8cc6b1d..d149888 100644
--- a/gnucash/report/utility-reports/hello-world.scm
+++ b/gnucash/report/utility-reports/hello-world.scm
@@ -93,8 +93,8 @@
       "c" (N_ "This is a string option.") (N_ "Hello, World")))
     
     ;; This is a date/time option. The user can pick a date and,
-    ;; possibly, a time. Times are stored as a pair
-    ;; (seconds . nanoseconds) measured from Jan 1, 1970, i.e.,
+    ;; possibly, a time. Times are stored as an integer specifying
+    ;; number of seconds measured from Jan 1, 1970, i.e.,
     ;; Unix time. The last option is false, so the user can only
     ;; select a date, not a time. The default value is the current
     ;; time.

commit 879ec75f20ea72cf8860e4a732c3df900ecace19
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Thu May 24 11:16:23 2018 +0800

    [TR] [ENH] grid can easily display averages
    
    The subtotal-grid can easily calculate average amounts per *row*. I
    think this is useful enough to be set as default. Enable if number of
    secondary-key groups > 1. Upgrade test suite as well.
    
    The subtotal collectors do not calculate overall secondary-key
    subtotals, therefore, we cannot easily calculate average amounts per
    *column*.

diff --git a/gnucash/report/standard-reports/test/test-transaction.scm b/gnucash/report/standard-reports/test/test-transaction.scm
index 675792c..2abd884 100644
--- a/gnucash/report/standard-reports/test/test-transaction.scm
+++ b/gnucash/report/standard-reports/test/test-transaction.scm
@@ -805,46 +805,46 @@
       (let ((sxml (options->sxml options "subtotal table")))
         (test-equal "summary bank-row is correct"
           (list "Bank" "$190.00" "$190.00" "$190.00" "$190.00" "$190.00" "$190.00"
-                "$190.00" "$190.00" "$190.00" "$190.00" "$190.00" "$190.00" "$2,280.00")
+                "$190.00" "$190.00" "$190.00" "$190.00" "$190.00" "$190.00" "$2,280.00" "$190.00")
           (get-row-col sxml 1 #f))
         (test-equal "summary gbp bank-row is correct"
           (list "GBP Bank" "£51.00" "£51.00" "£51.00" "£51.00" "£51.00" "£51.00"
-                "£51.00" "£51.00" "£51.00" "£51.00" "£51.00" "£51.00" "£612.00")
+                "£51.00" "£51.00" "£51.00" "£51.00" "£51.00" "£51.00" "£612.00" "£51.00")
           (get-row-col sxml 2 #f))
         (test-equal "summary expense-row is correct"
           (list "Expenses" "$22.00" "$22.00" "$22.00" "$22.00" "$22.00" "$22.00"
-                "$22.00" "$22.00" "$22.00" "$22.00" "$22.00" "$22.00" "$264.00")
+                "$22.00" "$22.00" "$22.00" "$22.00" "$22.00" "$22.00" "$264.00" "$22.00")
           (get-row-col sxml 3 #f))
         (test-equal "summary income-row is correct"
           (list "Income" "-$212.00" "-$212.00" "-$212.00" "-$212.00" "-$212.00"
                 "-$212.00" "-$212.00" "-$212.00" "-$212.00" "-$212.00" "-$212.00"
-                "-$212.00" "-$2,544.00")
+                "-$212.00" "-$2,544.00" "-$212.00")
           (get-row-col sxml 4 #f))
         (test-equal "summary gbp income-row is correct"
           (list "Income-GBP" "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£51.00"
-                "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£612.00")
+                "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£612.00" "-£51.00")
           (get-row-col sxml 5 #f))
         (test-equal "summary gbp total-row is correct"
-          (list "Grand Total" "£0.00")
+          (list "Grand Total" "£0.00" "£0.00")
           (get-row-col sxml 6 #f))
         (test-equal "summary total-row is correct"
-          (list "$0.00")
+          (list "$0.00" "$0.00")
           (get-row-col sxml 7 #f)))
 
       (set-option! options "General" "Start Date" (cons 'absolute (gnc-dmy2time64 01 01 1969)))
       (set-option! options "General" "End Date" (cons 'absolute (gnc-dmy2time64 31 12 1970)))
       (let ((sxml (options->sxml options "sparse subtotal table")))
         (test-equal "sparse summary-table - row 1"
-          (list "Bank" "$29.00" "-$5.00" "-$23.00" "$1.00")
+          (list "Bank" "$29.00" "-$5.00" "-$23.00" "$1.00" "$0.33")
           (get-row-col sxml 1 #f))
         (test-equal "sparse summary-table - row 2"
-          (list "Expenses" "$16.00" "$15.00" "$31.00")
+          (list "Expenses" "$16.00" "$15.00" "$31.00" "$10.33")
           (get-row-col sxml 2 #f))
         (test-equal "sparse summary-table - row 3"
-          (list "Income" "-$29.00" "-$29.00")
+          (list "Income" "-$29.00" "-$29.00" "-$9.67")
           (get-row-col sxml 3 #f))
         (test-equal "sparse summary-table - row 4"
-          (list "Grand Total" "$3.00")
+          (list "Grand Total" "$3.00" "$1.00")
           (get-row-col sxml 4 #f))
         (test-equal "sparse summary-table - col 1"
           (list "Bank" "Expenses" "Income" "Grand Total")
@@ -860,6 +860,9 @@
           (get-row-col sxml #f 4))
         (test-equal "sparse summary-table - col 5"
           (list "$1.00" "$31.00" "-$29.00" "$3.00")
-          (get-row-col sxml #f 5))))
+          (get-row-col sxml #f 5))
+        (test-equal "sparse summary-table - col 6 average"
+          (list "$0.33" "$10.33" "-$9.67" "$1.00")
+          (get-row-col sxml #f 6))))
     (test-end "subtotal table")
     ))
diff --git a/gnucash/report/standard-reports/transaction.scm b/gnucash/report/standard-reports/transaction.scm
index 3599be5..2be2d86 100644
--- a/gnucash/report/standard-reports/transaction.scm
+++ b/gnucash/report/standard-reports/transaction.scm
@@ -1712,6 +1712,14 @@ be excluded from periodic reporting.")
   (set! grid (cons (vector row col data) grid)) ;add again. this is fine because the grid should
   grid)                                         ;never have duplicate data in the trep.
 (define (grid->html-table grid list-of-rows list-of-cols)
+  (define row-average-enabled? (> (length list-of-cols) 1))
+  (define (monetary-div monetary divisor)
+    (and monetary
+         (let* ((amount (gnc:gnc-monetary-amount monetary))
+                (currency (gnc:gnc-monetary-commodity monetary))
+                (scu (gnc-commodity-get-fraction currency)))
+           (gnc:make-gnc-monetary
+            currency (gnc-numeric-convert (/ amount divisor) scu GNC-HOW-RND-ROUND)))))
   (define (row->num-of-commodities row)
     ;; for a row, find the maximum number of commodities being stored
     (apply max
@@ -1720,22 +1728,27 @@ be excluded from periodic reporting.")
                     (if (null? cell) 0
                         (length (vector-ref (car cell) 2)))))
                 (cons 'col-total list-of-cols))))
-  (define (make-table-cell row col commodity-idx)
+  (define (make-table-cell row col commodity-idx divisor)
     (let ((cell (grid-get grid row col)))
       (if (null? cell) ""
-          (gnc:make-html-table-cell/markup "number-cell" (list-ref-safe (vector-ref (car cell) 2) commodity-idx)))))
+          (gnc:make-html-table-cell/markup "number-cell"
+                                           (monetary-div (list-ref-safe (vector-ref (car cell) 2) commodity-idx) divisor)))))
   (define (make-row row commodity-idx)
     (append
      (list (cond
             ((positive? commodity-idx) "")
             ((eq? row 'row-total) (_ "Grand Total"))
             (else (cdr row))))
-     (map (lambda (col) (make-table-cell row col commodity-idx))
+     (map (lambda (col) (make-table-cell row col commodity-idx 1))
           list-of-cols)
-     (list (make-table-cell row 'col-total commodity-idx))))
+     (list (make-table-cell row 'col-total commodity-idx 1))
+     (if row-average-enabled?
+         (list (make-table-cell row 'col-total commodity-idx (length list-of-cols)))
+         '())))
   (let ((table (gnc:make-html-table)))
     (gnc:html-table-set-caption! table optname-grid)
-    (gnc:html-table-set-col-headers! table (append (list "") (map cdr list-of-cols) (list (_ "Total"))))
+    (gnc:html-table-set-col-headers! table (append (list "") (map cdr list-of-cols) (list (_ "Total"))
+                                                   (if row-average-enabled? (list (_ "Average")) '())))
     (gnc:html-table-set-style! table "th"
                                'attribute (list "class" "column-heading-right"))
     (for-each

commit e9535bfab6da71a31aa99962e42878e5b6634f64
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Sun May 20 20:54:58 2018 +0800

    [TR] [bugfix] disable grid if primary-key doesn't have subtotal
    
    Formerly the logic would allow grid if secondary-subtotal enabled but
    primary-subtotal disabled. This would produce a single-row grid. This
    is now known to be inaccurate.
    
    This is because there will be multiple secondary subtotals spread out
    in the main table but no primary subtotal grouping to separate
    them. This would make every subsequent secondary subtotal overwrite
    the previous one. I think it is best to disable grid altogether if
    primary-subtotal is not enabled.
    
    The converse i.e. primary-subtotal enabled but secondary-subtotal
    disabled, is handled correctly. It produces a single-column grid.

diff --git a/gnucash/report/standard-reports/transaction.scm b/gnucash/report/standard-reports/transaction.scm
index bda30e8..3599be5 100644
--- a/gnucash/report/standard-reports/transaction.scm
+++ b/gnucash/report/standard-reports/transaction.scm
@@ -1982,6 +1982,9 @@ be excluded from periodic reporting.")
                             (qof-print-date enddate)))))
 
                 (if (and (opt-val gnc:pagename-display optname-grid)
+                         (if (memq primary-key DATE-SORTING-TYPES)
+                             (keylist-get-info date-subtotal-list primary-date-subtotal 'renderer-fn)
+                             (opt-val pagename-sorting optname-prime-subtotal))
                          (eq? (opt-val gnc:pagename-display (N_ "Amount")) 'single))
                     (let* ((generic<? (lambda (a b)
                                         (cond ((string? (car a)) (string<? (car a) (car b)))

commit aafd46a44281aecf0d140f97a15d0b7a4d546658
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon May 21 21:58:25 2018 +0800

    [TR] [bugfix] upgrade add-subtotal-row & grid for >1 commodities.
    
    This aims to handle multiple commodities correctly. If a row contains
    subtotals with more than one commodity, the row is duplicated so that
    every commodity gets its own line in the grid.
    
    This is accompanied by an upgrade to the test suite.
    
    Sample output if prime-sortkey = accounts, sec-sortkey = monthly dates
    
            Jan-17  Feb-17  Mar-17   Total
    Food    $22.00  $23.00  $35.00  $80.00
    Books    $8.50   $9.55  $15.00  $33.05
    Apps     £2.55   £5.00   £9.60  £17.15
    Total                          $113.05
                                    £17.15
    
    (note monthly totals are not displayed because they're not actually
    generated with the above sorting options)

diff --git a/gnucash/report/standard-reports/test/test-transaction.scm b/gnucash/report/standard-reports/test/test-transaction.scm
index df83c84..675792c 100644
--- a/gnucash/report/standard-reports/test/test-transaction.scm
+++ b/gnucash/report/standard-reports/test/test-transaction.scm
@@ -115,6 +115,7 @@
               (list "USD Bank")
               (list "Wallet"))
         (list "Income" (list (cons 'type ACCT-TYPE-INCOME)))
+        (list "Income-GBP" (list (cons 'type ACCT-TYPE-INCOME)))
         (list "Expenses" (list (cons 'type ACCT-TYPE-EXPENSE)))
         (list "Liabilities" (list (cons 'type ACCT-TYPE-LIABILITY)))
         (list "Equity" (list (cons 'type ACCT-TYPE-EQUITY)))
@@ -134,6 +135,7 @@
          (usd-bank (cdr (assoc "USD Bank" account-alist)))
          (wallet (cdr (assoc "Wallet" account-alist)))
          (income (cdr (assoc "Income" account-alist)))
+         (gbp-income (cdr (assoc "Income-GBP" account-alist)))
          (expense (cdr (assoc "Expenses" account-alist)))
          (liability (cdr (assoc "Liabilities" account-alist)))
          (equity (cdr (assoc "Equity" account-alist)))
@@ -168,7 +170,10 @@
        (xaccAccountSetCommodity (cdr pair) (gnc-default-report-currency)))
      account-alist)
 
-    ;; Here we set foreign banks' currencies
+    ;; Here we set foreign currencies
+
+    (gnc-commodity-set-user-symbol foreign2 "£")
+
     (with-account
      gbp-bank
      (lambda ()
@@ -176,6 +181,12 @@
        (xaccAccountSetCommodity gbp-bank foreign2)))
 
     (with-account
+     gbp-income
+     (lambda ()
+       (xaccAccountSetCode gbp-income "01-GBP")
+       (xaccAccountSetCommodity gbp-income foreign2)))
+
+    (with-account
      usd-bank
      (lambda ()
        (xaccAccountSetCode usd-bank "02-USD")
@@ -239,7 +250,9 @@
     ;; run in modern times, otherwise these transactions will be mixed
     ;; up with the old transactions above. The year end net bank balance
     ;; should be (* 12 (+ 103 109 -22)) = $2280.
+    ;; there will also be a £51 income monthly, tested at end of file
     (for-each (lambda (m)
+                (env-transfer env 08 (1+ m) YEAR gbp-income gbp-bank 51 #:description "£51 income")
                 (env-transfer env 03 (1+ m) YEAR income bank  103 #:description "$103 income")
                 (env-transfer env 15 (1+ m) YEAR bank expense  22 #:description "$22 expense")
                 (env-transfer env 09 (1+ m) YEAR income bank  109 #:description "$109 income"))
@@ -728,13 +741,13 @@
       (set-option! options "Sorting" "Secondary Subtotal for Date Key" 'quarterly)
       (set-option! options "Sorting" "Show Informal Debit/Credit Headers" #t)
       (set-option! options "Sorting" "Show Account Description" #t)
-      (let* ((sxml (options->sxml options "sorting=date")))
+      (let* ((sxml (options->sxml options "sorting=date, friendly headers")))
         (test-equal "expense acc friendly headers"
           '("\n" "Expenses" "\n" "Expense" "\n" "Rebate")
-          (get-row-col sxml 47 #f))
+          (get-row-col sxml 69 #f))
         (test-equal "income acc friendly headers"
           '("\n" "Income" "\n" "Charge" "\n" "Income")
-          (get-row-col sxml 69 #f)))
+          (get-row-col sxml 91 #f)))
 
       (set-option! options "Accounts" "Accounts" (list bank))
       (set-option! options "Display" "Totals" #f)
@@ -781,7 +794,7 @@
     (test-begin "subtotal table")
 
     (let ((options (default-testing-options)))
-      (set-option! options "Accounts" "Accounts" (list bank income expense))
+      (set-option! options "Accounts" "Accounts" (list bank gbp-bank gbp-income income expense))
       (set-option! options "General" "Start Date" (cons 'relative 'start-cal-year))
       (set-option! options "General" "End Date" (cons 'relative 'end-cal-year))
       (set-option! options "Display" "Subtotal Table" #t)
@@ -794,18 +807,29 @@
           (list "Bank" "$190.00" "$190.00" "$190.00" "$190.00" "$190.00" "$190.00"
                 "$190.00" "$190.00" "$190.00" "$190.00" "$190.00" "$190.00" "$2,280.00")
           (get-row-col sxml 1 #f))
+        (test-equal "summary gbp bank-row is correct"
+          (list "GBP Bank" "£51.00" "£51.00" "£51.00" "£51.00" "£51.00" "£51.00"
+                "£51.00" "£51.00" "£51.00" "£51.00" "£51.00" "£51.00" "£612.00")
+          (get-row-col sxml 2 #f))
         (test-equal "summary expense-row is correct"
           (list "Expenses" "$22.00" "$22.00" "$22.00" "$22.00" "$22.00" "$22.00"
                 "$22.00" "$22.00" "$22.00" "$22.00" "$22.00" "$22.00" "$264.00")
-          (get-row-col sxml 2 #f))
+          (get-row-col sxml 3 #f))
         (test-equal "summary income-row is correct"
           (list "Income" "-$212.00" "-$212.00" "-$212.00" "-$212.00" "-$212.00"
                 "-$212.00" "-$212.00" "-$212.00" "-$212.00" "-$212.00" "-$212.00"
                 "-$212.00" "-$2,544.00")
-          (get-row-col sxml 3 #f))
+          (get-row-col sxml 4 #f))
+        (test-equal "summary gbp income-row is correct"
+          (list "Income-GBP" "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£51.00"
+                "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£51.00" "-£612.00")
+          (get-row-col sxml 5 #f))
+        (test-equal "summary gbp total-row is correct"
+          (list "Grand Total" "£0.00")
+          (get-row-col sxml 6 #f))
         (test-equal "summary total-row is correct"
-          (list "Grand Total" "$0.00")
-          (get-row-col sxml 4 #f)))
+          (list "$0.00")
+          (get-row-col sxml 7 #f)))
 
       (set-option! options "General" "Start Date" (cons 'absolute (gnc-dmy2time64 01 01 1969)))
       (set-option! options "General" "End Date" (cons 'absolute (gnc-dmy2time64 31 12 1970)))
diff --git a/gnucash/report/standard-reports/transaction.scm b/gnucash/report/standard-reports/transaction.scm
index b191b9f..bda30e8 100644
--- a/gnucash/report/standard-reports/transaction.scm
+++ b/gnucash/report/standard-reports/transaction.scm
@@ -1375,9 +1375,11 @@ be excluded from periodic reporting.")
                                   (cons (gnc:make-html-table-cell/markup "total-number-cell" mon)
                                         result)))))))))
 
-        ;; we only wish to add the first column into the grid.
-        (if (pair? columns)
-            (set! grid (grid-add grid row col (car columns))))
+        ;; take the first column of each commodity, add onto the subtotal grid
+        (set! grid (grid-add grid row col
+                             (map (lambda (commodity)
+                                    (retrieve-commodity (car columns) commodity))
+                                  list-of-commodities)))
 
         ;; each commodity subtotal gets a separate line in the html-table
         ;; each line comprises: indenting, first-column, data-columns
@@ -1689,17 +1691,17 @@ be excluded from periodic reporting.")
 ;; grid data structure
 (define (make-grid)
   '())
+(define (cell-match? cell row col)
+  (and (or (not row) (equal? row (vector-ref cell 0)))
+       (or (not col) (equal? col (vector-ref cell 1)))))
 (define (grid-get grid row col)    ; grid filter - get all row/col - if #f then retrieve whole row/col
   (filter
-   (lambda (cell)
-     (and (or (not row) (equal? row (vector-ref cell 0)))
-          (or (not col) (equal? col (vector-ref cell 1)))))
+   (lambda (cell) (cell-match? cell row col))
    grid))
 (define (grid-del grid row col)    ; grid filter - del all row/col - if #f then delete whole row/col - CAREFUL!
   (filter
    (lambda (cell)
-     (not (and (or (not row) (equal? row (vector-ref cell 0)))
-               (or (not col) (equal? col (vector-ref cell 1))))))
+     (not (cell-match? cell row col)))
    grid))
 (define (grid-rows grid)
   (delete-duplicates (map (lambda (cell) (vector-ref cell 0)) grid)))
@@ -1710,17 +1712,27 @@ be excluded from periodic reporting.")
   (set! grid (cons (vector row col data) grid)) ;add again. this is fine because the grid should
   grid)                                         ;never have duplicate data in the trep.
 (define (grid->html-table grid list-of-rows list-of-cols)
-  (define (make-table-cell row col)
+  (define (row->num-of-commodities row)
+    ;; for a row, find the maximum number of commodities being stored
+    (apply max
+           (map (lambda (col)
+                  (let ((cell (grid-get grid row col)))
+                    (if (null? cell) 0
+                        (length (vector-ref (car cell) 2)))))
+                (cons 'col-total list-of-cols))))
+  (define (make-table-cell row col commodity-idx)
     (let ((cell (grid-get grid row col)))
-      (if (pair? cell)
-          (gnc:make-html-table-cell/markup "number-cell" (car (vector-ref (car cell) 2)))
-          "")))
-  (define (make-row row)
+      (if (null? cell) ""
+          (gnc:make-html-table-cell/markup "number-cell" (list-ref-safe (vector-ref (car cell) 2) commodity-idx)))))
+  (define (make-row row commodity-idx)
     (append
-     (list (if (eq? row 'row-total) (_ "Grand Total") (cdr row)))
-     (map (lambda (col) (make-table-cell row col))
+     (list (cond
+            ((positive? commodity-idx) "")
+            ((eq? row 'row-total) (_ "Grand Total"))
+            (else (cdr row))))
+     (map (lambda (col) (make-table-cell row col commodity-idx))
           list-of-cols)
-     (list (make-table-cell row 'col-total))))
+     (list (make-table-cell row 'col-total commodity-idx))))
   (let ((table (gnc:make-html-table)))
     (gnc:html-table-set-caption! table optname-grid)
     (gnc:html-table-set-col-headers! table (append (list "") (map cdr list-of-cols) (list (_ "Total"))))
@@ -1728,10 +1740,12 @@ be excluded from periodic reporting.")
                                'attribute (list "class" "column-heading-right"))
     (for-each
      (lambda (row)
-       (gnc:html-table-append-row! table (make-row row)))
-     list-of-rows)
-    (if (memq 'row-total (grid-rows grid))
-        (gnc:html-table-append-row! table (make-row 'row-total)))
+       (for-each (lambda (commodity-idx)
+                   (gnc:html-table-append-row! table (make-row row commodity-idx)))
+                 (iota (row->num-of-commodities row))))
+     (if (memq 'row-total (grid-rows grid))
+         (append list-of-rows '(row-total))
+         list-of-rows))
     table))
 
 ;; ;;;;;;;;;;;;;;;;;;;;

commit 98964f7a6d50107331a5eed70ddada7250d5108c
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon May 21 21:56:31 2018 +0800

    [TR] refactor add-subtotal-row
    
    Schemify to use (append) rather than (set!) calls to build
    list-of-cells. This is (IMHO) neater and definitely favoured by
    seasoned schemers.

diff --git a/gnucash/report/standard-reports/transaction.scm b/gnucash/report/standard-reports/transaction.scm
index 966246c..b191b9f 100644
--- a/gnucash/report/standard-reports/transaction.scm
+++ b/gnucash/report/standard-reports/transaction.scm
@@ -1309,8 +1309,7 @@ be excluded from periodic reporting.")
             (gnc:html-table-append-row/markup! table subheading-style (reverse row-contents)))))
 
     (define (add-subtotal-row subtotal-string subtotal-collectors subtotal-style level row col)
-      (let* ((row-contents '())
-             (left-indent (case level
+      (let* ((left-indent (case level
                             ((total) 0)
                             ((primary) primary-indent)
                             ((secondary) (+ primary-indent secondary-indent))))
@@ -1321,26 +1320,26 @@ be excluded from periodic reporting.")
                                                      gnc-commodity-equal)))
 
         (define (retrieve-commodity list-of-monetary commodity)
-          (if (null? list-of-monetary)
-              #f
-              (if (gnc-commodity-equal (gnc:gnc-monetary-commodity (car list-of-monetary)) commodity)
-                  (car list-of-monetary)
-                  (retrieve-commodity (cdr list-of-monetary) commodity))))
+          (find (lambda (mon) (gnc-commodity-equal commodity (gnc:gnc-monetary-commodity mon)))
+                list-of-monetary))
 
-        (define (add-first-column string)
+        (define (first-column string)
           (if export?
-              (begin
-                (addto! row-contents (gnc:make-html-table-cell/markup "total-label-cell" string))
-                (for-each (lambda (cell) (addto! row-contents cell))
-                          (gnc:html-make-empty-cells (+ right-indent width-left-columns -1))))
-              (addto! row-contents (gnc:make-html-table-cell/size/markup 1 (+ right-indent width-left-columns) "total-label-cell" string))))
+              (cons
+               (gnc:make-html-table-cell/markup "total-label-cell" string)
+               (gnc:html-make-empty-cells (+ right-indent width-left-columns -1)))
+              (list
+               (gnc:make-html-table-cell/size/markup 1 (+ right-indent width-left-columns) "total-label-cell" string))))
 
-        (define (add-columns commodity)
+        (define (data-columns commodity)
           (let loop ((merging? #f)
                      (last-column #f)
                      (columns columns)
-                     (merge-list merge-list))
-            (if (not (null? columns))
+                     (merge-list merge-list)
+                     (result '()))
+            (if (null? columns)
+                ;; we've processed all columns. return the (reversed) list of html-table-cells.
+                (reverse result)
                 (let* ((mon (retrieve-commodity (car columns) commodity))
                        (this-column (and mon (gnc:gnc-monetary-amount mon))))
                   (if (car merge-list)
@@ -1348,7 +1347,8 @@ be excluded from periodic reporting.")
                       (loop #t
                             this-column
                             (cdr columns)
-                            (cdr merge-list))
+                            (cdr merge-list)
+                            result)
                       (begin
                         (if merging?
                             ;; We're completing merge. Display debit-credit in correct column.
@@ -1360,38 +1360,37 @@ be excluded from periodic reporting.")
                                                               commodity (abs sum)))))
                                    (debit-col (and sum (positive? sum) sum-table-cell))
                                    (credit-col (and sum (not (positive? sum)) sum-table-cell)))
-                              (addto! row-contents (or debit-col ""))
-                              (addto! row-contents (or credit-col "")))
-                            ;; Default; not merging nor completed merge. Display monetary amount
-                            (addto! row-contents (gnc:make-html-table-cell/markup "total-number-cell" mon)))
-                        (loop #f
-                              #f
-                              (cdr columns)
-                              (cdr merge-list))))))))
+                              (loop #f
+                                    #f
+                                    (cdr columns)
+                                    (cdr merge-list)
+                                    (cons* (or credit-col "")
+                                           (or debit-col "")
+                                           result)))
+                            ;; Default; not merging nor completed merge. Just add amount to result.
+                            (loop #f
+                                  #f
+                                  (cdr columns)
+                                  (cdr merge-list)
+                                  (cons (gnc:make-html-table-cell/markup "total-number-cell" mon)
+                                        result)))))))))
 
         ;; we only wish to add the first column into the grid.
         (if (pair? columns)
             (set! grid (grid-add grid row col (car columns))))
 
-        ;;first row
-        (for-each (lambda (cell) (addto! row-contents cell))
-                  (gnc:html-make-empty-cells left-indent))
-        (add-first-column subtotal-string)
-        (add-columns (if (pair? list-of-commodities)
-                         (car list-of-commodities)
-                         #f)) ;to account for empty-row subtotals
-        (gnc:html-table-append-row/markup! table subtotal-style (reverse row-contents))
-
-        ;;subsequent rows
-        (if (pair? list-of-commodities)
-            (for-each (lambda (commodity)
-                        (set! row-contents '())
-                        (for-each (lambda (cell) (addto! row-contents cell))
-                                  (gnc:html-make-empty-cells left-indent))
-                        (add-first-column "")
-                        (add-columns commodity)
-                        (gnc:html-table-append-row/markup! table subtotal-style (reverse row-contents)))
-                      (cdr list-of-commodities)))))
+        ;; each commodity subtotal gets a separate line in the html-table
+        ;; each line comprises: indenting, first-column, data-columns
+        (let loop ((first-column-string subtotal-string)
+                   (list-of-commodities list-of-commodities))
+          (unless (null? list-of-commodities)
+            (gnc:html-table-append-row/markup!
+             table subtotal-style
+             (append
+              (gnc:html-make-empty-cells left-indent)
+              (first-column first-column-string)
+              (data-columns (car list-of-commodities))))
+            (loop "" (cdr list-of-commodities))))))
 
     (define (total-string str) (string-append (_ "Total For ") str))
 



Summary of changes:
 .../report/business-reports/balsheet-eg.eguile.scm |   7 -
 gnucash/report/business-reports/balsheet-eg.scm    |  13 +-
 gnucash/report/business-reports/receipt.scm        |  16 +-
 gnucash/report/business-reports/taxinvoice.scm     |  16 +-
 gnucash/report/locale-specific/us/taxtxf.scm       |  86 +--------
 gnucash/report/report-system/html-document.scm     |   6 +-
 gnucash/report/report-system/html-table.scm        |  44 +----
 gnucash/report/report-system/report-system.scm     |   1 -
 .../standard-reports/test/test-transaction.scm     |  61 +++++--
 gnucash/report/standard-reports/transaction.scm    | 163 ++++++++++-------
 gnucash/report/stylesheets/stylesheet-easy.scm     | 203 +++++++--------------
 gnucash/report/stylesheets/stylesheet-fancy.scm    | 203 +++++++--------------
 gnucash/report/stylesheets/stylesheet-footer.scm   | 203 +++++++--------------
 .../report/stylesheets/stylesheet-head-or-tail.scm | 203 +++++++--------------
 gnucash/report/stylesheets/stylesheet-plain.scm    | 203 +++++++--------------
 gnucash/report/utility-reports/hello-world.scm     |   4 +-
 16 files changed, 493 insertions(+), 939 deletions(-)



More information about the gnucash-changes mailing list