r18231 - gnucash/trunk/src/report - Add support to display negative values in red. Modify the budget report appropriately.

Phil Longstaff plongstaff at code.gnucash.org
Sun Aug 2 09:36:30 EDT 2009


Author: plongstaff
Date: 2009-08-02 09:36:29 -0400 (Sun, 02 Aug 2009)
New Revision: 18231
Trac: http://svn.gnucash.org/trac/changeset/18231

Modified:
   gnucash/trunk/src/report/standard-reports/budget.scm
   gnucash/trunk/src/report/stylesheets/stylesheet-css.scm
   gnucash/trunk/src/report/stylesheets/stylesheet-easy.scm
   gnucash/trunk/src/report/stylesheets/stylesheet-fancy.scm
   gnucash/trunk/src/report/stylesheets/stylesheet-plain.scm
Log:
Add support to display negative values in red.  Modify the budget report appropriately.


Modified: gnucash/trunk/src/report/standard-reports/budget.scm
===================================================================
--- gnucash/trunk/src/report/standard-reports/budget.scm	2009-08-02 03:00:28 UTC (rev 18230)
+++ gnucash/trunk/src/report/standard-reports/budget.scm	2009-08-02 13:36:29 UTC (rev 18231)
@@ -206,6 +206,9 @@
     amount)
   )
 
+  (define (negative-numeric-p x)
+    (if (gnc-numeric-p x) (gnc-numeric-negative-p x) #f))
+
   ;; Adds a line to tbe budget report.
   ;;
   ;; Parameters:
@@ -273,14 +276,14 @@
                (if show-actual?
                  (begin
                    (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))
                  )
                )
                (if show-diff?
                  (begin
                    (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))
                  )
                )
@@ -303,20 +306,21 @@
                (if show-actual?
                  (begin
                    (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))
                    (set! current-col (+ current-col 1))
                  )
                )
                (if show-diff?
-                 (begin
-                   (gnc:html-table-set-cell/tag!
-                    html-table rownum current-col "total-number-cell"
-                       (if bgt-total-unset? "."
+                 (let* ((diff-val 
                           (gnc:make-gnc-monetary comm
                               (gnc-numeric-sub bgt-total
                                        act-total GNC-DENOM-AUTO
                                        (+ 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))
                  )
                )

Modified: gnucash/trunk/src/report/stylesheets/stylesheet-css.scm
===================================================================
--- gnucash/trunk/src/report/stylesheets/stylesheet-css.scm	2009-08-02 03:00:28 UTC (rev 18230)
+++ gnucash/trunk/src/report/stylesheets/stylesheet-css.scm	2009-08-02 13:36:29 UTC (rev 18231)
@@ -125,29 +125,34 @@
 		   (N_ "Number cell") "c" (N_ "Font info for regular number cells")
 		   "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
           (gnc:make-font-option
            (N_ "Fonts")
-		   (N_ "Number header") "c" (N_ "Font info for number headers")
+		   (N_ "Number header") "e" (N_ "Font info for number headers")
 		   "Arial 10"))
          (opt-register
           (gnc:make-font-option
            (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"))
          (opt-register
           (gnc:make-font-option
            (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"))
          (opt-register
           (gnc:make-font-option
            (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"))
          (opt-register
           (gnc:make-font-option
            (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"))
 
          options))
@@ -169,6 +174,7 @@
 	 (spacing (opt-val "Tables" "Table cell spacing"))
 	 (padding (opt-val "Tables" "Table cell padding"))
 	 (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")))
 	 (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")))
@@ -201,6 +207,11 @@
        '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"))
@@ -216,6 +227,11 @@
        '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"))
@@ -259,9 +275,11 @@
 		  "a { " account-link-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-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.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-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.centered-label-cell { text-align: center; " centered-label-cell-font-info " }\n"
 		  ))

Modified: gnucash/trunk/src/report/stylesheets/stylesheet-easy.scm
===================================================================
--- gnucash/trunk/src/report/stylesheets/stylesheet-easy.scm	2009-08-02 03:00:28 UTC (rev 18230)
+++ gnucash/trunk/src/report/stylesheets/stylesheet-easy.scm	2009-08-02 13:36:29 UTC (rev 18231)
@@ -237,6 +237,12 @@
      '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"))
+
     (if (and bgpixmap
 	     (not (string=? bgpixmap "")))
 	(gnc:html-document-set-style!
@@ -281,6 +287,11 @@
      '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!
      ssdoc "total-label-cell"
      'tag '("td" "b")
      'attribute (list "align" "left"))

Modified: gnucash/trunk/src/report/stylesheets/stylesheet-fancy.scm
===================================================================
--- gnucash/trunk/src/report/stylesheets/stylesheet-fancy.scm	2009-08-02 03:00:28 UTC (rev 18230)
+++ gnucash/trunk/src/report/stylesheets/stylesheet-fancy.scm	2009-08-02 13:36:29 UTC (rev 18231)
@@ -231,6 +231,12 @@
      '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"))
+
     (if (and bgpixmap
 	     (not (string=? bgpixmap "")))
 	(gnc:html-document-set-style!
@@ -275,6 +281,11 @@
      '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!
      ssdoc "total-label-cell"
      'tag '("td" "b")
      'attribute (list "align" "left"))

Modified: gnucash/trunk/src/report/stylesheets/stylesheet-plain.scm
===================================================================
--- gnucash/trunk/src/report/stylesheets/stylesheet-plain.scm	2009-08-02 03:00:28 UTC (rev 18230)
+++ gnucash/trunk/src/report/stylesheets/stylesheet-plain.scm	2009-08-02 13:36:29 UTC (rev 18231)
@@ -109,6 +109,12 @@
      '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"))
@@ -124,6 +130,11 @@
      '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!
      ssdoc "total-label-cell"
      'tag '("td" "b")
      'attribute (list "align" "left"))



More information about the gnucash-changes mailing list