[Gnucash-changes] r13362 - gnucash/trunk/src/engine - Add some comments, error checks, ENTER/LEAVE balances and a special-case

Chris Shoemaker chris at cvs.gnucash.org
Wed Feb 22 12:41:59 EST 2006


Author: chris
Date: 2006-02-22 12:41:58 -0500 (Wed, 22 Feb 2006)
New Revision: 13362
Trac: http://svn.gnucash.org/trac/changeset/13362

Modified:
   gnucash/trunk/src/engine/Transaction.c
Log:
   Add some comments, error checks, ENTER/LEAVE balances and a special-case
   early-return for the conversion-rate calculation.


Modified: gnucash/trunk/src/engine/Transaction.c
===================================================================
--- gnucash/trunk/src/engine/Transaction.c	2006-02-22 15:41:18 UTC (rev 13361)
+++ gnucash/trunk/src/engine/Transaction.c	2006-02-22 17:41:58 UTC (rev 13362)
@@ -789,10 +789,12 @@
 	else { split->amount = amt;	}
 }
 
+/* The amount of the split in the _account's_ commodity. */
 void 
 xaccSplitSetAmount (Split *s, gnc_numeric amt) 
 {
   if (!s) return;
+  g_return_if_fail(gnc_numeric_check(amt) == GNC_ERROR_OK);
   ENTER ("(split=%p) old amt=%" G_GINT64_FORMAT "/%" G_GINT64_FORMAT
 	 " new amt=%" G_GINT64_FORMAT "/%" G_GINT64_FORMAT, s,
 	 s->amount.num, s->amount.denom, amt.num, amt.denom);
@@ -806,6 +808,7 @@
 
   SET_GAINS_ADIRTY(s);
   mark_split (s);
+  LEAVE("");
 }
 
 static void
@@ -816,10 +819,13 @@
 			get_currency_denom(split), GNC_HOW_RND_ROUND);
 }
 
+/* The value of the split in the _transaction's_ currency. */
 void 
 xaccSplitSetValue (Split *s, gnc_numeric amt) 
 {
   if (!s) return;
+  
+  g_return_if_fail(gnc_numeric_check(amt) == GNC_ERROR_OK);
   ENTER ("(split=%p) old val=%" G_GINT64_FORMAT "/%" G_GINT64_FORMAT
 	 " new val=%" G_GINT64_FORMAT "/%" G_GINT64_FORMAT, s,
 	 s->value.num, s->value.denom, amt.num, amt.denom);
@@ -830,6 +836,7 @@
 
   SET_GAINS_VDIRTY(s);
   mark_split (s);
+  LEAVE ("");
 }
 
 /********************************************************************\
@@ -1484,6 +1491,10 @@
    * rate (based on amount/value), and then return this conversion
    * rate.
    */
+  if (gnc_commodity_equal(xaccAccountGetCommodity(acc), 
+                          xaccTransGetCurrency(txn)))
+      return gnc_numeric_create(1, 1);
+
   splits = xaccTransGetSplitList(txn);
   for (; splits; splits = splits->next) {
     s = splits->data;



More information about the gnucash-changes mailing list