r17389 - gnucash/branches/2.2/src/report/standard-reports - [r17339] Bug #463320: Fix trial balance report's unrealized gain calculation and inability to print unrealized gain credits.

Andreas Köhler andi5 at cvs.gnucash.org
Tue Jul 22 18:34:28 EDT 2008


Author: andi5
Date: 2008-07-22 18:34:27 -0400 (Tue, 22 Jul 2008)
New Revision: 17389
Trac: http://svn.gnucash.org/trac/changeset/17389

Modified:
   gnucash/branches/2.2/src/report/standard-reports/trial-balance.scm
Log:
[r17339] Bug #463320: Fix trial balance report's unrealized gain calculation and inability to print unrealized gain credits.

Use "Average Cost" as the default price source.

Committed by cedayiv.


Modified: gnucash/branches/2.2/src/report/standard-reports/trial-balance.scm
===================================================================
--- gnucash/branches/2.2/src/report/standard-reports/trial-balance.scm	2008-07-22 22:34:18 UTC (rev 17388)
+++ gnucash/branches/2.2/src/report/standard-reports/trial-balance.scm	2008-07-22 22:34:27 UTC (rev 17389)
@@ -220,7 +220,7 @@
     
     (gnc:options-add-price-source! 
      options pagename-commodities
-     optname-price-source "b" 'weighted-average)
+     optname-price-source "b" 'average-cost)
     
     (add-option 
      (gnc:make-simple-boolean-option
@@ -531,8 +531,8 @@
 		 )
 	       all-accounts)
           (set! unrealized-gain-collector (gnc:make-commodity-collector))
-          (let* ((weighted-fn
-                  (gnc:case-exchange-fn 'weighted-average
+          (let* ((cost-fn
+                  (gnc:case-exchange-fn 'average-cost
                                         report-commodity end-date-tp))
 		 
                  (value
@@ -545,7 +545,7 @@
                   (gnc:gnc-monetary-amount
                    (gnc:sum-collector-commodity book-balance
                                                 report-commodity
-                                                weighted-fn)))
+                                                cost-fn)))
 		 
                  (unrealized-gain (gnc-numeric-sub-fixed value cost)))
 	    
@@ -821,28 +821,23 @@
 	  ;; we omit unrealized gains from the balance report, if
 	  ;; zero, since they are not present on normal trial balances
 	  (and (not (gnc-commodity-collector-allzero?
-		     unrealized-gain-collector))
+		     neg-unrealized-gain-collector))
 	       (let* ((ug-row (+ header-rows
-				 (gnc:html-acct-table-num-rows
-				  acct-table)))
+				 (gnc:html-acct-table-num-rows acct-table)))
+                      (credit? (gnc:double-col
+                                'credit-q neg-unrealized-gain-collector
+                                report-commodity exchange-fn show-fcur?))
+                      (entry (gnc:double-col
+                              'entry neg-unrealized-gain-collector
+                              report-commodity exchange-fn show-fcur?))
 		      )
-		 (add-line
-		  build-table (_ "Unrealized Gains")
-		  neg-unrealized-gain-collector)
-		 ;; make table line wide enough
-		 (gnc:html-table-set-cell!
-		  build-table
-		  ug-row
-		  (+ account-cols 1)
-		  #f)
+                 (add-line build-table
+                           (if credit?
+                               (_ "Unrealized Gains")
+                               (_ "Unrealized Losses"))
+                           neg-unrealized-gain-collector)
 		 (if (equal? report-variant 'work-sheet)
-		     (let* ((credit? (gnc:double-col
-				      'credit-q neg-unrealized-gain-collector
-				      report-commodity exchange-fn show-fcur?))
-			    (entry (gnc:double-col
-				    'entry neg-unrealized-gain-collector
-				    report-commodity exchange-fn show-fcur?))
-			    )
+		     (begin
 		       ;; make table line wide enough
 		       (gnc:html-table-set-cell!
 			build-table



More information about the gnucash-changes mailing list