gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Mon Oct 7 09:32:28 EDT 2019
Updated via https://github.com/Gnucash/gnucash/commit/2d996926 (commit)
via https://github.com/Gnucash/gnucash/commit/9d0d3fd3 (commit)
from https://github.com/Gnucash/gnucash/commit/b00a95c0 (commit)
commit 2d9969262112efa35a14f3fb3ed9627985a57579
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Oct 7 21:03:37 2019 +0800
[budget] bug 759005 we don't need style-tag "-neg" anymore
diff --git a/gnucash/report/standard-reports/budget.scm b/gnucash/report/standard-reports/budget.scm
index b5c1c6443..80b98dd6a 100644
--- a/gnucash/report/standard-reports/budget.scm
+++ b/gnucash/report/standard-reports/budget.scm
@@ -350,25 +350,24 @@
;; col - next column
(define (disp-cols style-tag col0
bgt-val act-val dif-val)
- (let* ((style-tag-neg (string-append style-tag "-neg"))
- (col1 (+ col0 (if show-budget? 1 0)))
+ (let* ((col1 (+ col0 (if show-budget? 1 0)))
(col2 (+ col1 (if show-actual? 1 0)))
(col3 (+ col2 (if show-diff? 1 0))))
(if show-budget?
(gnc:html-table-set-cell/tag!
html-table rownum col0
- (if (negative? bgt-val) style-tag-neg style-tag)
+ style-tag
(if (zero? bgt-val) "."
(gnc:make-gnc-monetary comm bgt-val))))
(if show-actual?
(gnc:html-table-set-cell/tag!
html-table rownum col1
- (if (negative? act-val) style-tag-neg style-tag)
+ style-tag
(gnc:make-gnc-monetary comm act-val)))
(if show-diff?
(gnc:html-table-set-cell/tag!
html-table rownum col2
- (if (negative? dif-val) style-tag-neg style-tag)
+ style-tag
(if (and (zero? bgt-val) (zero? act-val)) "."
(gnc:make-gnc-monetary comm dif-val))))
col3))
commit 9d0d3fd3be45015a1dbf2800a049eb40361fd09f
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Mon Oct 7 20:16:06 2019 +0800
Bug 759005 - Print negatives in red
Fixes display of negative monetary-amounts so that they are rendered
according to style-sheet option.
Note this commit fixes via <td> renderer -- if it has a single datum, and
has a negative monetary amount, then its tag gets "-neg" appended.
If a gnc:monetary is renderer *outside* html-table-cell, it will not
be rendered as red (in default stylesheet).
diff --git a/gnucash/report/report-system/html-table.scm b/gnucash/report/report-system/html-table.scm
index ceedb8ece..636c04129 100644
--- a/gnucash/report/report-system/html-table.scm
+++ b/gnucash/report/report-system/html-table.scm
@@ -140,25 +140,30 @@
cell (append (gnc:html-table-cell-data cell) objects)))
(define (gnc:html-table-cell-render cell doc)
+ ;; This function renders a html-table-cell to a document tree
+ ;; segment. Note: if the html-table-cell datum is a negative
+ ;; gnc:monetary, it fixes the tag eg. "number-cell" becomes
+ ;; "number-cell-red". The gnc:monetary renderer does not have an
+ ;; automatic -neg tag modifier. See bug 759005 and bug 797357.
(let* ((retval '())
(push (lambda (l) (set! retval (cons l retval))))
- (style (gnc:html-table-cell-style cell)))
-
-; ;; why dont colspans export??!
-; (gnc:html-table-cell-set-style! cell "td"
-; 'attribute (list "colspan"
-; (or (gnc:html-table-cell-colspan cell) 1)))
- (gnc:html-document-push-style doc style)
- (push (gnc:html-document-markup-start
- doc (gnc:html-table-cell-tag cell) #t
+ (cell-tag (gnc:html-table-cell-tag cell))
+ (cell-data (gnc:html-table-cell-data cell))
+ (tag (if (and (= 1 (length cell-data))
+ (gnc:gnc-monetary? (car cell-data))
+ (negative? (gnc:gnc-monetary-amount (car cell-data))))
+ (string-append cell-tag "-neg")
+ cell-tag)))
+ (gnc:html-document-push-style doc (gnc:html-table-cell-style cell))
+ (push (gnc:html-document-markup-start
+ doc tag #t
(format #f "rowspan=\"~a\"" (gnc:html-table-cell-rowspan cell))
(format #f "colspan=\"~a\"" (gnc:html-table-cell-colspan cell))))
- (for-each
- (lambda (child)
+ (for-each
+ (lambda (child)
(push (gnc:html-object-render child doc)))
- (gnc:html-table-cell-data cell))
- (push (gnc:html-document-markup-end
- doc (gnc:html-table-cell-tag cell)))
+ cell-data)
+ (push (gnc:html-document-markup-end doc cell-tag))
(gnc:html-document-pop-style doc)
retval))
diff --git a/gnucash/report/report-system/test/test-report-html.scm b/gnucash/report/report-system/test/test-report-html.scm
index e4a854d48..e4178e316 100644
--- a/gnucash/report/report-system/test/test-report-html.scm
+++ b/gnucash/report/report-system/test/test-report-html.scm
@@ -798,6 +798,31 @@ HTML Document Title</title></head><body></body>\n\
)
(test-end "HTML Table - Table Rendering")
+ (test-begin "html-table-cell renderers")
+ (let ((doc (gnc:make-html-document))
+ (cell (gnc:make-html-table-cell 4)))
+ (test-equal "html-table-cell renders correctly"
+ "<td rowspan=\"1\" colspan=\"1\"><number> 4</td>\n"
+ (string-concatenate
+ (gnc:html-document-tree-collapse
+ (gnc:html-table-cell-render cell doc)))))
+
+ ;; the following is tailor-made to test bug 797357. if the report
+ ;; system is refactored, this test will probably need fixing. it
+ ;; aims to ensure the table-cell class eg 'number-cell'
+ ;; 'total-number-cell' is augmented with a '-neg', and the
+ ;; resulting renderer renders as <td class='number-cell neg' ...>
+ (let* ((doc (gnc:make-html-document))
+ (comm-table (gnc-commodity-table-get-table (gnc-get-current-book)))
+ (USD (gnc-commodity-table-lookup comm-table "CURRENCY" "USD"))
+ (cell (gnc:make-html-table-cell (gnc:make-gnc-monetary USD -10))))
+ (test-equal "html-table-cell negative-monetary -> tag gets -neg appended"
+ "td-neg"
+ (cadr
+ (gnc:html-document-tree-collapse
+ (gnc:html-table-cell-render cell doc)))))
+ (test-end "html-table-cell renderers")
+
(test-end "HTML Tables - without style sheets")
)
Summary of changes:
gnucash/report/report-system/html-table.scm | 33 +++++++++++++---------
.../report/report-system/test/test-report-html.scm | 25 ++++++++++++++++
gnucash/report/standard-reports/budget.scm | 9 +++---
3 files changed, 48 insertions(+), 19 deletions(-)
More information about the gnucash-changes
mailing list