r18431 - gnucash/trunk/src/backend/sql - Fix bug 591098 - when starting Gnucash, "Present" and all other collumns exept TOTAL are zero until you open the account

Phil Longstaff plongstaff at code.gnucash.org
Fri Nov 20 23:32:26 EST 2009


Author: plongstaff
Date: 2009-11-20 23:32:26 -0500 (Fri, 20 Nov 2009)
New Revision: 18431
Trac: http://svn.gnucash.org/trac/changeset/18431

Modified:
   gnucash/trunk/src/backend/sql/gnc-transaction-sql.c
Log:
Fix bug 591098 - when starting Gnucash, "Present" and all other collumns exept TOTAL are zero until you open the account
Fix bug 598618 -  does not calculate account balances correctly

Both of these are happening because not all transactions are being loaded at startup.  Bug 591098
happens because the account assumes it has all splits loaded, and looks for the first one after the
requested date to get the present balance.  The second happens because then the splits associated
with an invoice transaction are being loaded, the balance cannot be updated properly.

This change reverts back to loading all transactions on startup.  Once gnucash is a proper database
app, we can change back to loading transactions only when needed.


Modified: gnucash/trunk/src/backend/sql/gnc-transaction-sql.c
===================================================================
--- gnucash/trunk/src/backend/sql/gnc-transaction-sql.c	2009-11-20 21:12:21 UTC (rev 18430)
+++ gnucash/trunk/src/backend/sql/gnc-transaction-sql.c	2009-11-21 04:32:26 UTC (rev 18431)
@@ -54,6 +54,7 @@
 #endif
 
 #define SIMPLE_QUERY_COMPILATION 1
+#define LOAD_TRANSACTIONS_AS_NEEDED 0
 
 /*@ unused @*/ static QofLogModule log_module = G_LOG_DOMAIN;
 
@@ -365,6 +366,7 @@
 		GSList* nextbal;
 		Account* root = gnc_book_get_root_account( be->primary_book );
 
+#if LOAD_TRANSACTIONS_AS_NEEDED
 		qof_event_suspend();
 		xaccAccountBeginEdit( root );
 
@@ -373,6 +375,7 @@
 		gnc_account_foreach_descendant( gnc_book_get_root_account( be->primary_book ),
 										save_account_balances,
 										&bal_list );
+#endif
 
 		// Load the transactions
 		row = gnc_sql_result_get_first_row( result );
@@ -397,6 +400,7 @@
     		xaccTransCommitEdit( pTx );
 		}
 
+#if LOAD_TRANSACTIONS_AS_NEEDED
 		// Update the account balances based on the loaded splits.  If the end
 		// balance has changed, update the start balance so that the end
 		// balance is the same as it was before the splits were loaded.
@@ -447,6 +451,7 @@
 
 		xaccAccountCommitEdit( root );
 		qof_event_resume();
+#endif
     }
 }
 
@@ -1182,6 +1187,7 @@
 /*@ null @*/ GSList*
 gnc_sql_get_account_balances_slist( GncSqlBackend* be )
 {
+#if LOAD_TRANSACTIONS_AS_NEEDED
     GncSqlResult* result;
     GncSqlStatement* stmt;
 	gchar* buf;
@@ -1251,6 +1257,9 @@
     }
 
     return bal_slist;
+#else
+    return NULL;
+#endif
 }
 
 /* ----------------------------------------------------------------- */
@@ -1310,7 +1319,11 @@
         GNC_SQL_BACKEND_VERSION,
         GNC_ID_TRANS,
         commit_transaction,          /* commit */
-        NULL,
+#if LOAD_TRANSACTIONS_AS_NEEDED
+        NULL,                        /* initial load */
+#else
+        gnc_sql_transaction_load_all_tx,
+#endif
         create_transaction_tables,   /* create tables */
 		NULL,                        /* compile_query */
 		NULL,                        /* run_query */
@@ -1324,9 +1337,15 @@
         commit_split,                /* commit */
         NULL,                        /* initial_load */
         NULL,                        /* create tables */
+#if LOAD_TRANSACTIONS_AS_NEEDED
         compile_split_query,
         run_split_query,
         free_split_query,
+#else
+		NULL,                        /* compile_query */
+		NULL,                        /* run_query */
+		NULL,                        /* free_query */
+#endif
 		NULL                         /* write */
     };
 



More information about the gnucash-changes mailing list