[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 <sup> footnote.
This commit is contained in:
Christopher Lam 2019-10-11 23:55:16 +08:00
parent cbd8649183
commit 39a7584e79

View File

@ -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))))