Add support to display negative values in red. Modify the budget report appropriately.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18231 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Phil Longstaff 2009-08-02 13:36:29 +00:00
parent ba946a9913
commit 2e09bf1126
5 changed files with 67 additions and 12 deletions

View File

@ -206,6 +206,9 @@
amount) amount)
) )
(define (negative-numeric-p x)
(if (gnc-numeric-p x) (gnc-numeric-negative-p x) #f))
;; Adds a line to tbe budget report. ;; Adds a line to tbe budget report.
;; ;;
;; Parameters: ;; Parameters:
@ -273,14 +276,14 @@
(if show-actual? (if show-actual?
(begin (begin
(gnc:html-table-set-cell/tag! (gnc:html-table-set-cell/tag!
html-table rownum current-col "number-cell" act-val) html-table rownum current-col (if (negative-numeric-p act-numeric-val) "number-cell-neg" "number-cell") act-val)
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )
(if show-diff? (if show-diff?
(begin (begin
(gnc:html-table-set-cell/tag! (gnc:html-table-set-cell/tag!
html-table rownum current-col "number-cell" dif-val) html-table rownum current-col (if (negative-numeric-p dif-numeric-val) "number-cell-neg" "number-cell") dif-val)
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )
@ -303,20 +306,21 @@
(if show-actual? (if show-actual?
(begin (begin
(gnc:html-table-set-cell/tag! (gnc:html-table-set-cell/tag!
html-table rownum current-col "total-number-cell" html-table rownum current-col (if (negative-numeric-p act-total) "total-number-cell" "total-number-cell-neg")
(gnc:make-gnc-monetary comm act-total)) (gnc:make-gnc-monetary comm act-total))
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )
(if show-diff? (if show-diff?
(begin (let* ((diff-val
(gnc:html-table-set-cell/tag!
html-table rownum current-col "total-number-cell"
(if bgt-total-unset? "."
(gnc:make-gnc-monetary comm (gnc:make-gnc-monetary comm
(gnc-numeric-sub bgt-total (gnc-numeric-sub bgt-total
act-total GNC-DENOM-AUTO act-total GNC-DENOM-AUTO
(+ GNC-DENOM-LCD GNC-RND-NEVER))))) (+ GNC-DENOM-LCD GNC-RND-NEVER)))))
(gnc:html-table-set-cell/tag!
html-table rownum current-col (if (negative-numeric-p diff-val) "total-number-cell-neg" "total-number-cell")
(if bgt-total-unset? "." diff-val)
)
(set! current-col (+ current-col 1)) (set! current-col (+ current-col 1))
) )
) )

View File

@ -124,30 +124,35 @@
(N_ "Fonts") (N_ "Fonts")
(N_ "Number cell") "c" (N_ "Font info for regular number cells") (N_ "Number cell") "c" (N_ "Font info for regular number cells")
"Arial 10")) "Arial 10"))
(opt-register
(gnc:make-simple-boolean-option
(N_ "Fonts")
(N_ "Negative Values in Red") "d" (N_ "Display negative values in red.")
#t))
(opt-register (opt-register
(gnc:make-font-option (gnc:make-font-option
(N_ "Fonts") (N_ "Fonts")
(N_ "Number header") "c" (N_ "Font info for number headers") (N_ "Number header") "e" (N_ "Font info for number headers")
"Arial 10")) "Arial 10"))
(opt-register (opt-register
(gnc:make-font-option (gnc:make-font-option
(N_ "Fonts") (N_ "Fonts")
(N_ "Text cell") "c" (N_ "Font info for regular text cells") (N_ "Text cell") "f" (N_ "Font info for regular text cells")
"Arial 10")) "Arial 10"))
(opt-register (opt-register
(gnc:make-font-option (gnc:make-font-option
(N_ "Fonts") (N_ "Fonts")
(N_ "Total number cell") "c" (N_ "Font info for number cells containing a total") (N_ "Total number cell") "g" (N_ "Font info for number cells containing a total")
"Arial Bold 12")) "Arial Bold 12"))
(opt-register (opt-register
(gnc:make-font-option (gnc:make-font-option
(N_ "Fonts") (N_ "Fonts")
(N_ "Total label cell") "c" (N_ "Font info for cells containing total labels") (N_ "Total label cell") "h" (N_ "Font info for cells containing total labels")
"Arial Bold 12")) "Arial Bold 12"))
(opt-register (opt-register
(gnc:make-font-option (gnc:make-font-option
(N_ "Fonts") (N_ "Fonts")
(N_ "Centered label cell") "c" (N_ "Font info for centered label cells") (N_ "Centered label cell") "i" (N_ "Font info for centered label cells")
"Arial Bold 12")) "Arial Bold 12"))
options)) options))
@ -169,6 +174,7 @@
(spacing (opt-val "Tables" "Table cell spacing")) (spacing (opt-val "Tables" "Table cell spacing"))
(padding (opt-val "Tables" "Table cell padding")) (padding (opt-val "Tables" "Table cell padding"))
(border (opt-val "Tables" "Table border width")) (border (opt-val "Tables" "Table border width"))
(negative-red? (opt-val "Fonts" "Negative Values in Red"))
(title-font-info (font-name-to-style-info (opt-val "Fonts" "Title"))) (title-font-info (font-name-to-style-info (opt-val "Fonts" "Title")))
(account-link-font-info (font-name-to-style-info (opt-val "Fonts" "Account link"))) (account-link-font-info (font-name-to-style-info (opt-val "Fonts" "Account link")))
(number-cell-font-info (font-name-to-style-info (opt-val "Fonts" "Number cell"))) (number-cell-font-info (font-name-to-style-info (opt-val "Fonts" "Number cell")))
@ -200,6 +206,11 @@
'tag "td" 'tag "td"
'attribute (list "class" "number-cell")) '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! (gnc:html-document-set-style!
ssdoc "number-header" ssdoc "number-header"
'tag "th" 'tag "th"
@ -215,6 +226,11 @@
'tag "td" 'tag "td"
'attribute (list "class" "total-number-cell")) '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! (gnc:html-document-set-style!
ssdoc "total-label-cell" ssdoc "total-label-cell"
'tag "td" 'tag "td"
@ -259,9 +275,11 @@
"a { " account-link-font-info " }\n" "a { " account-link-font-info " }\n"
"th { text-align: right; " number-header-font-info " }\n" "th { text-align: right; " number-header-font-info " }\n"
"td.number-cell { text-align: right; " number-cell-font-info " }\n" "td.number-cell { text-align: right; " number-cell-font-info " }\n"
"td.number-cell-neg { text-align: right; " (if negative-red? "color: red; " "") number-cell-font-info " }\n"
"td.number-header { text-align: right; " number-header-font-info " }\n" "td.number-header { text-align: right; " number-header-font-info " }\n"
"td.text-cell { text-align: left; " text-cell-font-info " }\n" "td.text-cell { text-align: left; " text-cell-font-info " }\n"
"td.total-number-cell { text-align:right; " total-number-cell-font-info " }\n" "td.total-number-cell { text-align:right; " total-number-cell-font-info " }\n"
"td.total-number-cell-neg { text-align:right; " (if negative-red? "color: red; " "") total-number-cell-font-info " }\n"
"td.total-label-cell { text-align: left; " total-label-cell-font-info " }\n" "td.total-label-cell { text-align: left; " total-label-cell-font-info " }\n"
"td.centered-label-cell { text-align: center; " centered-label-cell-font-info " }\n" "td.centered-label-cell { text-align: center; " centered-label-cell-font-info " }\n"
)) ))

View File

@ -237,6 +237,12 @@
'attribute (list "align" "right") 'attribute (list "align" "right")
'attribute (list "nowrap")) 'attribute (list "nowrap"))
(gnc:html-document-set-style!
ssdoc "number-cell-neg"
'tag "td"
'attribute (list "align" "right")
'attribute (list "nowrap"))
(if (and bgpixmap (if (and bgpixmap
(not (string=? bgpixmap ""))) (not (string=? bgpixmap "")))
(gnc:html-document-set-style! (gnc:html-document-set-style!
@ -280,6 +286,11 @@
'tag '("td" "b") 'tag '("td" "b")
'attribute (list "align" "right")) 'attribute (list "align" "right"))
(gnc:html-document-set-style!
ssdoc "total-number-cell-neg"
'tag '("td" "b")
'attribute (list "align" "right"))
(gnc:html-document-set-style! (gnc:html-document-set-style!
ssdoc "total-label-cell" ssdoc "total-label-cell"
'tag '("td" "b") 'tag '("td" "b")

View File

@ -231,6 +231,12 @@
'attribute (list "align" "right") 'attribute (list "align" "right")
'attribute (list "nowrap")) 'attribute (list "nowrap"))
(gnc:html-document-set-style!
ssdoc "number-cell-neg"
'tag "td"
'attribute (list "align" "right")
'attribute (list "nowrap"))
(if (and bgpixmap (if (and bgpixmap
(not (string=? bgpixmap ""))) (not (string=? bgpixmap "")))
(gnc:html-document-set-style! (gnc:html-document-set-style!
@ -274,6 +280,11 @@
'tag '("td" "b") 'tag '("td" "b")
'attribute (list "align" "right")) 'attribute (list "align" "right"))
(gnc:html-document-set-style!
ssdoc "total-number-cell-neg"
'tag '("td" "b")
'attribute (list "align" "right"))
(gnc:html-document-set-style! (gnc:html-document-set-style!
ssdoc "total-label-cell" ssdoc "total-label-cell"
'tag '("td" "b") 'tag '("td" "b")

View File

@ -108,6 +108,12 @@
'attribute (list "align" "right") 'attribute (list "align" "right")
'attribute (list "nowrap")) '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! (gnc:html-document-set-style!
ssdoc "number-header" ssdoc "number-header"
'tag "th" 'tag "th"
@ -123,6 +129,11 @@
'tag '("td" "b") 'tag '("td" "b")
'attribute (list "align" "right")) 'attribute (list "align" "right"))
(gnc:html-document-set-style!
ssdoc "total-number-cell-neg"
'tag '("td" "b")
'attribute (list "align" "right"))
(gnc:html-document-set-style! (gnc:html-document-set-style!
ssdoc "total-label-cell" ssdoc "total-label-cell"
'tag '("td" "b") 'tag '("td" "b")