[Gnucash-changes] Fix xaccAccountGetBalanceAsOfDate() (bug #150757).

Derek Atkins warlord at cvs.gnucash.org
Sat Aug 28 22:35:18 EDT 2004


Log Message:
-----------
Fix xaccAccountGetBalanceAsOfDate() (bug #150757).

	* src/engine/Account.c: fix xaccAccountGetBalanceAsOfDate() to properly
	  compute the balance at the end of the split list.  Fixes #150757.

Modified Files:
--------------
    gnucash:
        ChangeLog
    gnucash/src/engine:
        Account.c

Revision Data
-------------
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1835
retrieving revision 1.1836
diff -LChangeLog -LChangeLog -u -r1.1835 -r1.1836
--- ChangeLog
+++ ChangeLog
@@ -1,10 +1,15 @@
-2004-18-21  Derek Atkins  <derek at ihtfp.com>
+2004-08-28  Derek Atkins  <derek at ihtfp.com>
+
+	* src/engine/Account.c: fix xaccAccountGetBalanceAsOfDate() to properly
+	  compute the balance at the end of the split list.  Fixes #150757.
+
+2004-08-21  Derek Atkins  <derek at ihtfp.com>
 
 	* src/report/standard-reports/advanced-portfolio.scm:
 	  Add option to include zero-amount splits in computations.
 	  Fixes #143722.
 
-2004-18-19  Derek Atkins  <derek at ihtfp.com>
+2004-08-19  Derek Atkins  <derek at ihtfp.com>
 
 	Neil Williams's "QOF create: functionality added" patch:
 
Index: Account.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Account.c,v
retrieving revision 1.277
retrieving revision 1.278
diff -Lsrc/engine/Account.c -Lsrc/engine/Account.c -u -r1.277 -r1.278
--- src/engine/Account.c
+++ src/engine/Account.c
@@ -1666,12 +1666,17 @@
       lp = lp->next;
   }
 
-  if( lp && lp->prev )
-  {
-    /* Since lp is now pointing to a split which was past the reconcile
-     * date, get the running balance of the previous split.
-     */
-    balance = xaccSplitGetBalance( (Split *)lp->prev->data );
+  if( lp ) {
+    if ( lp->prev ) {
+      /* Since lp is now pointing to a split which was past the reconcile
+       * date, get the running balance of the previous split.
+       */
+      balance = xaccSplitGetBalance( (Split *)lp->prev->data );
+    }		
+    else {
+      /* AsOf date must be before any entries, return zero. */
+      balance = gnc_numeric_zero();
+    }
   }
 
   /* Otherwise there were no splits posted after the given date,


More information about the gnucash-changes mailing list