r17380 - gnucash/branches/2.2/src/report/report-system - [r17293] Reporting: Ignore exchange rates if the quantity to exchange is zero.

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


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

Modified:
   gnucash/branches/2.2/src/report/report-system/commodity-utilities.scm
Log:
[r17293] Reporting: Ignore exchange rates if the quantity to exchange is zero.

Committed by cedayiv.


Modified: gnucash/branches/2.2/src/report/report-system/commodity-utilities.scm
===================================================================
--- gnucash/branches/2.2/src/report/report-system/commodity-utilities.scm	2008-07-22 22:32:44 UTC (rev 17379)
+++ gnucash/branches/2.2/src/report/report-system/commodity-utilities.scm	2008-07-22 22:32:54 UTC (rev 17380)
@@ -775,23 +775,24 @@
 (define (gnc:make-exchange-function exchange-alist)
   (let ((exchangelist exchange-alist))
     (lambda (foreign domestic)
-      (begin
-	(gnc:debug "foreign: " foreign)
-	(gnc:debug "domestic: " domestic)
-	(if foreign
-	    (or (gnc:exchange-by-euro foreign domestic #f)
-		(gnc:exchange-if-same foreign domestic)
-		(gnc:make-gnc-monetary 
-		 domestic
-		 (let ((pair (assoc (gnc:gnc-monetary-commodity foreign) 
-				    exchangelist)))
-		   (if (not pair)
-		       (gnc-numeric-zero)
-		       (gnc-numeric-mul (gnc:gnc-monetary-amount foreign)
-					(cadr pair)
-					(gnc-commodity-get-fraction domestic)
-					GNC-RND-ROUND)))))
-	  #f)))))
+      (gnc:debug "foreign: " foreign)
+      (gnc:debug "domestic: " domestic)
+      (if foreign
+          (or (gnc:exchange-by-euro foreign domestic #f)
+              (gnc:exchange-if-same foreign domestic)
+              (gnc:make-gnc-monetary
+               domestic
+               (let ((pair (assoc (gnc:gnc-monetary-commodity foreign)
+                                  exchangelist))
+                     (foreign-amount (gnc:gnc-monetary-amount foreign)))
+                 (if (or (not pair)
+                         (gnc-numeric-zero-p foreign-amount))
+                     (gnc-numeric-zero)
+                     (gnc-numeric-mul foreign-amount
+                                      (cadr pair)
+                                      (gnc-commodity-get-fraction domestic)
+                                      GNC-RND-ROUND)))))
+          #f))))
 
 ;; Helper for the gnc:exchange-by-pricalist* below. Exchange the
 ;; <gnc:monetary> 'foreign' into the <gnc:commodity*> 'domestic' by



More information about the gnucash-changes mailing list