From 39a7584e79ecec590ca30ad767ecb721e80e72b0 Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Fri, 11 Oct 2019 23:55:16 +0800 Subject: [PATCH] [html-table] renderer detects neg amounts for first cell-data previous would only negate whereby table-cell has single monetary/amount. change to detect whereby table-cell has multiple items, and the first one is a negative monetary/amount. this is useful for the budget spreadsheet whereby a negative monetary may be followed by a footnote. --- gnucash/report/report-system/html-table.scm | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gnucash/report/report-system/html-table.scm b/gnucash/report/report-system/html-table.scm index e1f9187bbb..771b2dab3f 100644 --- a/gnucash/report/report-system/html-table.scm +++ b/gnucash/report/report-system/html-table.scm @@ -139,15 +139,16 @@ (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 number - ;; or gnc:monetary, it fixes the tag eg. "number-cell" becomes - ;; "number-cell-red". The number and gnc:monetary renderers do not - ;; have an automatic -neg tag modifier. See bug 759005 and 797357. + ;; segment. Note: if the first element in a html-table-cell data is + ;; a negative number or gnc:monetary, it fixes the tag + ;; eg. "number-cell" becomes "number-cell-red". The number and + ;; gnc:monetary renderers do not have an automatic -neg tag + ;; modifier. See bug 759005 and bug 797357. (let* ((retval '()) (push (lambda (l) (set! retval (cons l retval)))) (cell-tag (gnc:html-table-cell-tag cell)) (cell-data (gnc:html-table-cell-data cell)) - (tag (if (and (= 1 (length cell-data)) + (tag (if (and (not (null? cell-data)) (not (string=? cell-tag "td")) (or (and (gnc:gnc-monetary? (car cell-data)) (negative? (gnc:gnc-monetary-amount (car cell-data))))