[Gnucash-changes] Sync the g2 branch with the gnome2-merge-12 tag.

David Hampton hampton at cvs.gnucash.org
Sat Apr 2 18:04:03 EST 2005


Log Message:
-----------
Sync the g2 branch with the gnome2-merge-12 tag.

Tags:
----
gnucash-gnome2-dev

Modified Files:
--------------
    gnucash:
        ChangeLog
        GNOME2_STATUS
        acinclude.m4
        configure.in
    gnucash/rpm:
        README
        gnucash.spec.in
    gnucash/src/app-utils:
        gnc-ui-util.c
    gnucash/src/backend/file:
        gnc-backend-file.c
    gnucash/src/backend/file/test:
        test-string-converters.c
    gnucash/src/business/business-core:
        gncInvoice.c
    gnucash/src/engine:
        Account.c
        Account.h
        AccountP.h
        Group.h
        Scrub.c
        Transaction.c
        gnc-lot.c
        gnc-lot.h
        gnc-numeric.c
        gnc-trace.c
        gnc-trace.h
        guid.c
        guid.h
        kvp_frame.c
        qof_book_merge.c
        qofclass.h
        qofid.h
        qofquery-deserial.c
        qofquery-serialize.c
        qofsession-p.h
        qofsession.c
        qofsql.c
    gnucash/src/engine/test:
        test-book-merge.c
    gnucash/src/gnc-module:
        gnc-module.h
    gnucash/src/gnome:
        druid-merge.c
        gnc-split-reg.c
    gnucash/src/gnome-utils:
        dialog-utils.c
        gnc-account-sel.c
        gnc-amount-edit.c
        gnc-date-delta.c
        gnc-date-edit.c
        gnc-date-format.c
        gnc-dense-cal.c
        gnc-frequency.c
    gnucash/src/import-export:
        import-backend.c
        import-backend.h
        import-main-matcher.c
        import-main-matcher.h
        import-settings.c
        import-settings.h
    gnucash/src/import-export/hbci:
        Makefile.am
        dialog-hbcitrans.c
        druid-hbci-initial.c
        gnc-hbci-getbalance.c
        gnc-hbci-gettrans.c
        gnc-hbci-kvp.c
        gnc-hbci-transfer.c
        gnc-hbci-utils.c
        gnc-hbci-utils.h
        hbci-interaction.c
        hbci-interaction.h
        hbci-interactionP.h
    gnucash/src/import-export/ofx:
        gnc-ofx-import.c
    gnucash/src/quotes:
        dump-finance-quote
    gnucash/src/report/locale-specific/us:
        Makefile.am
        gncmod-locale-reports-us.c
        us.scm
    gnucash/src/report/report-system:
        html-acct-table.scm
    gnucash/src/report/standard-reports:
        account-summary.scm
    gnucash/src/scm:
        main.scm
    gnucash/src/tax/us:
        Makefile.am
        gncmod-tax-us.c

Added Files:
-----------
    gnucash/src/import-export/hbci:
        HACKING-HBCITEST.txt
    gnucash/src/report/locale-specific/us:
        de_DE.scm
        taxtxf-de_DE.scm
    gnucash/src/tax/us:
        de_DE.scm
        txf-de_DE.scm
        txf-help-de_DE.scm

Revision Data
-------------
Index: qofid.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofid.h,v
retrieving revision 1.2.6.5
retrieving revision 1.2.6.6
diff -Lsrc/engine/qofid.h -Lsrc/engine/qofid.h -u -r1.2.6.5 -r1.2.6.6
--- src/engine/qofid.h
+++ src/engine/qofid.h
@@ -121,7 +121,7 @@
 @param e_type QofIdType
 @param is_dirty gboolean
 @param hash_of_entities GHashTable
- at param data gpointer, place where object class can hang arbitrari data
+ at param data gpointer, place where object class can hang arbitrary data
 
 */
 typedef struct QofCollection_s QofCollection;
Index: gnc-trace.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-trace.c,v
retrieving revision 1.2.20.9
retrieving revision 1.2.20.10
diff -Lsrc/engine/gnc-trace.c -Lsrc/engine/gnc-trace.c -u -r1.2.20.9 -r1.2.20.10
--- src/engine/gnc-trace.c
+++ src/engine/gnc-trace.c
@@ -73,14 +73,21 @@
 static FILE *fout = NULL;
 static const int MAX_TRACE_FILENAME = 100;
 
+/* Don't be fooled: gnc_trace_num_spaces has external linkage and
+   static storage, but can't be defined with 'extern' because it has
+   an initializer, and can't be declared with 'static' because that
+   would give it internal linkage. */
+gint __attribute__ ((unused)) gnc_trace_num_spaces = 0;
+
 static void
 fh_printer (const gchar   *log_domain,
             GLogLevelFlags    log_level,
             const gchar   *message,
             gpointer    user_data)
 {
+  extern gint gnc_trace_num_spaces;
   FILE *fh = user_data;
-  fprintf (fh, "%s\n", message);
+  fprintf (fh, "%*s%s\n", gnc_trace_num_spaces, "", message);
   fflush(fh);
 }
 
@@ -91,9 +98,11 @@
 
    fout = fopen ("/tmp/gnucash.trace", "w");
 
-   if(!fout && (filename = (char *)malloc(MAX_TRACE_FILENAME))) {
-      snprintf(filename, MAX_TRACE_FILENAME-1, "/tmp/gnucash.trace.%d", getpid());
+   if(!fout && (filename = (char *)g_malloc(MAX_TRACE_FILENAME))) {
+      snprintf(filename, MAX_TRACE_FILENAME-1, "/tmp/gnucash.trace.%d", 
+	       getpid());
       fout = fopen (filename, "w");
+      g_free(filename);
    }
 
    if(!fout)
Index: Scrub.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Scrub.c,v
retrieving revision 1.43.4.5
retrieving revision 1.43.4.6
diff -Lsrc/engine/Scrub.c -Lsrc/engine/Scrub.c -u -r1.43.4.5 -r1.43.4.6
--- src/engine/Scrub.c
+++ src/engine/Scrub.c
@@ -573,16 +573,21 @@
   }
   else if (!gnc_commodity_equiv (retval,trans->common_currency))
   {
-    PWARN ("expected common currency %s but found %s\n",
+    char guid_str[GUID_ENCODING_LENGTH+1];
+    guid_to_string_buff(xaccTransGetGUID(trans), guid_str);
+    PWARN ("expected common currency %s but found %s in txn %s\n",
            gnc_commodity_get_unique_name (trans->common_currency),
-           gnc_commodity_get_unique_name (retval));
+           gnc_commodity_get_unique_name (retval), guid_str);
   }
 
   if (NULL == retval)
   {
      /* In every situation I can think of, this routine should return 
       * common currency.  So make note of this ... */
-     PWARN ("unable to find a common currency, and that is strange.");
+     char guid_str[GUID_ENCODING_LENGTH+1];
+     guid_to_string_buff(xaccTransGetGUID(trans), guid_str);
+     PWARN ("unable to find a common currency in txn %s, and that is strange.",
+	    guid_str);
   }
 
   return retval;
@@ -623,7 +628,11 @@
     else
     {
       SplitList *node;
-      PWARN ("no common transaction currency found for trans=\"%s\"", trans->description);
+      char guid_str[GUID_ENCODING_LENGTH+1];
+      guid_to_string_buff(xaccTransGetGUID(trans), guid_str);
+      PWARN ("no common transaction currency found for trans=\"%s\" (%s)",
+	     trans->description, guid_str);
+
       for (node=trans->splits; node; node=node->next)
       {
         Split *split = node->data;
Index: gnc-trace.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-trace.h,v
retrieving revision 1.3.4.6
retrieving revision 1.3.4.7
diff -Lsrc/engine/gnc-trace.h -Lsrc/engine/gnc-trace.h -u -r1.3.4.6 -r1.3.4.7
--- src/engine/gnc-trace.h
+++ src/engine/gnc-trace.h
@@ -83,6 +83,8 @@
 
 //extern gncLogLevel gnc_log_modules[MOD_LAST + 1];
 
+#define GNC_TRACE_INDENT_WIDTH 4
+
 /** Initialize the error logging subsystem */
 void gnc_log_init (void);
 
@@ -105,7 +107,7 @@
 const char * gnc_log_prettify (const char *name);
 
 /* We want logging decisions to be made inline, rather than through
- * a CPU-cucking subroutine call. Thus, this is a #define, not a
+ * a CPU-sucking subroutine call. Thus, this is a #define, not a
  * subroutine call.  The prototype would have been:
  * gboolean gnc_should_log (gncModuleType module, gncLogLevel log_level); 
  *
@@ -160,7 +162,8 @@
 #define PINFO(format, args...) {                   \
   if (gnc_should_log (module, GNC_LOG_INFO)) {     \
     g_log (G_LOG_DOMAIN, G_LOG_LEVEL_INFO,         \
-      "Info: %s(): " format, FUNK , ## args);      \
+      "Info: %s(): " format,                       \
+      FUNK , ## args);                             \
   }                                                \
 }
 
@@ -168,23 +171,30 @@
 #define DEBUG(format, args...) {                   \
   if (gnc_should_log (module, GNC_LOG_DEBUG)) {    \
     g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,        \
-      "Debug: %s(): " format, FUNK , ## args);     \
+      "Debug: %s(): " format,                      \
+      FUNK , ## args);                             \
   }                                                \
 }
 
 /** Print an function entry debugging message */
 #define ENTER(format, args...) {                   \
+  extern gint gnc_trace_num_spaces;                \
   if (gnc_should_log (module, GNC_LOG_DEBUG)) {    \
     g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,        \
-      "Enter: %s" format, FUNK , ## args);         \
+      "Enter in %s: %s()" format, __FILE__,        \
+      FUNK , ## args);                             \
+    gnc_trace_num_spaces += GNC_TRACE_INDENT_WIDTH;\
   }                                                \
 }
 
 /** Print an function exit debugging message */
 #define LEAVE(format, args...) {                   \
+  extern gint gnc_trace_num_spaces;                \
   if (gnc_should_log (module, GNC_LOG_DEBUG)) {    \
+    gnc_trace_num_spaces -= GNC_TRACE_INDENT_WIDTH;\
     g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,        \
-      "Leave: %s" format, FUNK , ## args);         \
+      "Leave: %s()" format,                        \
+      FUNK , ## args);                             \
   }                                                \
 }
 
Index: qofsql.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofsql.c,v
retrieving revision 1.5.2.2
retrieving revision 1.5.2.3
diff -Lsrc/engine/qofsql.c -Lsrc/engine/qofsql.c -u -r1.5.2.2 -r1.5.2.3
--- src/engine/qofsql.c
+++ src/engine/qofsql.c
@@ -129,12 +129,13 @@
 static inline char * 
 dequote_string (char *str)
 {
+	size_t len;
 	/* strip out quotation marks ...  */
 	if (('\'' == str[0]) ||
 	    ('\"' == str[0]))
 	{
 		str ++;
-		size_t len = strlen(str);
+		len = strlen(str);
 		str[len-1] = 0;
 	}
 	return str;
@@ -145,7 +146,20 @@
 {
 	char tmpbuff[128];
 	GSList *param_list;
+	GList *guid_list;
 	QofQueryPredData *pred_data = NULL;
+	sql_field_item *sparam, *svalue;
+	char * qparam_name, *qvalue_name, *table_name, *param_name;
+	char *sep, *path,*str,*p;
+	QofQuery *qq;
+	KvpValue *kv, *kval;
+	KvpValueType kvt;
+	QofQueryCompare qop;
+	time_t exact;
+	int rc, len;
+	Timespec ts;
+	QofType param_type;
+	QofGuidMatch gm;
 	
 	if (NULL == cond)
 	{
@@ -161,14 +175,14 @@
 		PWARN("missing left paramter");
 		return NULL;
 	}
-	sql_field_item * sparam = cond->d.pair.left->item;
+	sparam = cond->d.pair.left->item;
 	if (SQL_name != sparam->type)
 	{
 		PWARN("we support only paramter names at this time (parsed %d)",
           sparam->type);
 		return NULL;
 	}
-	char * qparam_name = sparam->d.name->data;
+	qparam_name = sparam->d.name->data;
 	if (NULL == qparam_name)
 	{
 		PWARN ("missing paramter name");
@@ -183,13 +197,13 @@
 		PWARN ("missing right paramter");
 		return NULL;
 	}
-	sql_field_item * svalue = cond->d.pair.right->item;
+	svalue = cond->d.pair.right->item;
 	if (SQL_name != svalue->type)
 	{
 		PWARN("we support only simple values (parsed as %d)", svalue->type);
 		return NULL;
 	}
-	char * qvalue_name = svalue->d.name->data;
+	qvalue_name = svalue->d.name->data;
 	if (NULL == qvalue_name)
 	{
 		PWARN("missing value");
@@ -207,11 +221,11 @@
 			PWARN ("missing kvp frame");
 			return NULL;
 		}
-		KvpValue *kv = kvp_frame_get_value (query->kvp_join, qvalue_name+5);
+		kv = kvp_frame_get_value (query->kvp_join, qvalue_name+5);
 		/* If there's no value, its not an error; 
 		 * we just don't do this predicate */
 		if (!kv) return NULL;  
-		KvpValueType kvt = kvp_value_get_type (kv);
+		kvt = kvp_value_get_type (kv);
 
 		tmpbuff[0] = 0x0;
 		qvalue_name = tmpbuff;
@@ -251,7 +265,6 @@
 	param_list = qof_query_build_param_list (qparam_name, NULL);
 
 	/* Get the where-term comparison operator */
-	QofQueryCompare qop;
 	switch (cond->op)
 	{
 		case SQL_eq:    qop = QOF_COMPARE_EQUAL; break;
@@ -270,8 +283,6 @@
 	/* OK, need to know the type of the thing being matched 
 	 * in order to build the correct predicate.  Get the type 
 	 * from the object parameters. */
-	char *table_name;
-	char *param_name;
 	get_table_and_param (qparam_name, &table_name, &param_name);
 	if (NULL == table_name)
 	{
@@ -290,7 +301,7 @@
 		return NULL;
 	}
 
-	QofType param_type = qof_class_get_parameter_type (table_name, param_name);
+	param_type = qof_class_get_parameter_type (table_name, param_name);
 	if (!param_type) 
 	{
 		PWARN ("The parameter \'%s\' on object \'%s\' is not known", 
@@ -339,14 +350,12 @@
 		/* work around highly bogus locale setting */
 		qof_date_format_set(QOF_DATE_FORMAT_US);
 
-		time_t exact;
-		int rc = qof_scan_date_secs (qvalue_name, &exact);
+		rc= qof_scan_date_secs (qvalue_name, &exact);
 		if (0 == rc) 
 		{
 			PWARN ("unable to parse date: %s", qvalue_name);
 			return NULL;
 		}
-		Timespec ts;
 		ts.tv_sec = exact;
 		ts.tv_nsec = 0;
 		pred_data = qof_query_date_predicate (qop, QOF_DATE_MATCH_DAY, ts);
@@ -377,9 +386,9 @@
 		// XXX less, than greater than don't make sense,
 		// should check for those bad conditions
 
-		QofGuidMatch gm = QOF_GUID_MATCH_ANY;
+		gm = QOF_GUID_MATCH_ANY;
 		if (QOF_COMPARE_NEQ == qop) gm = QOF_GUID_MATCH_NONE;
-		GList *guid_list = g_list_append (NULL, &guid);
+		guid_list = g_list_append (NULL, &guid);
 		pred_data = qof_query_guid_predicate (gm, guid_list);
 
 		g_list_free (guid_list);
@@ -389,12 +398,11 @@
 		/* We are expecting an encoded value that looks like
 		 * /some/path/string:value
 		 */
-		char *sep = strchr (qvalue_name, ':');
+		sep = strchr (qvalue_name, ':');
 		if (!sep) return NULL;
 		*sep = 0;
-		char * path = qvalue_name;
-		char * str = sep +1;
-		char * p;
+		path = qvalue_name;
+		str = sep +1;
 		/* If str has only digits, we know its a plain number.
 		 * If its numbers and a decimal point, assume a float
 		 * If its numbers and a slash, assume numeric
@@ -402,8 +410,8 @@
 		 * If it looks like an iso date ... 
 		 * else assume its a string.
 		 */
-		KvpValue *kval = NULL;
-		int len = strlen (str);
+		kval = NULL;
+		len = strlen (str);
 		if ((32 == len) && (32 == strspn (str, "0123456789abcdef")))
 		{
 			GUID guid;
@@ -455,7 +463,7 @@
 		return NULL;
 	}
 
-	QofQuery *qq = qof_query_create();
+	qq = qof_query_create();
 	qof_query_add_term (qq, param_list, pred_data, QOF_QUERY_FIRST_TERM);
 	return qq;
 }
@@ -465,6 +473,9 @@
 static QofQuery *
 handle_where (QofSqlQuery *query, sql_where *swear)
 {
+	QofQueryOp qop;
+	QofQuery * qq;
+	
 	switch (swear->type)
 	{
 		case SQL_pair:
@@ -473,7 +484,6 @@
 			QofQuery *qright = handle_where (query, swear->d.pair.right);
 			if (NULL == qleft) return qright;
 			if (NULL == qright) return qleft;
-			QofQueryOp qop;
 			switch (swear->d.pair.op)
 			{
 				case SQL_and: qop = QOF_QUERY_AND; break;
@@ -484,7 +494,7 @@
 					qof_query_destroy (qright);
 					return NULL;
 			}
-			QofQuery * qq = qof_query_merge (qleft, qright, qop);
+			qq = qof_query_merge (qleft, qright, qop);
 			qof_query_destroy (qleft);
 			qof_query_destroy (qright);
 			return qq;
@@ -511,11 +521,14 @@
 static void 
 handle_sort_order (QofSqlQuery *query, GList *sorder_list)
 {
-	if (!sorder_list) return;
-
 	GSList *qsp[3];
+	GList *n;
 	gboolean direction[3];
 	int i;
+	sql_order_field *sorder;
+	char * qparam_name;
+	
+	if (!sorder_list) return;
 
 	for (i=0; i<3; i++)
 	{
@@ -524,14 +537,14 @@
 
 		if (sorder_list)
 		{
-			sql_order_field *sorder = sorder_list->data;
+			sorder = sorder_list->data;
 
 			/* Set the sort direction */
 			if (SQL_asc == sorder->order_type) direction[i] = TRUE;
 
 			/* Find the paramter name */
-			char * qparam_name = NULL;
-			GList *n = sorder->name;
+			qparam_name = NULL;
+			n = sorder->name;
 			if (n)
 			{
 				qparam_name = n->data;
@@ -559,6 +572,10 @@
 void 
 qof_sql_query_parse (QofSqlQuery *query, const char *str)
 {
+	GList *tables;
+	sql_select_statement *sss;
+	sql_where *swear;
+	
 	if (!query) return;
 
 	/* Delete old query, if any */
@@ -590,14 +607,14 @@
 	 * user wrote "SELECT * FROM tableA, tableB WHERE ..."
 	 * then we don't have a single unique table-name.
 	 */
-	GList *tables = sql_statement_get_tables (query->parse_result);
+	tables = sql_statement_get_tables (query->parse_result);
 	if (1 == g_list_length (tables))
 	{
 		query->single_global_tablename = tables->data;
 	}
 
-	sql_select_statement *sss = query->parse_result->statement;
-	sql_where * swear = sss->where;
+	sss = query->parse_result->statement;
+	swear = sss->where;
 	if (swear)
 	{
 		/* Walk over the where terms, turn them into QOF predicates */
@@ -625,7 +642,7 @@
 GList * 
 qof_sql_query_run (QofSqlQuery *query, const char *str)
 {
-	GList *node;
+	GList *node, *results;
 
 	if (!query) return NULL;
 
@@ -635,7 +652,7 @@
 	qof_query_set_book (query->qof_query, query->book);
 
 	// qof_query_print (query->qof_query);
-	GList *results = qof_query_run (query->qof_query);
+	results = qof_query_run (query->qof_query);
 
 	return results;
 }
@@ -643,7 +660,7 @@
 GList * 
 qof_sql_query_rerun (QofSqlQuery *query)
 {
-	GList *node;
+	GList *node, *results;
 
 	if (!query) return NULL;
 
@@ -652,7 +669,7 @@
 	qof_query_set_book (query->qof_query, query->book);
 
 	// qof_query_print (query->qof_query);
-	GList *results = qof_query_run (query->qof_query);
+	results = qof_query_run (query->qof_query);
 
 	return results;
 }
Index: AccountP.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/AccountP.h,v
retrieving revision 1.54.4.2
retrieving revision 1.54.4.3
diff -Lsrc/engine/AccountP.h -Lsrc/engine/AccountP.h -u -r1.54.4.2 -r1.54.4.3
--- src/engine/AccountP.h
+++ src/engine/AccountP.h
@@ -62,6 +62,8 @@
  * This is the *private* header for the account structure.
  * No one outside of the engine should ever include this file.
 */
+
+/** \struct Account */
 struct account_s
 {
   QofInstance inst;
Index: qofsession-p.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofsession-p.h,v
retrieving revision 1.2.4.2
retrieving revision 1.2.4.3
diff -Lsrc/engine/qofsession-p.h -Lsrc/engine/qofsession-p.h -u -r1.2.4.2 -r1.2.4.3
--- src/engine/qofsession-p.h
+++ src/engine/qofsession-p.h
@@ -32,18 +32,20 @@
 #include "qofbook.h"
 #include "qofsession.h"
 
+/** \struct QofSession
+*/
 struct _QofSession
 {
-  /* A book holds pointers to the various types of datasets used
+  /** A book holds pointers to the various types of datasets used
    * by GnuCash.  A session may have open multiple books.  */
   GList *books;
 
-  /* The requested book id, in the form or a URI, such as
+  /** The requested book id, in the form or a URI, such as
    * file:/some/where, or sql:server.host.com:555
    */
   char *book_id;
 
-  /* If any book subroutine failed, this records the failure reason 
+  /** If any book subroutine failed, this records the failure reason 
    * (file not found, etc).
    * This is a 'stack' that is one deep.  (Should be deeper ??)
    * FIXME: Each backend has its own error stack. The session
@@ -54,7 +56,7 @@
   char *error_message;
 
   /* ---------------------------------------------------- */
-  /* Pointer to the backend that is actually used to move data
+  /** Pointer to the backend that is actually used to move data
    * between the persistant store and the local engine.  */
   QofBackend *backend;
 };
@@ -68,4 +70,3 @@
 QofBackend* gncBackendInit_file(const char *book_id, void *data);
 
 #endif
-
Index: guid.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/guid.c,v
retrieving revision 1.25.4.7
retrieving revision 1.25.4.8
diff -Lsrc/engine/guid.c -Lsrc/engine/guid.c -u -r1.25.4.7 -r1.25.4.8
--- src/engine/guid.c
+++ src/engine/guid.c
@@ -503,7 +503,7 @@
   counter--;
 }
 
-const GUID
+GUID
 guid_new_return(void)
 {
   GUID guid;
Index: qofquery-deserial.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofquery-deserial.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Lsrc/engine/qofquery-deserial.c -Lsrc/engine/qofquery-deserial.c -u -r1.1.2.1 -r1.1.2.2
--- src/engine/qofquery-deserial.c
+++ src/engine/qofquery-deserial.c
@@ -182,11 +182,15 @@
 static QofQueryPredData *                                       \
 SUBRNAME (xmlNodePtr root)                                      \
 {                                                               \
-	xmlNodePtr xp = root->xmlChildrenNode;                       \
+	QofQueryPredData *pred;                                      \
+	xmlNodePtr xp;												\
 	xmlNodePtr node;                                             \
+	QofQueryCompare how;										\
+	CTYPE val;													\
+	xp = root->xmlChildrenNode;									\
                                                                 \
-	QofQueryCompare how = QOF_COMPARE_EQUAL;                     \
-	CTYPE val = 0;                                               \
+	how = QOF_COMPARE_EQUAL;									\
+	val = 0;                                               \
                                                                 \
 	for (node=xp; node; node = node->next)                       \
 	{                                                            \
@@ -197,7 +201,6 @@
 		{}                                                        \
 	}                                                            \
                                                                 \
-	QofQueryPredData *pred;                                      \
 	pred = PRED (how, val);                                      \
 	return pred;                                                 \
 }
@@ -245,12 +248,17 @@
 static QofQueryPredData *
 qof_query_pred_kvp_from_xml (xmlNodePtr root)
 {
-	xmlNodePtr xp = root->xmlChildrenNode;
+	QofQueryCompare how;
+	GSList *path;
+	KvpValue *value;
+	QofQueryPredData *pred;
+	xmlNodePtr xp;
 	xmlNodePtr node;
 
-	QofQueryCompare how = QOF_COMPARE_EQUAL;
-	GSList *path = NULL;
-	KvpValue *value = NULL;
+	how = QOF_COMPARE_EQUAL;
+	xp = root->xmlChildrenNode;
+	path = NULL;
+	value = NULL;
 
 	for (node=xp; node; node = node->next)
 	{
@@ -271,7 +279,6 @@
 		GET_DATE(&value,    wrap_new_timespec, "qofquery:date");
 	}
 
-	QofQueryPredData *pred;
 	pred = qof_query_kvp_predicate (how, path, value);
 	g_slist_free (path);
 	return pred;
@@ -282,12 +289,18 @@
 static QofQueryPredData *
 qof_query_pred_guid_from_xml (xmlNodePtr root)
 {
-	xmlNodePtr xp = root->xmlChildrenNode;
+	GList *guid_list, *n;
+	const char *str;
+	GUID *guid;
+	gboolean decode;
+	QofQueryPredData *pred;
+	QofGuidMatch sm;
+	xmlNodePtr xp;
 	xmlNodePtr node;
-   GList *guid_list = NULL;
-
-	QofGuidMatch sm = QOF_GUID_MATCH_ANY;
+	guid_list = NULL;
 
+	sm = QOF_GUID_MATCH_ANY;
+	xp = root->xmlChildrenNode;
 	for (node=xp; node; node = node->next)
 	{
 		if (node->type != XML_ELEMENT_NODE) continue;
@@ -298,9 +311,9 @@
 
 		if (0 == strcmp ("qofquery:guid", node->name))
 		{
-			const char *str = GET_TEXT (node);
-			GUID *guid = guid_malloc ();
-			gboolean decode = string_to_guid (str, guid);
+			str = GET_TEXT (node);
+			guid = guid_malloc ();
+			decode = string_to_guid (str, guid);
 			if (decode)
 			{
 				guid_list = g_list_append (guid_list, guid);
@@ -313,11 +326,9 @@
 		}
 	}
 
-	QofQueryPredData *pred;
 	pred = qof_query_guid_predicate (sm, guid_list);
 
 	/* The predicate made a copy of everything, so free our stuff */
-   GList *n;
 	for (n=guid_list; n; n=n->next)
 	{
 		guid_free (n->data);
@@ -331,11 +342,15 @@
 static QofQueryPredData *
 qof_query_pred_char_from_xml (xmlNodePtr root)
 {
-	xmlNodePtr xp = root->xmlChildrenNode;
+	QofQueryPredData *pred;
+	QofCharMatch sm;
+	const char * char_list;
+	xmlNodePtr xp;
 	xmlNodePtr node;
 
-	QofCharMatch sm = QOF_CHAR_MATCH_ANY;
-   const char * char_list = NULL;
+    char_list = NULL;
+	xp = root->xmlChildrenNode;
+	sm = QOF_CHAR_MATCH_ANY;
 
 	for (node=xp; node; node = node->next)
 	{
@@ -348,7 +363,6 @@
 		{}
 	}
 
-	QofQueryPredData *pred;
 	pred = qof_query_char_predicate (sm, char_list);
 	return pred;
 }
@@ -358,12 +372,16 @@
 static QofQueryPredData *
 qof_query_pred_numeric_from_xml (xmlNodePtr root)
 {
-	xmlNodePtr xp = root->xmlChildrenNode;
+	QofQueryPredData *pred;
 	xmlNodePtr node;
-
-	QofQueryCompare how = QOF_COMPARE_EQUAL;
-	QofNumericMatch sm = QOF_NUMERIC_MATCH_ANY;
+	QofQueryCompare how;
+	QofNumericMatch sm;
    gnc_numeric num;
+	xmlNodePtr xp;
+	
+	xp = root->xmlChildrenNode;
+	how = QOF_COMPARE_EQUAL;
+	sm = QOF_NUMERIC_MATCH_ANY;
 
 	for (node=xp; node; node = node->next)
 	{
@@ -376,7 +394,6 @@
 		{}
 	}
 
-	QofQueryPredData *pred;
 	pred = qof_query_numeric_predicate (how, sm, num);
 	return pred;
 }
@@ -386,12 +403,18 @@
 static QofQueryPredData *
 qof_query_pred_date_from_xml (xmlNodePtr root)
 {
-	xmlNodePtr xp = root->xmlChildrenNode;
+	xmlNodePtr xp;
 	xmlNodePtr node;
+	QofQueryCompare how;
+	QofDateMatch sm;
+	Timespec date;
+	QofQueryPredData *pred;
+	
+	xp = root->xmlChildrenNode;
 
-	QofQueryCompare how = QOF_COMPARE_EQUAL;
-	QofDateMatch sm = QOF_DATE_MATCH_ROUNDED;
-	Timespec date = {0,0};
+	how = QOF_COMPARE_EQUAL;
+	sm = QOF_DATE_MATCH_ROUNDED;
+	date = (Timespec){0,0};
 
 	for (node=xp; node; node = node->next)
 	{
@@ -404,7 +427,6 @@
 		{}
 	}
 
-	QofQueryPredData *pred;
 	pred = qof_query_date_predicate (how, sm, date);
 	return pred;
 }
@@ -414,13 +436,19 @@
 static QofQueryPredData *
 qof_query_pred_string_from_xml (xmlNodePtr root)
 {
-	xmlNodePtr xp = root->xmlChildrenNode;
+	QofQueryPredData *pred;
+	xmlNodePtr xp;
 	xmlNodePtr node;
-
-	QofQueryCompare how = QOF_COMPARE_EQUAL;
-	QofStringMatch sm = QOF_STRING_MATCH_CASEINSENSITIVE;
-	gboolean is_regex = FALSE;
-	const char *pstr = NULL;
+	QofQueryCompare how;
+	QofStringMatch sm;
+	gboolean is_regex;
+	const char *pstr;
+	
+	xp = root->xmlChildrenNode;
+	how = QOF_COMPARE_EQUAL;
+	sm = QOF_STRING_MATCH_CASEINSENSITIVE;
+	is_regex = FALSE;
+	pstr = NULL;
 
 	for (node=xp; node; node = node->next)
 	{
@@ -433,8 +461,6 @@
 		            STRING_MATCH, NORMAL, CASEINSENSITIVE);
 		{}
 	}
-
-	QofQueryPredData *pred;
 	pred = qof_query_string_predicate (how, pstr, sm , is_regex);
 	return pred;
 }
@@ -444,9 +470,12 @@
 static GSList * 
 qof_query_param_path_from_xml (xmlNodePtr root)
 {
-	xmlNodePtr pterms = root->xmlChildrenNode;
-	GSList *plist = NULL;
+	xmlNodePtr pterms;
+	GSList *plist;
 	xmlNodePtr node;
+
+	pterms = root->xmlChildrenNode;
+	plist = NULL;
 	for (node=pterms; node; node = node->next)
 	{
 		if (node->type != XML_ELEMENT_NODE) continue;
@@ -466,18 +495,23 @@
 qof_query_term_from_xml (QofQuery *q, xmlNodePtr root)
 {
 	xmlNodePtr node;
-	xmlNodePtr term = root->xmlChildrenNode;
-	QofQueryPredData *pred = NULL;
-	GSList *path = NULL;
-
+	xmlNodePtr term;
+	QofQueryPredData *pred;
+	GSList *path;
+	QofQuery *qt;
+	QofQuery *qinv;
+	
+	pred = NULL;
+	path = NULL;
+	term = root->xmlChildrenNode;
 	for (node=term; node; node = node->next)
 	{
 		if (node->type != XML_ELEMENT_NODE) continue;
 		if (0 == strcmp (node->name, "qofquery:invert"))
 		{
-			QofQuery *qt = qof_query_create();
+			qt = qof_query_create();
 			qof_query_term_from_xml (qt, node);
-			QofQuery *qinv = qof_query_invert (qt);
+			qinv = qof_query_invert (qt);
 			qof_query_merge_in_place (q, qinv, QOF_QUERY_AND);
 			qof_query_destroy (qinv);
 			qof_query_destroy (qt);
@@ -553,8 +587,10 @@
 static void 
 qof_query_and_terms_from_xml (QofQuery *q, xmlNodePtr root)
 {
-	xmlNodePtr andterms = root->xmlChildrenNode;
+	xmlNodePtr andterms;
 	xmlNodePtr node;
+	
+	andterms = root->xmlChildrenNode;
 	for (node=andterms; node; node = node->next)
 	{
 		if (node->type != XML_ELEMENT_NODE) continue;
@@ -571,16 +607,18 @@
 static void 
 qof_query_or_terms_from_xml (QofQuery *q, xmlNodePtr root)
 {
-	xmlNodePtr andterms = root->xmlChildrenNode;
+	xmlNodePtr andterms;
 	xmlNodePtr node;
+	QofQuery *qand;
 
+	andterms = root->xmlChildrenNode;
 	for (node=andterms; node; node = node->next)
 	{
 		if (node->type != XML_ELEMENT_NODE) continue;
 
 		if (0 == strcmp (node->name, "qofquery:and-terms"))
 		{
-			QofQuery *qand = qof_query_create ();
+			qand = qof_query_create ();
 			qof_query_and_terms_from_xml (qand, node);
 			qof_query_merge_in_place (q, qand, QOF_QUERY_OR);
 			qof_query_destroy (qand);
@@ -594,10 +632,13 @@
 qof_query_from_xml (xmlNodePtr root)
 {
 	QofQuery *q;
+	xmlChar *version;
+	xmlNodePtr qpart;
+	xmlNodePtr node;
 
 	if (!root) return NULL;
 
-	xmlChar * version = xmlGetProp(root, "version");
+	version = xmlGetProp(root, "version");
    if (!root->name || strcmp ("qof:qofquery", root->name))
    {
 		// XXX something is wrong. warn ... 
@@ -606,8 +647,7 @@
 
 	q = qof_query_create ();
 
-	xmlNodePtr qpart = root->xmlChildrenNode;
-	xmlNodePtr node;
+	qpart = root->xmlChildrenNode;
 	for (node=qpart; node; node = node->next)
 	{
 		if (node->type != XML_ELEMENT_NODE) continue;
@@ -643,6 +683,7 @@
 {
 	QofQuery *q, *qnew;
 	QofSqlQuery *sq;
+	xmlNodePtr topnode;
 
 	guid_init();
 	qof_query_init();
Index: gnc-numeric.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-numeric.c,v
retrieving revision 1.26.4.6
retrieving revision 1.26.4.7
diff -Lsrc/engine/gnc-numeric.c -Lsrc/engine/gnc-numeric.c -u -r1.26.4.6 -r1.26.4.7
--- src/engine/gnc-numeric.c
+++ src/engine/gnc-numeric.c
@@ -725,6 +725,9 @@
   double      sigfigs;
   qofint128 nume, newm;
 
+  temp.num   = 0;
+  temp.denom = 0;
+
   if(gnc_numeric_check(in)) {
     return gnc_numeric_error(GNC_ERROR_ARG);
   }
Index: Account.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Account.c,v
retrieving revision 1.222.4.11
retrieving revision 1.222.4.12
diff -Lsrc/engine/Account.c -Lsrc/engine/Account.c -u -r1.222.4.11 -r1.222.4.12
--- src/engine/Account.c
+++ src/engine/Account.c
@@ -1255,7 +1255,8 @@
    xaccAccountCommitEdit(acc);
 }
 
-void qofAccountSetParent (Account *acc, QofEntity *parent) 
+static void
+qofAccountSetParent (Account *acc, QofEntity *parent) 
 {
 	Account *parent_acc;
 	
Index: Account.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Account.h,v
retrieving revision 1.110.4.10
retrieving revision 1.110.4.11
diff -Lsrc/engine/Account.h -Lsrc/engine/Account.h -u -r1.110.4.10 -r1.110.4.11
--- src/engine/Account.h
+++ src/engine/Account.h
@@ -214,19 +214,6 @@
 void xaccAccountSetLastNum (Account *account, const char *num);
 /** Set the account's type */
 GNCAccountType xaccAccountGetType (Account *account);
-/** \brief Special function only for qof_book_merge
-
-qofAccountSetParent uses a specific QofEntity that is
-set during a qof_book_merge and it refers to the
-corresponding QofEntity in the target book. This is used
-to link new accounts into an existing AccountGroup. The
-parent reference is only changed if no parent exists.
-
-Care is needed before this function can be used in any
-other manner.
-*/
-void qofAccountSetParent (Account *, QofEntity *);
-
 const char* qofAccountGetTypeString (Account *acc);
 void qofAccountSetType (Account *acc, const char *type_string);
 
Index: Transaction.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Transaction.c,v
retrieving revision 1.261.4.8
retrieving revision 1.261.4.9
diff -Lsrc/engine/Transaction.c -Lsrc/engine/Transaction.c -u -r1.261.4.8 -r1.261.4.9
--- src/engine/Transaction.c
+++ src/engine/Transaction.c
@@ -3273,7 +3273,7 @@
 {
   static const QofParam params[] = {
     { SPLIT_DATE_RECONCILED, QOF_TYPE_DATE,
-      (QofAccessFunc)xaccSplitRetDateReconciledTS, NULL },
+	(QofAccessFunc)xaccSplitRetDateReconciledTS, 	(QofSetterFunc)xaccSplitSetDateReconciledTS },
 
     /* d-* are depricated query params, should not be used in new
      * queries, should be removed from old queries. */
Index: qofsession.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofsession.c,v
retrieving revision 1.2.4.14
retrieving revision 1.2.4.15
diff -Lsrc/engine/qofsession.c -Lsrc/engine/qofsession.c -u -r1.2.4.14 -r1.2.4.15
--- src/engine/qofsession.c
+++ src/engine/qofsession.c
@@ -313,8 +313,6 @@
    return session->book_id;
 }
 
-/* =============================================================== */
-
 typedef struct qof_entity_copy_data {
 	QofEntity *from;
 	QofEntity *to;
Index: Group.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/Group.h,v
retrieving revision 1.64.4.4
retrieving revision 1.64.4.5
diff -Lsrc/engine/Group.h -Lsrc/engine/Group.h -u -r1.64.4.4 -r1.64.4.5
--- src/engine/Group.h
+++ src/engine/Group.h
@@ -78,7 +78,13 @@
 /** Return the book to which this account belongs */
 QofBook * xaccGroupGetBook (AccountGroup *group);
 
-/** DOCUMENT ME! */
+/** Compare two account groups
+
+warns if one is NULL, if one has no accounts or if the two
+groups have different numbers of accounts.
+
+ at return TRUE if the two account groups are equal, FALSE otherwise.
+*/
 gboolean xaccGroupEqual(AccountGroup *a, AccountGroup *b,
                         gboolean check_guids);
 
Index: gnc-lot.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-lot.c,v
retrieving revision 1.14.4.6
retrieving revision 1.14.4.7
diff -Lsrc/engine/gnc-lot.c -Lsrc/engine/gnc-lot.c -u -r1.14.4.6 -r1.14.4.7
--- src/engine/gnc-lot.c
+++ src/engine/gnc-lot.c
@@ -361,9 +361,31 @@
 
 /* ============================================================= */
 
+/* change prototype of gnc_lot_register to return a gboolean
+and set a foreach 
+before enabling the object description. */
+/*
+static QofObject gncLotDesc =
+{
+interface_version:  QOF_OBJECT_VERSION,
+e_type:             GNC_ID_LOT,
+type_label:         "Lot",
+create:             (gpointer)gnc_lot_new,
+book_begin:         NULL,
+book_end:           NULL,
+is_dirty:           NULL,
+mark_clean:         NULL,
+foreach:            NULL,
+printable:          NULL,
+version_cmp:        NULL,
+};
+*/
+
 void gnc_lot_register (void)
 {
   static const QofParam params[] = {
+	{ LOT_TITLE, 		QOF_TYPE_STRING,	(QofAccessFunc)gnc_lot_get_title, 		(QofSetterFunc)gnc_lot_set_title },
+	{ LOT_NOTES,		QOF_TYPE_STRING,	(QofAccessFunc)gnc_lot_get_notes,		(QofSetterFunc)gnc_lot_set_notes },
     { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_entity_get_guid, NULL },
     { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)gnc_lot_get_book, NULL },
     { LOT_IS_CLOSED, QOF_TYPE_BOOLEAN, (QofAccessFunc)gnc_lot_is_closed, NULL },
@@ -372,6 +394,9 @@
   };
 
   qof_class_register (GNC_ID_LOT, NULL, params);
+  
+//  return qof_object_register(&gncLotDesc);
+
 }
 
 /* ========================== END OF FILE ========================= */
Index: kvp_frame.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/kvp_frame.c,v
retrieving revision 1.30.4.7
retrieving revision 1.30.4.8
diff -Lsrc/engine/kvp_frame.c -Lsrc/engine/kvp_frame.c -u -r1.30.4.7 -r1.30.4.8
--- src/engine/kvp_frame.c
+++ src/engine/kvp_frame.c
@@ -498,6 +498,7 @@
   KvpValue * old_value;
   char *last_key;
 
+  last_key = NULL;
   if (new_value)
   {
      frame = get_trailer_make (frame, key_path, &last_key);
Index: qof_book_merge.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qof_book_merge.c,v
retrieving revision 1.2.2.4
retrieving revision 1.2.2.5
diff -Lsrc/engine/qof_book_merge.c -Lsrc/engine/qof_book_merge.c -u -r1.2.2.4 -r1.2.2.5
--- src/engine/qof_book_merge.c
+++ src/engine/qof_book_merge.c
@@ -97,11 +97,11 @@
 		g_slist_free(currentRule->linkedEntList);
 		g_slist_free(currentRule->mergeParam);
 		g_free(mergeData->mergeList->data);
-		if(currentRule) {
-			g_slist_free(currentRule->linkedEntList);
-			g_slist_free(currentRule->mergeParam);
-			g_free(currentRule);
-		}
+	if(currentRule) {
+		g_slist_free(currentRule->linkedEntList);
+		g_slist_free(currentRule->mergeParam);
+		g_free(currentRule);
+	}
 		mergeData->mergeList = g_list_next(mergeData->mergeList);
 	}
 	g_list_free(mergeData->mergeList);
@@ -112,7 +112,9 @@
 	g_free(mergeData);
 }
 
-/*
+/*  Q: This could be a general usage function:
+	qof_param_as_string(QofParam*, QofEntity*);
+	Useful? Worth transferring to qofclass.c?
 	Need to fix the KVP->string. How?
 
 	The QOF_TYPE_DATE output format from
@@ -128,19 +130,18 @@
 char*
 qof_book_merge_param_as_string(QofParam *qtparam, QofEntity *qtEnt)
 {
-	gchar       *param_string, param_date[QOF_DATE_STRING_LENGTH];
-	char        param_sa[GUID_ENCODING_LENGTH + 1];
-	KvpFrame    *param_kvp;
-	QofType     paramType;
+	gchar 		*param_string, param_date[QOF_DATE_STRING_LENGTH];
+	char 		param_sa[GUID_ENCODING_LENGTH + 1];
+	KvpFrame 	*param_kvp;
+	QofType 	paramType;
 	const GUID *param_guid;
-	time_t      param_t;
-	gnc_numeric param_numeric,  (*numeric_getter) (QofEntity*, QofParam*);
-	Timespec    param_ts,       (*date_getter)    (QofEntity*, QofParam*);
-	double      param_double,   (*double_getter)  (QofEntity*, QofParam*);
-	gboolean    param_boolean,  (*boolean_getter) (QofEntity*, QofParam*);
-	gint32      param_i32,      (*int32_getter)   (QofEntity*, QofParam*);
-	gint64      param_i64,      (*int64_getter)   (QofEntity*, QofParam*);
-	char        param_char,     (*char_getter)    (QofEntity*, QofParam*);
+	time_t 		param_t;
+	gnc_numeric param_numeric, 	(*numeric_getter)	(QofEntity*, QofParam*);
+	Timespec 	param_ts, 		(*date_getter)		(QofEntity*, QofParam*);
+	double 		param_double, 	(*double_getter)	(QofEntity*, QofParam*);
+	gboolean 	param_boolean, 	(*boolean_getter)	(QofEntity*, QofParam*);
+	gint32 		param_i32, 		(*int32_getter)		(QofEntity*, QofParam*);
+	gint64 		param_i64, 		(*int64_getter)		(QofEntity*, QofParam*);
 	
 	param_string = NULL;
 	paramType = qtparam->param_type;
@@ -204,9 +205,7 @@
 			return param_string;
 		}
 		if(safe_strcmp(paramType, QOF_TYPE_CHAR) == 0) { 
-			char_getter = (char (*)(QofEntity*, QofParam*)) qtparam->param_getfcn;
-			param_char = char_getter(qtEnt, qtparam);
-			param_string = g_strdup_printf("%c", param_char);
+			param_string = g_strdup(qtparam->param_getfcn(qtEnt,qtparam));
 			return param_string;
 		}
 	return NULL;
@@ -223,7 +222,7 @@
 	g_return_val_if_fail((tag != MERGE_REPORT), NULL);
 	resolved = mergeData->currentRule;
 	g_return_val_if_fail((resolved != NULL), NULL);
-	if((resolved->mergeAbsolute == TRUE)&&(tag == MERGE_DUPLICATE))
+	if((resolved->mergeAbsolute == TRUE)&&(tag == MERGE_DUPLICATE)) 	
 	{ 
 		tag = MERGE_ABSOLUTE; 
 	}
@@ -231,7 +230,7 @@
 	{
 		tag = MERGE_UPDATE; 
 	}
-	if((resolved->mergeAbsolute == FALSE)&&	(tag == MERGE_ABSOLUTE))
+	if((resolved->mergeAbsolute == FALSE)&&	(tag == MERGE_ABSOLUTE)) 	
 	{ 
 		tag = MERGE_DUPLICATE; 
 	}
@@ -239,7 +238,7 @@
 	{ 
 		tag = MERGE_NEW; 
 	}
-	if(resolved->updated == FALSE) { resolved->mergeResult = tag; }
+	if(resolved->updated == FALSE) { resolved->mergeResult = tag;	}
 	resolved->updated = TRUE;
 	if(tag >= MERGE_INVALID) { 
 		mergeData->abort = TRUE;
@@ -351,22 +350,21 @@
 qof_book_mergeCompare( qof_book_mergeData *mergeData ) 
 {
 	qof_book_mergeRule *currentRule;
-
-	gchar      *stringImport, *stringTarget, *charImport, *charTarget;
-	QofEntity  *mergeEnt, *targetEnt, *referenceEnt;
-	const GUID *guidImport, *guidTarget;
-	QofParam   *qtparam;
-	KvpFrame   *kvpImport, *kvpTarget;
-	QofIdType  mergeParamName;
-	QofType    mergeType;
-	GSList    *paramList;
-	gboolean  absolute, mergeError, knowntype, mergeMatch, booleanImport, booleanTarget,
-                                                 (*boolean_getter) (QofEntity*, QofParam*);
-	Timespec      tsImport, tsTarget,            (*date_getter)    (QofEntity*, QofParam*);
-	gnc_numeric   numericImport, numericTarget,  (*numeric_getter) (QofEntity*, QofParam*);
-	double        doubleImport, doubleTarget,    (*double_getter)  (QofEntity*, QofParam*);
-	gint32        i32Import, i32Target,          (*int32_getter)   (QofEntity*, QofParam*);
-	gint64        i64Import, i64Target,          (*int64_getter)   (QofEntity*, QofParam*);
+	gchar 			*stringImport, *stringTarget, *charImport, *charTarget;
+	QofEntity	 	*mergeEnt, *targetEnt, *referenceEnt;
+	const GUID 		*guidImport, *guidTarget;
+	QofParam 		*qtparam;
+	KvpFrame 		*kvpImport, *kvpTarget;
+	QofIdType 		mergeParamName;
+	QofType 		mergeType;
+	GSList 			*paramList;
+	gboolean	 	absolute, mergeError, knowntype, mergeMatch, booleanImport, booleanTarget,
+													(*boolean_getter)	(QofEntity*, QofParam*);
+	Timespec 		tsImport, tsTarget, 			(*date_getter)		(QofEntity*, QofParam*);
+	gnc_numeric 	numericImport, numericTarget, 	(*numeric_getter)	(QofEntity*, QofParam*);
+	double 			doubleImport, doubleTarget, 	(*double_getter)	(QofEntity*, QofParam*);
+	gint32 			i32Import, i32Target, 			(*int32_getter)		(QofEntity*, QofParam*);
+	gint64 			i64Import, i64Target, 			(*int64_getter)		(QofEntity*, QofParam*);
 
 	g_return_val_if_fail((mergeData != NULL), -1);
 	currentRule = mergeData->currentRule;
@@ -483,7 +481,7 @@
 			referenceEnt = qtparam->param_getfcn(mergeEnt, qtparam);
 			if((referenceEnt != NULL)
 				&&(safe_strcmp(referenceEnt->e_type, mergeType) == 0)) {
-					currentRule->linkedEntList = g_slist_prepend(currentRule->linkedEntList, referenceEnt);
+				currentRule->linkedEntList = g_slist_prepend(currentRule->linkedEntList, referenceEnt);
 					/* Compare the mergeEnt reference with targetEnt reference */
 					if(referenceEnt == qtparam->param_getfcn(targetEnt, qtparam)) { mergeMatch = TRUE; }
 					currentRule = qof_book_mergeUpdateRule(currentRule, mergeMatch, DEFAULT_MERGE_WEIGHT);
@@ -598,14 +596,14 @@
 			continue;
 		}
 		mergeData->currentRule = rule;
-		g_return_if_fail(qof_book_mergeCompare(mergeData) != -1);
-		if(difference > mergeData->currentRule->difference) {
-			best_matchEnt = currentRule->targetEnt;
-			difference = currentRule->difference;
-			rule = currentRule;
-			mergeData->mergeList = g_list_prepend(mergeData->mergeList,rule);
-			qof_book_merge_orphan_check(difference, rule, mergeData);
-		}
+			g_return_if_fail(qof_book_mergeCompare(mergeData) != -1);
+			if(difference > mergeData->currentRule->difference) {
+				best_matchEnt = currentRule->targetEnt;
+				difference = currentRule->difference;
+				rule = currentRule;
+				mergeData->mergeList = g_list_prepend(mergeData->mergeList,rule);
+				qof_book_merge_orphan_check(difference, rule, mergeData);
+			}
 		orphans = g_slist_next(orphans);
 	}
 	g_slist_free(mergeData->orphan_list);
Index: qofquery-serialize.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofquery-serialize.c,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -Lsrc/engine/qofquery-serialize.c -Lsrc/engine/qofquery-serialize.c -u -r1.1.2.1 -r1.1.2.2
--- src/engine/qofquery-serialize.c
+++ src/engine/qofquery-serialize.c
@@ -208,18 +208,30 @@
 static xmlNodePtr
 qof_query_pred_data_to_xml (QofQueryPredData *pd)
 {
+	GList *n;
+	GSList *ns;
+	xmlNodePtr topnode;
+	query_guid_t pdata_g;
+	query_string_t pdata_s;
+	query_numeric_t pdata_n;
+	query_kvp_t pdata_k;
+	query_date_t pdata_d;
+	query_int64_t pdata_i64;
+	query_int32_t pdata_i32;
+	query_double_t pdata_db;
+	query_boolean_t pdata_bool;
+	query_char_t pdata_c;
 
 	if (!safe_strcmp (pd->type_name, QOF_TYPE_GUID))
 	{
-		xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-guid");
+		topnode = xmlNewNode (NULL, "qofquery:pred-guid");
 		/* GUID Predicate doesn't do a PUT_HOW */
 
-		GList *n;
-		query_guid_t pdata = (query_guid_t) pd;
-		PUT_MATCH5("qofquery:guid-match", pdata->options, 
+		pdata_g = (query_guid_t) pd;
+		PUT_MATCH5("qofquery:guid-match", pdata_g->options, 
 		                GUID_MATCH, ANY, ALL, NONE, NULL, LIST_ANY);
 
-		for (n = pdata->guids; n; n = n->next)
+		for (n = pdata_g->guids; n; n = n->next)
 		{
 			PUT_GUID ("qofquery:guid", n->data);
 		}
@@ -227,105 +239,103 @@
 	}
 	if (!safe_strcmp (pd->type_name, QOF_TYPE_STRING))
 	{
-		xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-string");
+		topnode = xmlNewNode (NULL, "qofquery:pred-string");
 		PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
 
-		query_string_t pdata = (query_string_t) pd;
-		PUT_MATCH2("qofquery:string-match", pdata->options,
+		pdata_s = (query_string_t) pd;
+		PUT_MATCH2("qofquery:string-match", pdata_s->options,
                        STRING_MATCH, NORMAL, CASEINSENSITIVE);
-		PUT_BOOL ("qofquery:is-regex", pdata->is_regex);
-		PUT_STR ("qofquery:string", pdata->matchstring);
+		PUT_BOOL ("qofquery:is-regex", pdata_s->is_regex);
+		PUT_STR ("qofquery:string", pdata_s->matchstring);
 		return topnode;
 	}
 	if (!safe_strcmp (pd->type_name, QOF_TYPE_NUMERIC))
 	{
-		xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-numeric");
+		topnode = xmlNewNode (NULL, "qofquery:pred-numeric");
 		PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
 
-		query_numeric_t pdata = (query_numeric_t) pd;
-		PUT_MATCH3("qofquery:numeric-match", pdata->options,
+		pdata_n = (query_numeric_t) pd;
+		PUT_MATCH3("qofquery:numeric-match", pdata_n->options,
 		                 NUMERIC_MATCH, DEBIT, CREDIT, ANY);
 		
-		PUT_NUMERIC ("qofquery:numeric", pdata->amount);
+		PUT_NUMERIC ("qofquery:numeric", pdata_n->amount);
 		return topnode;
 	}
 	if (!safe_strcmp (pd->type_name, QOF_TYPE_KVP))
 	{
-		xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-kvp");
+		topnode = xmlNewNode (NULL, "qofquery:pred-kvp");
 		PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
 
-		query_kvp_t pdata = (query_kvp_t) pd;
-		
-		GSList *n;
-		for (n=pdata->path; n; n=n->next)
+		pdata_k = (query_kvp_t) pd;
+		for (ns=pdata_k->path; ns; ns=ns->next)
 		{
-			PUT_STR ("qofquery:kvp-path", n->data);
+			PUT_STR ("qofquery:kvp-path", ns->data);
 		}
-		qof_kvp_value_to_xml (pdata->value, topnode);
+		qof_kvp_value_to_xml (pdata_k->value, topnode);
 		return topnode;
 	}
 	if (!safe_strcmp (pd->type_name, QOF_TYPE_DATE))
 	{
-		xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-date");
+		topnode = xmlNewNode (NULL, "qofquery:pred-date");
 		PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
 
-		query_date_t pdata = (query_date_t) pd;
+		pdata_d = (query_date_t) pd;
 		
-		PUT_MATCH2("qofquery:date-match", pdata->options,
+		PUT_MATCH2("qofquery:date-match", pdata_d->options,
 		                 DATE_MATCH, NORMAL, ROUNDED);
 
-		PUT_DATE ("qofquery:date", pdata->date);
+		PUT_DATE ("qofquery:date", pdata_d->date);
 		return topnode;
 	}
 	if (!safe_strcmp (pd->type_name, QOF_TYPE_INT64))
 	{
-		xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-int64");
+		topnode = xmlNewNode (NULL, "qofquery:pred-int64");
 		PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
 
-		query_int64_t pdata = (query_int64_t) pd;
-		PUT_INT64 ("qofquery:int64", pdata->val);
+		pdata_i64 = (query_int64_t) pd;
+		PUT_INT64 ("qofquery:int64", pdata_i64->val);
 		return topnode;
 	}
 	if (!safe_strcmp (pd->type_name, QOF_TYPE_INT32))
 	{
-		xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-int32");
+		topnode = xmlNewNode (NULL, "qofquery:pred-int32");
 		PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
 
-		query_int32_t pdata = (query_int32_t) pd;
+		pdata_i32 = (query_int32_t) pd;
 		
-		PUT_INT32 ("qofquery:int32", pdata->val);
+		PUT_INT32 ("qofquery:int32", pdata_i32->val);
 		return topnode;
 	}
 	if (!safe_strcmp (pd->type_name, QOF_TYPE_DOUBLE))
 	{
-		xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-double");
+		topnode = xmlNewNode (NULL, "qofquery:pred-double");
 		PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
 
-		query_double_t pdata = (query_double_t) pd;
+		pdata_db = (query_double_t) pd;
 		
-		PUT_DBL ("qofquery:double", pdata->val);
+		PUT_DBL ("qofquery:double", pdata_db->val);
 		return topnode;
 	}
 	if (!safe_strcmp (pd->type_name, QOF_TYPE_BOOLEAN))
 	{
-		xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-boolean");
+		topnode = xmlNewNode (NULL, "qofquery:pred-boolean");
 		PUT_HOW ("qofquery:compare", pd->how, LT, LTE, EQUAL, GT, GTE, NEQ);
 
-		query_boolean_t pdata = (query_boolean_t) pd;
+		pdata_bool = (query_boolean_t) pd;
 		
-		PUT_BOOL ("qofquery:boolean", pdata->val);
+		PUT_BOOL ("qofquery:boolean", pdata_bool->val);
 		return topnode;
 	}
 	if (!safe_strcmp (pd->type_name, QOF_TYPE_CHAR))
 	{
-		xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:pred-char");
+		topnode = xmlNewNode (NULL, "qofquery:pred-char");
 		/* There is no PUT_HOW for char-match */
-		query_char_t pdata = (query_char_t) pd;
+		pdata_c = (query_char_t) pd;
 		
-		PUT_MATCH2("qofquery:char-match", pdata->options,
+		PUT_MATCH2("qofquery:char-match", pdata_c->options,
 		                 CHAR_MATCH, ANY, NONE);
 		
-		PUT_STR ("qofquery:char-list", pdata->char_list);
+		PUT_STR ("qofquery:char-list", pdata_c->char_list);
 		return topnode;
 	}
 	return NULL;
@@ -336,11 +346,15 @@
 static xmlNodePtr
 qof_query_param_path_to_xml (GSList *param_path)
 {
-	xmlNodePtr topnode = xmlNewNode (NULL, "qofquery:param-path");
-	GSList *n = param_path;
+	xmlNodePtr topnode;
+	GSList *n;
+	QofIdTypeConst path;
+	
+	n = param_path;
+	topnode = xmlNewNode (NULL, "qofquery:param-path");
 	for ( ; n; n=n->next)
 	{
-		QofIdTypeConst path = n->data;
+		path = n->data;
 		if (!path) continue;
 		PUT_STR ("qofquery:param", path);
 	}
@@ -353,13 +367,17 @@
 qof_query_one_term_to_xml (QofQueryTerm *qt)
 {
 	xmlNodePtr node;
-	xmlNodePtr term = xmlNewNode (NULL, "qofquery:term");
-
-	gboolean invert = qof_query_term_is_inverted (qt);
-	GSList *path = qof_query_term_get_param_path (qt);
-	QofQueryPredData *pd = qof_query_term_get_pred_data (qt);
-
-	xmlNodePtr topnode = term;
+	xmlNodePtr term;
+	xmlNodePtr topnode;
+	gboolean invert;
+	GSList *path;
+	QofQueryPredData *pd;
+
+	invert = qof_query_term_is_inverted (qt);
+	term = xmlNewNode (NULL, "qofquery:term");
+	topnode = term;
+	path = qof_query_term_get_param_path (qt);
+	pd = qof_query_term_get_pred_data (qt);
 	if (invert)
 	{
 		/* inverter becomes new top mode */
@@ -381,14 +399,19 @@
 static xmlNodePtr
 qof_query_and_terms_to_xml (GList *and_terms)
 {
-	xmlNodePtr terms = xmlNewNode (NULL, "qofquery:and-terms");
-	GList *n = and_terms;
+	xmlNodePtr terms;
+	GList *n;
+	QofQueryTerm *qt;
+	xmlNodePtr t;
+	
+	terms = xmlNewNode (NULL, "qofquery:and-terms");
+	n = and_terms;
 	for ( ; n; n=n->next)
 	{
-		QofQueryTerm *qt = n->data;
+		qt = n->data;
 		if (!qt) continue;
 
-		xmlNodePtr t = qof_query_one_term_to_xml (n->data);
+		t = qof_query_one_term_to_xml (n->data);
 		if (t) xmlAddChild (terms, t);
 	}
 	return terms;
@@ -399,15 +422,18 @@
 static xmlNodePtr
 qof_query_terms_to_xml (QofQuery *q)
 {
-	xmlNodePtr terms = NULL;
-	GList *n = qof_query_get_terms (q);
+	xmlNodePtr terms;
+	GList *n;
+	xmlNodePtr andt;
 
+	terms = NULL;
+	n = qof_query_get_terms (q);
 	if (!n) return NULL;
 	terms = xmlNewNode (NULL, "qofquery:or-terms");
 
 	for ( ; n; n=n->next)
 	{
-		xmlNodePtr andt = qof_query_and_terms_to_xml (n->data);
+		andt = qof_query_and_terms_to_xml (n->data);
 		if (andt) xmlAddChild (terms, andt);
 	}
 	return terms;
@@ -419,31 +445,39 @@
 qof_query_sorts_to_xml (QofQuery *q)
 {
 	QofQuerySort *s[3];
+	xmlNodePtr sortlist;
+	GSList *plist;
+	xmlNodePtr sort;
+	xmlNodePtr topnode;
+	gboolean increasing;
+	gint opt;
+	xmlNodePtr pl;
+	int i;
+	
 	qof_query_get_sorts (q, &s[0], &s[1], &s[2]);
 
 	if (NULL == s[0]) return NULL;
 
-	xmlNodePtr sortlist = xmlNewNode (NULL, "qofquery:sort-list");
-	int i;
+	sortlist = xmlNewNode (NULL, "qofquery:sort-list");
 	for (i=0; i<3; i++)
 	{
 		if (NULL == s[i]) continue;
 
-		GSList *plist = qof_query_sort_get_param_path (s[i]);
+		plist = qof_query_sort_get_param_path (s[i]);
 		if (!plist) continue;
 
-		xmlNodePtr sort = xmlNewNode (NULL, "qofquery:sort");
+		sort = xmlNewNode (NULL, "qofquery:sort");
 		xmlAddChild (sortlist, sort);
 
-		xmlNodePtr topnode = sort;
+		topnode = sort;
 
-		gboolean increasing = qof_query_sort_get_increasing (s[i]);
+		increasing = qof_query_sort_get_increasing (s[i]);
 		PUT_STR ("qofquery:order", increasing ? "DESCENDING" : "ASCENDING");
 
-		gint opt = qof_query_sort_get_sort_options (s[i]);
+		opt = qof_query_sort_get_sort_options (s[i]);
 		PUT_INT32 ("qofquery:options", opt);
 
-		xmlNodePtr pl = qof_query_param_path_to_xml (plist);
+		pl = qof_query_param_path_to_xml (plist);
 		if (pl) xmlAddChild (sort, pl);
 	}
 
@@ -455,16 +489,21 @@
 static void
 do_qof_query_to_xml (QofQuery *q, xmlNodePtr topnode)
 {
-	QofIdType search_for = qof_query_get_search_for (q);
+	QofIdType search_for;
+	xmlNodePtr terms;
+	xmlNodePtr sorts;
+	gint max_results;
+	
+	search_for = qof_query_get_search_for (q);
 	PUT_STR ("qofquery:search-for", search_for);
 
-	xmlNodePtr terms = qof_query_terms_to_xml(q);
+	terms = qof_query_terms_to_xml(q);
 	if (terms) xmlAddChild (topnode, terms);
 
-	xmlNodePtr sorts = qof_query_sorts_to_xml (q);
+	sorts = qof_query_sorts_to_xml (q);
 	if (sorts) xmlAddChild (topnode, sorts);
 
-	gint max_results = qof_query_get_max_results (q);
+	max_results = qof_query_get_max_results (q);
 	PUT_INT32 ("qofquery:max-results", max_results);
 }
 
@@ -499,6 +538,11 @@
 {
 	QofQuery *q;
 	QofSqlQuery *sq;
+	xmlDocPtr doc;
+	xmlNodePtr topnode;
+	xmlChar *xbuf;
+	int bufsz;
+	xmlOutputBufferPtr xbuf;
 
 	qof_query_init();
 	qof_object_initialize ();
@@ -523,12 +567,10 @@
 
 	qof_query_print (q);
 
-	xmlDocPtr doc = doc = xmlNewDoc("1.0");
-	xmlNodePtr topnode = qof_query_to_xml (q);
+	doc = doc = xmlNewDoc("1.0");
+	topnode = qof_query_to_xml (q);
 	xmlDocSetRootElement(doc,topnode);
 
-	xmlChar *xbuf;
-	int bufsz;
 	xmlDocDumpFormatMemory (doc, &xbuf, &bufsz, 1);
 
 	printf ("%s\n", xbuf);
@@ -538,7 +580,7 @@
 #if 0
 printf ("duude\n");
 	// xmlOutputBufferPtr xbuf = xmlAllocOutputBuffer (enc);
-	xmlOutputBufferPtr xbuf = xmlOutputBufferCreateFile (stdout, NULL);
+	xbuf = xmlOutputBufferCreateFile (stdout, NULL);
 printf ("duude\n");
 
 	xbuf = xmlOutputBufferCreateFd (1, NULL);
Index: gnc-lot.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/gnc-lot.h,v
retrieving revision 1.8.4.6
retrieving revision 1.8.4.7
diff -Lsrc/engine/gnc-lot.h -Lsrc/engine/gnc-lot.h -u -r1.8.4.6 -r1.8.4.7
--- src/engine/gnc-lot.h
+++ src/engine/gnc-lot.h
@@ -63,6 +63,7 @@
 #include "gnc-numeric.h"
 #include "qofbook.h"
 #include "qofid.h"
+#include "qofobject.h"
 
 GNCLot * gnc_lot_new (QofBook *);
 void gnc_lot_destroy (GNCLot *);
@@ -135,7 +136,8 @@
 
 #define LOT_IS_CLOSED	"is-closed?"
 #define LOT_BALANCE	"balance"
-
+#define LOT_TITLE		"lot-title"
+#define LOT_NOTES		"notes"
 #endif /* GNC_LOT_H */
 /** @} */
 /** @} */
Index: guid.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/guid.h,v
retrieving revision 1.15.6.6
retrieving revision 1.15.6.7
diff -Lsrc/engine/guid.h -Lsrc/engine/guid.h -u -r1.15.6.6 -r1.15.6.7
--- src/engine/guid.h
+++ src/engine/guid.h
@@ -134,7 +134,7 @@
  *  CAS: huh? make that: @return guid A data structure containing a newly
  * allocated GUID.  Caller is responsible for calling guid_free().
  */
-const GUID guid_new_return(void);
+GUID guid_new_return(void);
 
 /** Returns a GUID which is guaranteed to never reference any entity. */
 /* CAS: AFAICT: this isn't really guaranteed, but it's only as likely
Index: qofclass.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/qofclass.h,v
retrieving revision 1.1.6.4
retrieving revision 1.1.6.5
diff -Lsrc/engine/qofclass.h -Lsrc/engine/qofclass.h -u -r1.1.6.4 -r1.1.6.5
--- src/engine/qofclass.h
+++ src/engine/qofclass.h
@@ -82,7 +82,7 @@
 
 /** Type of Paramters (String, Date, Numeric, GUID, etc.) */
 typedef const char * QofType;
-
+/** Type of QofParam */
 typedef struct _QofParam QofParam;
 
 /** The QofAccessFunc defines an arbitrary function pointer
Index: html-acct-table.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/report-system/html-acct-table.scm,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -Lsrc/report/report-system/html-acct-table.scm -Lsrc/report/report-system/html-acct-table.scm -u -r1.1.2.2 -r1.1.2.3
--- src/report/report-system/html-acct-table.scm
+++ src/report/report-system/html-acct-table.scm
@@ -63,7 +63,7 @@
 ;; The list of accounts which are to be placed in the
 ;; gnc:html-acct-table object can be controled with the
 ;; gnc:make-html-acct-table/accts, gnc:make-html-acct-table/env/accts,
-;; and gnc:html-table-add-accts!  functions.  
+;; and gnc:html-table-add-accts! functions.  
 ;; 
 ;; The gnc:html-acct-table parameters, set with
 ;; gnc:make-html-acct-table/env and gnc:make-html-acct-table/accts/env
@@ -209,6 +209,21 @@
 ;;         the parent account of the current account, if one exists.
 ;;         #f if the current account has no parent.
 ;; 
+;;     account-guid: guid
+;; 
+;;         the guid of the account in the current row, as returned by
+;;         gnc:account-get-guid.
+;; 
+;;     account-desc: string?
+;; 
+;;         the account description of the account in the current row,
+;;         as returned by gnc:account-get-description.
+;; 
+;;     account-notes: string?
+;; 
+;;         the account notes of the account in the current row, as
+;;         returned by gnc:account-get-notes.
+;; 
 ;;     account-path: string
 ;; 
 ;;         the full name of the account in the current row. i.e., if
@@ -339,6 +354,15 @@
 ;;         probably safest not to assume that an account contains only
 ;;         its default commodity.
 ;; 
+;;     account-type: account_type
+;; 
+;;         returns the type of the account in the current row
+;; 
+;;     account-type-string: string
+;; 
+;;         returns the type of the account in the current row as a
+;;         string
+;; 
 ;;     row-type: 'account-row 'subtotal-row 
 ;; 
 ;;         indicates the nature of the current row.  'account-row
@@ -638,6 +662,14 @@
 		  (account-depth acct-depth)
 		  (logical-depth logi-depth)
 		  (account-commodity (gnc:account-get-commodity acct))
+		  (account-type (gnc:account-get-type acct))
+		  ;; N.B.: gnc:account-get-type-string really should be
+		  ;; called gnc:account-type-get-string
+		  (account-type-string (gnc:account-get-type-string
+					(gnc:account-get-type acct)))
+		  (account-guid (gnc:account-get-guid acct))
+		  (account-description (gnc:account-get-description acct))
+		  (account-notes (gnc:account-get-notes acct))
 		  (account-bal (my-get-balance-nosub
 				acct start-date end-date))
 		  (recursive-bal
@@ -655,6 +687,11 @@
 			    (list 'account account)
 			    (list 'account-name account-name)
 			    (list 'account-code account-code)
+			    (list 'account-type account-type)
+			    (list 'account-type-string account-type-string)
+			    (list 'account-guid account-guid)
+			    (list 'account-description account-description)
+			    (list 'account-notes account-notes)
 			    (list 'account-path account-path)
 			    (list 'account-parent account-parent)
 			    (list 'account-children account-children)
@@ -709,8 +746,11 @@
 				 )
 	     (or (not (use-acct? acct))
 		 (not subtotal-mode)
-		 ;; ignore use-acct for subtotals...
-		 ;; (not (use-acct acct))
+		 ;; ditto that remark concerning zero recursive-bal...
+		 (and (gnc:commodity-collector-allzero? recursive-bal)
+		      (equal? zero-mode 'omit-leaf-acct))
+		 ;; ignore use-acct for subtotals...?
+		 ;; (not (use-acct? acct))
 		 (null? subaccts)
 		 (let* ((lbl-txt (gnc:make-html-text (_ "Total") " ")))
 		   (apply gnc:html-text-append! lbl-txt
@@ -803,7 +843,7 @@
   (gnc:html-table-num-rows (gnc:_html-acct-table-matrix_ acct-table)))
 
 (define (gnc:html-acct-table-num-cols acct-table)
-  (- (gnc:html-table-num-cols (gnc:_html-acct-table-matrix_ acct-table)) 1))
+  (- (gnc:html-table-num-columns (gnc:_html-acct-table-matrix_ acct-table)) 1))
 
 (define (gnc:html-acct-table-get-cell acct-table row col)
   ;; we'll only ever store one object in an html-table-cell
@@ -1009,16 +1049,16 @@
 		       'omit-bal))
 		  (bal-method
 		   ;; figure out how to calculate our balance:
-		   ;; 'immediate-bal|'recursive-bal|'omit-bal
+		   ;; 'immediate-bal|'recursive-bal ('omit-bal handled below)
 		   (or (and (equal? row-type 'subtotal-row) 'recursive-bal)
 		       (and (equal? (+ display-depth 1) display-tree-depth)
-			    (if (equal? limit-behavior 'truncate)
-				'immediate-bal
-				;; 'summarize, 'flatten, and unknown
-				;; depth limit behaviors yield
-				;; 'recursive-bal.  this is true
-				;; whether a leaf account or not.
-				'recursive-bal)
+			    (or (and (equal? limit-behavior 'summarize)
+				     'recursive-bal)
+				(and (null? children) 'immediate-bal)
+				;; otherwise, parent account at depth limit,
+				;; with either 'truncate or 'flatten...
+				parent-acct-bal-mode
+				)
 			    )
 		       (if (null? children) #f parent-acct-bal-mode)
 		       'immediate-bal
Index: gnc-split-reg.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/gnc-split-reg.c,v
retrieving revision 1.19.4.15
retrieving revision 1.19.4.16
diff -Lsrc/gnome/gnc-split-reg.c -Lsrc/gnome/gnc-split-reg.c -u -r1.19.4.15 -r1.19.4.16
--- src/gnome/gnc-split-reg.c
+++ src/gnome/gnc-split-reg.c
@@ -255,7 +255,7 @@
   LAST_SIGNAL
 };
 
-static gint gnc_split_reg_signals[LAST_SIGNAL] = { 0 };
+static guint gnc_split_reg_signals[LAST_SIGNAL] = { 0 };
 
 static void
 gnc_split_reg_class_init( GNCSplitRegClass *class )
Index: druid-merge.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome/druid-merge.c,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.4
diff -Lsrc/gnome/druid-merge.c -Lsrc/gnome/druid-merge.c -u -r1.2.2.3 -r1.2.2.4
--- src/gnome/druid-merge.c
+++ src/gnome/druid-merge.c
@@ -42,11 +42,11 @@
 #include "gnc-trace.h"
 #include "Group.h"
 
-static GtkWidget	*qof_book_merge_window = NULL;
+static GtkWidget			*qof_book_merge_window = NULL;
 GtkWidget			*druid_hierarchy_window = NULL;
 static GtkWidget	*qsf_import_merge_window = NULL;
 QofSession			*previous_session = NULL;
-gint				count = 0;
+gint					count = 0;
 qof_book_mergeData	*mergeData = NULL;
 QofSession 			*merge_session = NULL;
 QofBook				*mergeBook = NULL;
@@ -210,7 +210,7 @@
            gpointer         user_data)
 {
 	gint result;
-    GtkWidget *top;	
+    GtkWidget *top;
     const char *message;
 
 	ENTER (" ");
@@ -413,7 +413,7 @@
 void
 gnc_ui_qof_book_merge_druid (void)
 {
-	if (qof_book_merge_window) { return; }
+	if (qof_book_merge_window) return;
 	/*	QofSession changes to avoid using current book */
 	gnc_engine_suspend_events ();
 	previous_session = qof_session_get_current_session();
Index: gnc-date-edit.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gnc-date-edit.c,v
retrieving revision 1.5.4.11
retrieving revision 1.5.4.12
diff -Lsrc/gnome-utils/gnc-date-edit.c -Lsrc/gnome-utils/gnc-date-edit.c -u -r1.5.4.11 -r1.5.4.12
--- src/gnome-utils/gnc-date-edit.c
+++ src/gnome-utils/gnc-date-edit.c
@@ -53,7 +53,7 @@
 	LAST_SIGNAL
 };
 
-static gint date_edit_signals [LAST_SIGNAL] = { 0 };
+static guint date_edit_signals [LAST_SIGNAL] = { 0 };
 
 
 static void gnc_date_edit_init         (GNCDateEdit      *gde);
@@ -145,7 +145,7 @@
 day_selected (GtkCalendar *calendar, GNCDateEdit *gde)
 {
 	char buffer [40];
-	gint year, month, day;
+	guint year, month, day;
 
 	gtk_calendar_get_date (calendar, &year, &month, &day);
 
Index: gnc-date-delta.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gnc-date-delta.c,v
retrieving revision 1.1.6.5
retrieving revision 1.1.6.6
diff -Lsrc/gnome-utils/gnc-date-delta.c -Lsrc/gnome-utils/gnc-date-delta.c -u -r1.1.6.5 -r1.1.6.6
--- src/gnome-utils/gnc-date-delta.c
+++ src/gnome-utils/gnc-date-delta.c
@@ -53,7 +53,7 @@
   LAST_SIGNAL
 };
 
-static gint date_delta_signals [LAST_SIGNAL] = { 0 };
+static guint date_delta_signals [LAST_SIGNAL] = { 0 };
 
 
 static void gnc_date_delta_init       (GNCDateDelta      *gdd);
Index: gnc-frequency.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gnc-frequency.c,v
retrieving revision 1.14.4.6
retrieving revision 1.14.4.7
diff -Lsrc/gnome-utils/gnc-frequency.c -Lsrc/gnome-utils/gnc-frequency.c -u -r1.14.4.6 -r1.14.4.7
--- src/gnome-utils/gnc-frequency.c
+++ src/gnome-utils/gnc-frequency.c
@@ -44,7 +44,7 @@
   LAST_SIGNAL
 } GNCF_Signals;
 
-static gint gnc_frequency_signals[LAST_SIGNAL] = { 0 };
+static guint gnc_frequency_signals[LAST_SIGNAL] = { 0 };
 
 /** Private Prototypes ********************/
 
Index: gnc-dense-cal.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gnc-dense-cal.c,v
retrieving revision 1.11.4.11
retrieving revision 1.11.4.12
diff -Lsrc/gnome-utils/gnc-dense-cal.c -Lsrc/gnome-utils/gnc-dense-cal.c -u -r1.11.4.11 -r1.11.4.12
--- src/gnome-utils/gnc-dense-cal.c
+++ src/gnome-utils/gnc-dense-cal.c
@@ -94,7 +94,7 @@
   LAST_SIGNAL
 };
 
-static gint gnc_dense_cal_signals[LAST_SIGNAL] = { 0 };
+static guint gnc_dense_cal_signals[LAST_SIGNAL] = { 0 };
 
 static short module = MOD_SX;
 
@@ -120,29 +120,29 @@
 static gint gnc_dense_cal_button_press( GtkWidget *widget,
                                         GdkEventButton *evt );
 
-static const inline int day_width_at( GncDenseCal *dcal, guint xScale );
-static const inline int day_width( GncDenseCal *dcal );
-static const inline int day_height_at( GncDenseCal *dcal, guint yScale );
-static const inline int day_height( GncDenseCal *dcal );
-static const inline int week_width_at( GncDenseCal *dcal, guint xScale );
-static const inline int week_width( GncDenseCal *dcal );
-static const inline int week_height_at( GncDenseCal *dcal, guint yScale );
-static const inline int week_height( GncDenseCal *dcal );
-static const inline int col_width_at( GncDenseCal *dcal, guint xScale );
-static const inline int col_width( GncDenseCal *dcal );
+static inline int day_width_at( GncDenseCal *dcal, guint xScale );
+static inline int day_width( GncDenseCal *dcal );
+static inline int day_height_at( GncDenseCal *dcal, guint yScale );
+static inline int day_height( GncDenseCal *dcal );
+static inline int week_width_at( GncDenseCal *dcal, guint xScale );
+static inline int week_width( GncDenseCal *dcal );
+static inline int week_height_at( GncDenseCal *dcal, guint yScale );
+static inline int week_height( GncDenseCal *dcal );
+static inline int col_width_at( GncDenseCal *dcal, guint xScale );
+static inline int col_width( GncDenseCal *dcal );
 
-static const inline int col_height( GncDenseCal *dcal );
-static const inline int num_cols( GncDenseCal *dcal );
+static inline int col_height( GncDenseCal *dcal );
+static inline int num_cols( GncDenseCal *dcal );
 /**
  * Returns the total number of weeks to display in the calendar [irrespective
  * of columns/weeks-per-col].
  **/
-static const inline int num_weeks( GncDenseCal *dcal );
+static inline int num_weeks( GncDenseCal *dcal );
 /**
  * Returns the number of weeks per column.  Note that this is the number of
  * weeks needed to display the longest column.
  **/
-static const int num_weeks_per_col( GncDenseCal *dcal );
+static int num_weeks_per_col( GncDenseCal *dcal );
 
 /** hotspot calculation **/
 static gint wheres_this( GncDenseCal *dcal, int x, int y );
@@ -1126,55 +1126,55 @@
         return TRUE;
 }
 
-static const inline int
+static inline int
 day_width_at( GncDenseCal *dcal, guint xScale )
 {
         return xScale + MINOR_BORDER_SIZE;
 }
 
-static const inline int
+static inline int
 day_width( GncDenseCal *dcal )
 {
         return day_width_at( dcal, dcal->x_scale );
 }
 
-static const inline int
+static inline int
 day_height_at( GncDenseCal *dcal, guint yScale )
 {
         return yScale + MINOR_BORDER_SIZE;
 }
 
-static const inline int
+static inline int
 day_height( GncDenseCal *dcal )
 {
         return day_height_at( dcal, dcal->y_scale );
 }
 
-static const inline int
+static inline int
 week_width_at( GncDenseCal *dcal, guint xScale )
 {
         return day_width_at(dcal, xScale) * 7;
 }
 
-static const inline int
+static inline int
 week_width( GncDenseCal *dcal )
 {
         return week_width_at( dcal, dcal->x_scale );
 }
 
-static const inline int
+static inline int
 week_height_at( GncDenseCal *dcal, guint yScale )
 {
         return day_height_at(dcal, yScale);
 }
 
-static const inline int
+static inline int
 week_height( GncDenseCal *dcal )
 {
         return week_height_at(dcal, dcal->y_scale);
 }
 
-static const inline int
+static inline int
 col_width_at( GncDenseCal *dcal, guint xScale )
 {
         return (week_width_at(dcal, xScale)
@@ -1182,33 +1182,33 @@
                 + COL_BORDER_SIZE);
 }
 
-static const inline int
+static inline int
 col_width( GncDenseCal *dcal )
 {
         return col_width_at( dcal, dcal->x_scale );
 }
 
-static const inline int
+static inline int
 col_height( GncDenseCal *dcal )
 {
         return week_height(dcal)
                 * num_weeks_per_col(dcal);
 }
 
-static const inline int
+static inline int
 num_cols( GncDenseCal *dcal )
 {
         return ceil( (float)dcal->numMonths / (float)dcal->monthsPerCol );
 }
 
-static const inline int
+static inline int
 num_weeks( GncDenseCal *dcal )
 {
         /* FIXME: calculate, remove 'recompute_extents' */
         return dcal->num_weeks;
 }
 
-static const
+static
 int num_weeks_per_col( GncDenseCal *dcal )
 {
         int num_weeks_toRet, numCols, i;
Index: gnc-amount-edit.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gnc-amount-edit.c,v
retrieving revision 1.3.4.4
retrieving revision 1.3.4.5
diff -Lsrc/gnome-utils/gnc-amount-edit.c -Lsrc/gnome-utils/gnc-amount-edit.c -u -r1.3.4.4 -r1.3.4.5
--- src/gnome-utils/gnc-amount-edit.c
+++ src/gnome-utils/gnc-amount-edit.c
@@ -49,7 +49,7 @@
 };
 
 
-static gint amount_edit_signals [LAST_SIGNAL] = { 0 };
+static guint amount_edit_signals [LAST_SIGNAL] = { 0 };
 
 
 static void gnc_amount_edit_init         (GNCAmountEdit      *gae);
Index: gnc-date-format.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gnc-date-format.c,v
retrieving revision 1.3.2.4
retrieving revision 1.3.2.5
diff -Lsrc/gnome-utils/gnc-date-format.c -Lsrc/gnome-utils/gnc-date-format.c -u -r1.3.2.4 -r1.3.2.5
--- src/gnome-utils/gnc-date-format.c
+++ src/gnome-utils/gnc-date-format.c
@@ -67,7 +67,7 @@
   GtkWidget*	label_box;
 };
 
-static gint date_format_signals [LAST_SIGNAL] = { 0 };
+static guint date_format_signals [LAST_SIGNAL] = { 0 };
 
 
 static void gnc_date_format_init         (GNCDateFormat      *gdf);
Index: gnc-account-sel.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/gnc-account-sel.c,v
retrieving revision 1.5.4.5
retrieving revision 1.5.4.6
diff -Lsrc/gnome-utils/gnc-account-sel.c -Lsrc/gnome-utils/gnc-account-sel.c -u -r1.5.4.5 -r1.5.4.6
--- src/gnome-utils/gnc-account-sel.c
+++ src/gnome-utils/gnc-account-sel.c
@@ -42,7 +42,7 @@
         LAST_SIGNAL
 };
 
-static gint account_sel_signals [LAST_SIGNAL] = { 0 };
+static guint account_sel_signals [LAST_SIGNAL] = { 0 };
 
 static void gnc_account_sel_init (GNCAccountSel *gas);
 static void gnc_account_sel_class_init (GNCAccountSelClass *klass);
Index: dialog-utils.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/dialog-utils.c,v
retrieving revision 1.13.4.11
retrieving revision 1.13.4.12
diff -Lsrc/gnome-utils/dialog-utils.c -Lsrc/gnome-utils/dialog-utils.c -u -r1.13.4.11 -r1.13.4.12
--- src/gnome-utils/dialog-utils.c
+++ src/gnome-utils/dialog-utils.c
@@ -22,11 +22,14 @@
  *                                                                  *
 \********************************************************************/
 
+#define _GNU_SOURCE 1  /* necessary to get RTLD_DEFAULT on linux */
+
 #include "config.h"
 
 #include <glade/glade.h>
 #include <gnome.h>
 #include <gmodule.h>
+#include <dlfcn.h>
 
 #include "dialog-utils.h"
 #include "global-options.h"
@@ -38,7 +41,6 @@
 #include "gnc-euro.h"
 #include "gnc-ui-util.h"
 
-
 /* This static indicates the debugging module that this .o belongs to. */
 static short module = MOD_GUI;
 
@@ -954,20 +956,23 @@
 				gboolean signal_after,
 				gpointer user_data)
 {
-  gpointer ptr;
   GCallback func;
+  GtkSignalFunc *p_func = &func;
 
   if (allsymbols == NULL) {
     /* get a handle on the main executable -- use this to find symbols */
     allsymbols = g_module_open(NULL, 0);
   }
 
-  if (!g_module_symbol(allsymbols, handler_name, &ptr)) {
-    g_warning("could not find signal handler '%s'.", handler_name);
-    return;
+  if (!g_module_symbol(allsymbols, handler_name, (gpointer *)p_func)) {
+    /* Fallback to dlsym -- necessary for *BSD linkers */
+    func = dlsym(RTLD_DEFAULT, handler_name);
+    if (func == NULL) {
+      g_warning("ggaff: could not find signal handler '%s'.", handler_name);
+      return;
+    }
   }
 
-  func = G_CALLBACK(ptr);
   if (other_object) {
     if (signal_after)
       g_signal_connect_object (signal_object, signal_name, func,
Index: druid-hbci-initial.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/druid-hbci-initial.c,v
retrieving revision 1.26.4.10
retrieving revision 1.26.4.11
diff -Lsrc/import-export/hbci/druid-hbci-initial.c -Lsrc/import-export/hbci/druid-hbci-initial.c -u -r1.26.4.10 -r1.26.4.11
--- src/import-export/hbci/druid-hbci-initial.c
+++ src/import-export/hbci/druid-hbci-initial.c
@@ -133,7 +133,6 @@
 {
   const char *bankname;
   const char *bankcode;
-
   g_assert(hacc);
   bankname = AB_Account_GetBankName (hacc);
   bankcode = AB_Account_GetBankCode (hacc);
@@ -453,55 +452,42 @@
   int res;
   const char *backend_name = "aqhbci";
 
-  /* NOTE NOTE NOTE: This is the name for the external application
-     shipped with aqhbci that contains the setup druid for HBCI
-     related stuff. The name is misleading -- it requires qt but not
-     kde). This application contains the very verbose step-by-step
-     setup wizard for the HBCI account, and the application is shared
-     with other AqBanking-based financial managers that offer the HBCI
-     features (e.g. KMyMoney). See gnucash-devel discussion here
-     https://lists.gnucash.org/pipermail/gnucash-devel/2004-December/012351.html 
+  /* This is the point where we look for and start an external
+     application shipped with aqhbci that contains the setup druid for
+     HBCI related stuff. It requires qt (but not kde). This
+     application contains the very verbose step-by-step setup wizard
+     for the HBCI account, and the application is shared with other
+     AqBanking-based financial managers that offer the HBCI features
+     (e.g. KMyMoney). See gnucash-devel discussion here
+     https://lists.gnucash.org/pipermail/gnucash-devel/2004-December/012351.html
   */
-  const char *wizard_name = "kde_wizard";
   gboolean wizard_exists;
   const char *wizard_path;
-  int fd;
   AB_BANKING *banking = info->api;
   g_assert(info->druid);
 
-  buf = GWEN_Buffer_new(NULL, 200, 0, 0);
-  AB_Banking_GetWizardPath(banking, backend_name, buf);
+  buf = GWEN_Buffer_new(NULL, 300, 0, 0);
+  AB_Banking_FindWizard(banking, backend_name, NULL, buf);
   wizard_exists = (strlen(GWEN_Buffer_GetStart(buf)) > 0);
-
-  GWEN_Buffer_AppendString(buf, "/");
-  /* {
-    GWEN_PLUGIN_DESCRIPTION_LIST2 *l = 
-      AB_Banking_GetWizardDescrs(banking, backend_name);
-    const GWEN_PLUGIN_DESCRIPTION *x = GWEN_PluginDescription_List2_GetFront(l);
-    // There needs to be a way to find the file name here. Currently
-    // this doesnt work yet.
-    wizard_name = GWEN_PluginDescription_GetName(x);
-    GWEN_Buffer_AppendString(buf, wizard_name);
-    GWEN_PluginDescription_List2_freeAll(l);
-    } */
-  GWEN_Buffer_AppendString(buf, wizard_name);
   wizard_path = GWEN_Buffer_GetStart(buf);
 
-  /* Really check whether the file exists */
-  fd = open( wizard_path, O_RDONLY );
-  if ( fd == -1)
-    wizard_exists = FALSE;
-  else
-    close( fd );
+  if (wizard_exists) {
+    /* Really check whether the file exists */
+    int fd = open( wizard_path, O_RDONLY );
+    if ( fd == -1)
+      wizard_exists = FALSE;
+    else
+      close( fd );
+  }
 
   druid_disable_next_button(info);
-  AB_Banking_DeactivateProvider(banking, backend_name);
+  /* AB_Banking_DeactivateProvider(banking, backend_name); */
   if (wizard_exists) {
     int wait_status;
     int wait_result = 0;
 
-    /* Call the qt wizard (called kde wizard). See the note above
-       about why this approach is chosen. */
+    /* Call the qt wizard. See the note above about why this approach
+       is chosen. */
 
     /* In gtk2, this would be g_spawn_async or similar. */
     AB_Banking_Fini (info->api);
@@ -520,6 +506,7 @@
 	_exit(0);
       default: /* parent */
 	res = 0;
+	/* wait until child is finished */
 	while (wait_result == 0) {
 	  gtk_main_iteration();
 	  wait_result = waitpid(pid, &wait_status, WNOHANG);
@@ -557,10 +544,8 @@
     gnc_error_dialog
       (info->window, "%s",
        _("The external program \"AqHBCI Setup Wizard\" has not been found. \n\n"
-	 "Did you install the package \"kde_wizard\" of AqHBCI? \n"
-	 "If not, please install it now. (The name of that package \n"
-	 "is misleading, as it does not require the KDE desktop \n"
-	 "environment but only the Qt toolkit libraries.)"));
+	 "Did you install the package \"aqhbci-qt-tools\" of AqHBCI? \n"
+	 "If not, please install it now."));
     druid_disable_next_button(info);
   }
   GWEN_Buffer_free(buf);
Index: gnc-hbci-utils.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-utils.h,v
retrieving revision 1.12.4.4
retrieving revision 1.12.4.5
diff -Lsrc/import-export/hbci/gnc-hbci-utils.h -Lsrc/import-export/hbci/gnc-hbci-utils.h -u -r1.12.4.4 -r1.12.4.5
--- src/import-export/hbci/gnc-hbci-utils.h
+++ src/import-export/hbci/gnc-hbci-utils.h
@@ -25,6 +25,7 @@
 
 #include <glib.h>
 #include <gnome.h>
+#include <iconv.h>
 
 #include <aqbanking/banking.h>
 #include <aqbanking/transaction.h>
@@ -76,6 +77,11 @@
 int
 gnc_hbci_debug_outboxjob (AB_JOB *job, gboolean verbose);
 
+/** Clean up the queue after executing, i.e. delete the job as good as
+    possible. */
+void
+gnc_hbci_cleanup_job(AB_BANKING *api, AB_JOB *job);
+
 /* Check int on whether some feedback should be given to the
  * user. Returns true if the HBCI action should be tried again; on the
  * other hand, returns false if the user can't do anything about this
@@ -144,4 +150,16 @@
 /** Return a newly allocated string. */
 char *gnc_AB_VALUE_toReadableString(const AB_VALUE *v);
 
+/** Returns a newly allocated gchar, converted according to the given
+   handler */
+gchar *gnc_call_iconv(iconv_t handler, const char* input);
+
+/** Returns the encoding of the current book in the format as required
+    by iconv_open(3). */
+const char *gnc_hbci_book_encoding(void);
+
+/** Returns the encoding that is required by AqBanking in the format
+    as required by iconv_open(3). */
+const char *gnc_hbci_AQBANKING_encoding(void);
+
 #endif
Index: dialog-hbcitrans.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/dialog-hbcitrans.c,v
retrieving revision 1.9.4.10
retrieving revision 1.9.4.11
diff -Lsrc/import-export/hbci/dialog-hbcitrans.c -Lsrc/import-export/hbci/dialog-hbcitrans.c -u -r1.9.4.10 -r1.9.4.11
--- src/import-export/hbci/dialog-hbcitrans.c
+++ src/import-export/hbci/dialog-hbcitrans.c
@@ -27,8 +27,11 @@
 #endif
 
 #include <gnome.h>
+#include <aqbanking/version.h>
 #include <aqbanking/account.h>
 #include <aqbanking/jobsingletransfer.h>
+#include <aqbanking/jobsingledebitnote.h>
+#include <iconv.h>
 
 #include "dialog-utils.h"
 #include "gnc-ui.h"
@@ -432,7 +435,16 @@
       printf("gnc_hbci_trans_dialog_enqueue: Oops, job not available. Aborting.\n");
       return -1;
     }
+#if ((AQBANKING_VERSION_MAJOR > 1) || \
+     ((AQBANKING_VERSION_MAJOR == 1) && \
+      ((AQBANKING_VERSION_MINOR > 0) || \
+       ((AQBANKING_VERSION_MINOR == 0) && \
+        (AQBANKING_VERSION_PATCHLEVEL > 6)))))
+    max_purpose_lines = AB_TransactionLimits_GetMaxLinesPurpose
+      ( AB_JobSingleTransfer_GetFieldLimits(job) );
+#else
     max_purpose_lines = AB_JobSingleTransfer_GetMaxPurposeLines(job);
+#endif
     /* these are the number of fields, 27 characters each. */
     AB_Job_free(job);
   }
@@ -501,7 +513,6 @@
   return result;
 }
 
-
 /** Create a new AB_TRANSACTION, fill the values from the entry
     fields into it and return it. The caller must
     AB_TRANSACTION_free() it when finished. */
@@ -510,6 +521,15 @@
 {
   /* Fill in the user-entered values */
   AB_TRANSACTION *trans = AB_Transaction_new();
+  gchar *tmpchar;
+
+  /* FIXME: The internal source encoding is hard-coded so far. This
+     needs to be fixed for the gnome2 version; the source encoding is
+     then probably utf-8 as well. iconv is also used in
+     gnc_AB_BANKING_interactors() in hbci-interaction.c. */
+  iconv_t gnc_iconv_handler =
+    iconv_open(gnc_hbci_AQBANKING_encoding(), gnc_hbci_book_encoding());
+  g_assert(gnc_iconv_handler != (iconv_t)(-1));
 	
   /* OpenHBCI newer than 0.9.8: use account's bankCode values
    * instead of the bank's ones since this is what some banks
@@ -528,19 +548,32 @@
   /* printf("Got otherAccountId %s.\n",
      AB_Transaction_otherAccountId (trans)); */
   AB_Transaction_SetRemoteCountry (trans, "DE");
-  AB_Transaction_AddRemoteName
-    (trans, gtk_entry_get_text (GTK_ENTRY (td->recp_name_entry)), FALSE);
+
+  /* Convert the result of GTK_ENTRY into UTF-8 */
+  tmpchar = gnc_call_iconv(gnc_iconv_handler, 
+			   gtk_entry_get_text (GTK_ENTRY (td->recp_name_entry)));
+  AB_Transaction_AddRemoteName (trans, tmpchar, FALSE);
+  g_free (tmpchar);
 	
   /* The last argument means: If TRUE, then the string will be only be
      appended if it doesn't exist yet. */
-  AB_Transaction_AddPurpose
-    (trans, gtk_entry_get_text (GTK_ENTRY (td->purpose_entry)), FALSE);
-  AB_Transaction_AddPurpose
-    (trans, gtk_entry_get_text (GTK_ENTRY (td->purpose_cont_entry)), FALSE);
-  AB_Transaction_AddPurpose
-    (trans, gtk_entry_get_text (GTK_ENTRY (td->purpose_cont2_entry)), FALSE);
-  AB_Transaction_AddPurpose
-    (trans, gtk_entry_get_text (GTK_ENTRY (td->purpose_cont3_entry)), FALSE);
+  /* Convert the result of GTK_ENTRY into UTF-8 */
+  tmpchar = gnc_call_iconv(gnc_iconv_handler, 
+			   gtk_entry_get_text (GTK_ENTRY (td->purpose_entry)));
+  AB_Transaction_AddPurpose (trans, tmpchar, FALSE);
+  g_free (tmpchar);
+  tmpchar = gnc_call_iconv(gnc_iconv_handler, 
+			   gtk_entry_get_text (GTK_ENTRY (td->purpose_cont_entry)));
+  AB_Transaction_AddPurpose (trans, tmpchar, FALSE);
+  g_free (tmpchar);
+  tmpchar = gnc_call_iconv(gnc_iconv_handler, 
+			   gtk_entry_get_text (GTK_ENTRY (td->purpose_cont2_entry)));
+  AB_Transaction_AddPurpose (trans, tmpchar, FALSE);
+  g_free (tmpchar);
+  tmpchar = gnc_call_iconv(gnc_iconv_handler, 
+			   gtk_entry_get_text (GTK_ENTRY (td->purpose_cont3_entry)));
+  AB_Transaction_AddPurpose (trans, tmpchar, FALSE);
+  g_free (tmpchar);
 	
   /* FIXME: Replace "EUR" by account-dependent string here. */
   AB_Transaction_SetValue 
@@ -559,6 +592,7 @@
     AB_Transaction_SetTextKey (trans, 51);
   }
 
+  iconv_close(gnc_iconv_handler);
   return trans;
 }
 
@@ -620,7 +654,14 @@
   AB_JOB *job;
 
   /* Create a Do-Transaction (Transfer) job. */
-  job = AB_JobSingleTransfer_new(h_acc);
+  switch (trans_type) {
+  case SINGLE_DEBITNOTE:
+    job = AB_JobSingleDebitNote_new(h_acc);
+    break;
+  default:
+  case SINGLE_TRANSFER:
+    job = AB_JobSingleTransfer_new(h_acc);
+  };
   if (AB_Job_CheckAvailability(job)) {
     printf("gnc_hbci_trans_dialog_enqueue: Oops, job not available. Aborting.\n");
     return NULL;
Index: gnc-hbci-utils.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-utils.c,v
retrieving revision 1.23.4.7
retrieving revision 1.23.4.8
diff -Lsrc/import-export/hbci/gnc-hbci-utils.c -Lsrc/import-export/hbci/gnc-hbci-utils.c -u -r1.23.4.7 -r1.23.4.8
--- src/import-export/hbci/gnc-hbci-utils.c
+++ src/import-export/hbci/gnc-hbci-utils.c
@@ -25,6 +25,8 @@
 
 #include <gnome.h>
 #include <errno.h>
+#include <iconv.h>
+#include <langinfo.h>
 #include <gwenhywfar/directory.h>
 
 #include "gnc-ui.h"
@@ -134,7 +136,7 @@
 
     if (!hbci_acc && bankcode && (strlen(bankcode)>0) &&
 	accountid && (strlen(accountid) > 0)) {
-      printf("gnc_hbci_get_hbci_acc: No AB_ACCOUNT found for UID %d, trying bank code\n", account_uid);
+      /* printf("gnc_hbci_get_hbci_acc: No AB_ACCOUNT found for UID %d, trying bank code\n", account_uid); */
       hbci_acc = AB_Banking_GetAccountByCodeAndNumber(api, bankcode, accountid);
     }
     /*printf("gnc_hbci_get_hbci_acc: return HBCI_Account %p\n", hbci_acc);*/
@@ -239,6 +241,18 @@
   return cause;
 }
 
+void
+gnc_hbci_cleanup_job(AB_BANKING *api, AB_JOB *job)
+{
+  if (AB_Job_GetStatus(job) == AB_Job_StatusFinished) {
+    AB_Banking_DelFinishedJob(api, job);
+  } else if (AB_Job_GetStatus(job) == AB_Job_StatusPending) {
+    AB_Banking_DelPendingJob(api, job);
+  }
+  /* Martin assured me that there will be no job in the queue after
+     ExecuteQueue, so we don't need to remove it from the queue. */
+}
+
 
 gboolean
 gnc_hbci_Error_retry (GtkWidget *parent, int error, 
@@ -463,16 +477,22 @@
   }
 }
 
+struct cb_struct {
+  gchar **result;
+  iconv_t gnc_iconv_handler;
+};
+
 /* Needed for the gnc_hbci_descr_tognc and gnc_hbci_memo_tognc. */
 static void *gnc_list_string_cb (const char *string, void *user_data)
 {
-  gchar **res = user_data;
+  struct cb_struct *u = user_data;
+  gchar **res = u->result;
   gchar *tmp1, *tmp2;
 
   if (!string) return NULL;
-  tmp1 = g_strdup (string);
-  g_strstrip (tmp1);
+  tmp1 = gnc_call_iconv(u->gnc_iconv_handler, string);
 
+  g_strstrip (tmp1);
   if (strlen (tmp1) > 0) {
     if (*res != NULL) {
       /* The " " is the separating string in between each two strings. */
@@ -499,19 +519,27 @@
   char *g_descr;
   const GWEN_STRINGLIST *h_purpose = AB_Transaction_GetPurpose (h_trans);
   const GWEN_STRINGLIST *h_remotename = AB_Transaction_GetRemoteName (h_trans);
+  struct cb_struct cb_object;
+
+  cb_object.gnc_iconv_handler = 
+    iconv_open(gnc_hbci_book_encoding(), gnc_hbci_AQBANKING_encoding());
+  g_assert(cb_object.gnc_iconv_handler != (iconv_t)(-1));
 
   /* Don't use list_string_concat_delim here since we need to
      g_strstrip every single element of the string list, which is
      only done in our callback gnc_list_string_cb. The separator is
      also set there. */
+  cb_object.result = &h_descr;
   if (h_purpose)
     GWEN_StringList_ForEach (h_purpose,
 			     &gnc_list_string_cb,
-			     &h_descr);
+			     &cb_object);
+
+  cb_object.result = &othername;
   if (h_remotename)
     GWEN_StringList_ForEach (h_remotename,
 			     &gnc_list_string_cb,
-			     &othername);
+			     &cb_object);
   /*DEBUG("HBCI Description '%s'", h_descr);*/
 
   if (othername && (strlen (othername) > 0))
@@ -527,6 +555,7 @@
        g_strdup (h_descr) : 
        g_strdup (_("Unspecified")));
 
+  iconv_close(cb_object.gnc_iconv_handler);
   free (h_descr);
   free (othername);
   return g_descr;
@@ -834,3 +863,36 @@
     sprintf(tmp, "%.2f", 0.0);
   return g_strdup(tmp);
 }
+
+/* Returns a newly allocated gchar, converted according to the given
+   handler */
+gchar *gnc_call_iconv(iconv_t handler, const char* input)
+{
+  char *inbuffer = (char*)input;
+  char *outbuffer, *outbufferstart;
+  int inbytes, outbytes;
+
+  inbytes = strlen(inbuffer);
+  outbytes = inbytes + 2;
+  outbufferstart = g_strndup(inbuffer, outbytes);
+  outbuffer = outbufferstart;
+  iconv(handler, &inbuffer, &inbytes, &outbuffer, &outbytes);
+  if (outbytes > 0) 
+    *outbuffer = '\0';
+  return outbufferstart;
+}
+
+const char *gnc_hbci_book_encoding()
+{
+#if HAVE_LANGINFO_CODESET
+  char* encoding = nl_langinfo(CODESET);
+#else
+  char* encoding = "ISO8859-15";
+#endif
+  return encoding;
+}
+
+const char *gnc_hbci_AQBANKING_encoding()
+{
+  return "UTF-8";
+}
--- /dev/null
+++ src/import-export/hbci/HACKING-HBCITEST.txt
@@ -0,0 +1,56 @@
+By Christian Stimming, 2005-01-11
+
+Hi all developers,
+
+as you know, Gnucash includes support for the German online banking 
+protocol HBCI, and I usually emphasize that anyone outside Germany will 
+be unable to use all these cool features. But it recently came to my 
+mind that there is a test server, simulating a HBCI bank, which is run 
+by a friend of us (Stefan Palme), and he is able to give the Gnucash 
+developers something like a test account for, well, testing purposes.
+
+One authentification method of the HBCI protocol requires only a PIN for 
+login, and a TAN (transaction number) for each issued online order. We 
+can use this as a shared test account, because anyone who knows the PIN 
+(and some TANs) can use it. So I invite all you fellow developers to 
+install the HBCI features of gnucash, start the HBCI setup druid, setup 
+a Pin/Tan-based HBCI account, and just try out all the possible 
+features. Naturally, this test account won't move any real money around )
+
+(The Pin/Tan authentification method was added in 1.8.10 when changing 
+the HBCI library to Aqbanking. This method is rather insecure, but since 
+it is very simple to use there is quite some demand for it. So we 
+eventually implemented it in gnucash. I wouldn't recommend this for real 
+online banking if there is any of the other HBCI authentification 
+methods like chip cards or RSA keys available.)
+
+Here's what you need to enter in the HBCI setup druid:
+* "Use Pin/Tan mode"
+* Bank Code: 80007777
+   Server: www.hora-obscura.de/pintan/PinTanServlet 
+   (the URL changed on 2005-01-15)
+
+   User-Name: (something arbitrary; only for yourself)
+   User-Id: gnucash
+   Customer-Id: gnucash [or as a second customer: gnucash2]
+* Then press next all the time
+* For this user the PIN is: 12345
+* The setup druid should automatically recognize that this account 
+  offers access to the account numbers "2501111538" and "2501111539"
+* That finishes the setup.
+
+If you want to send money between these two account numbers back and 
+forth, you can do so by using any of the following TANs:
+                                  11111111
+                                  22222222
+                                  ...
+                                  99999999
+
+Enjoy! Don't hesitate to notify me if anything is broke.
+
+Christian stimming at tuhh.de
+
+
+There's an administrator web frontend reachable under
+https://www.hora-obscura.de/hbci wheren the used TANs can be
+resetted. The password for this can be asked from Christian Stimming.
Index: gnc-hbci-getbalance.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-getbalance.c,v
retrieving revision 1.13.4.8
retrieving revision 1.13.4.9
diff -Lsrc/import-export/hbci/gnc-hbci-getbalance.c -Lsrc/import-export/hbci/gnc-hbci-getbalance.c -u -r1.13.4.8 -r1.13.4.9
--- src/import-export/hbci/gnc-hbci-getbalance.c
+++ src/import-export/hbci/gnc-hbci-getbalance.c
@@ -102,9 +102,7 @@
     if (!gnc_AB_BANKING_execute (parent, api, job, interactor)) {
 
       /* AB_BANKING_executeOutbox failed. */
-      AB_Banking_DequeueJob(api, job);
-      AB_Banking_DelFinishedJob(api, job);
-      AB_Banking_DelPendingJob(api, job);
+      gnc_hbci_cleanup_job(api, job);
       /* FIXME: free unneeded data */
       return;
     }
@@ -117,9 +115,7 @@
 				job);
 
     /* Clean up after ourselves. */
-    AB_Banking_DequeueJob(api, job);
-    AB_Banking_DelFinishedJob(api, job);
-    AB_Banking_DelPendingJob(api, job);
+    gnc_hbci_cleanup_job(api, job);
     gnc_AB_BANKING_fini (api);
     GNCInteractor_hide (interactor);
   }
@@ -201,6 +197,7 @@
   time_t booked_tt;
   gboolean dialogres;
   double booked_value, noted_value;
+  gnc_numeric value;
 
   response = AB_JobGetBalance_GetAccountStatus((AB_JOB*)job);
   if (!response) {
@@ -242,6 +239,9 @@
     noted_val = NULL;
   }
 
+  value = double_to_gnc_numeric (booked_value,
+				 xaccAccountGetCommoditySCU(gnc_acc),
+				 GNC_RND_ROUND);
   if ((noted_value == 0.0) && (booked_value == 0.0))
     {
       gnome_ok_dialog_parented 
@@ -260,6 +260,8 @@
     }
   else
     {
+      gnc_numeric reconc_balance = xaccAccountGetReconciledBalance (gnc_acc);
+
       char *booked_str = gnc_AB_VALUE_toReadableString (booked_val);
       char *message1 = g_strdup_printf
 	(
@@ -273,14 +275,24 @@
 	 (_("For your information: This account also \n"
 	    "has a noted balance of %s\n"),
 	  noted_val));
-      const char *message3 = _("Reconcile account now?");
-
-      dialogres = gnc_verify_dialog
-	(parent, 
-	 TRUE,
-	 "%s%s\n%s",
-	 message1, message2, message3);
 
+      if (gnc_numeric_equal(value, reconc_balance)) {
+	const char *message3 = _("The booked balance is identical to the current \n"
+				 "reconciled balance of the account.");
+	char *msg = g_strdup_printf ("%s%s\n%s", message1, message2, message3);
+	gnome_ok_dialog_parented (msg, GTK_WINDOW (parent));
+	g_free (msg);
+	dialogres = FALSE;
+
+      } else {
+	const char *message3 = _("Reconcile account now?");
+
+	dialogres = gnc_verify_dialog
+	  (parent, 
+	   TRUE,
+	   "%s%s\n%s",
+	   message1, message2, message3);
+      }
       g_free (message1);
       g_free (message2);
       free (booked_str);
@@ -289,10 +301,6 @@
       
   if (dialogres) 
     {
-      gnc_numeric value =
-	double_to_gnc_numeric (booked_value,
-			       xaccAccountGetCommoditySCU(gnc_acc),
-			       GNC_RND_ROUND);
       recnWindowWithBalance (parent, 
 			     gnc_acc, 
 			     value,
Index: hbci-interaction.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/hbci-interaction.h,v
retrieving revision 1.6.4.4
retrieving revision 1.6.4.5
diff -Lsrc/import-export/hbci/hbci-interaction.h -Lsrc/import-export/hbci/hbci-interaction.h -u -r1.6.4.4 -r1.6.4.5
--- src/import-export/hbci/hbci-interaction.h
+++ src/import-export/hbci/hbci-interaction.h
@@ -42,6 +42,7 @@
 void GNCInteractor_set_cache_valid(GNCInteractor *i, gboolean value);
 GtkWidget *GNCInteractor_parent(GNCInteractor *i);
 void GNCInteractor_add_log_text (GNCInteractor *i, const char *msg);
+gboolean GNCInteractor_hadErrors (const GNCInteractor *i);
 
 
 #endif
Index: hbci-interactionP.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/hbci-interactionP.h,v
retrieving revision 1.4.4.4
retrieving revision 1.4.4.5
diff -Lsrc/import-export/hbci/hbci-interactionP.h -Lsrc/import-export/hbci/hbci-interactionP.h -u -r1.4.4.4 -r1.4.4.5
--- src/import-export/hbci/hbci-interactionP.h
+++ src/import-export/hbci/hbci-interactionP.h
@@ -76,6 +76,8 @@
   GHashTable *showbox_hash; 
   GtkWidget *showbox_last;
 
+  /* Flag whether the last dialog showed any error */
+  gboolean msgBoxError;
 };
 
 void delete_GNCInteractor (GNCInteractor *data);
Index: hbci-interaction.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/hbci-interaction.c,v
retrieving revision 1.16.4.9
retrieving revision 1.16.4.10
diff -Lsrc/import-export/hbci/hbci-interaction.c -Lsrc/import-export/hbci/hbci-interaction.c -u -r1.16.4.9 -r1.16.4.10
--- src/import-export/hbci/hbci-interaction.c
+++ src/import-export/hbci/hbci-interaction.c
@@ -54,7 +54,12 @@
   
   data = g_new0 (GNCInteractor, 1);
   data->parent = parent;
-  data->gnc_iconv_handler = iconv_open("ISO8859-1", "UTF-8");
+  /* FIXME: The internal target encoding is hard-coded so far. This
+     needs to be fixed for the gnome2 version; the target encoding is
+     then probably utf-8 as well. iconv is also used in
+     gnc_hbci_descr_tognc() in gnc-hbci-utils.c. */
+  data->gnc_iconv_handler = 
+    iconv_open(gnc_hbci_book_encoding(), gnc_hbci_AQBANKING_encoding());
   g_assert(data->gnc_iconv_handler != (iconv_t)(-1));
   data->keepAlive = TRUE;
   data->cache_pin = 
@@ -107,6 +112,7 @@
   data->state = RUNNING;
   gtk_widget_set_sensitive (GTK_WIDGET (data->abort_button), TRUE);
   gtk_widget_set_sensitive (GTK_WIDGET (data->close_button), FALSE);
+  data->keepAlive = TRUE;
 }
 static void GNCInteractor_setFinished (GNCInteractor *data)
 {
@@ -203,6 +209,12 @@
     }
 }
 
+gboolean GNCInteractor_hadErrors (const GNCInteractor *i)
+{
+  g_assert (i);
+  return i->msgBoxError != 0;
+}
+
 /* ************************************************************ 
  */
 
@@ -256,9 +268,7 @@
 
 char *gnc_hbci_utf8ToLatin1(GNCInteractor *data, const char *utf)
 {
-  int inbytes, outbytes;
   char *utf8extracted, *latin1;
-  char *inbuffer, *outbuffer;
 
   g_assert(data);
   if (!utf) return g_strdup("");
@@ -267,16 +277,7 @@
   utf8extracted = gnc__extractText(utf);
 /*   printf("Extracted \"%s\" into \"%s\"\n", utf, utf8extracted); */
 
-  inbuffer = utf8extracted;
-  inbytes = strlen(inbuffer);
-  outbytes = inbytes + 2;
-  latin1 = g_strndup(inbuffer, outbytes);
-  outbuffer = latin1;
-
-  iconv(data->gnc_iconv_handler, &inbuffer, &inbytes,
-	&outbuffer, &outbytes);
-  if (outbytes > 0)
-    *outbuffer = '\0';
+  latin1 = gnc_call_iconv(data->gnc_iconv_handler, utf8extracted);
 
 /*   printf("Converted \"%s\" into \"%s\"\n", utf8extracted, latin1); */
   g_free(utf8extracted);
@@ -306,6 +307,7 @@
   data = AB_Banking_GetUserData(ab);
   g_assert(data);
   g_assert(maxLen > minsize);
+  data->msgBoxError = flags & AB_BANKING_MSG_FLAGS_TYPE_ERROR;
 
   text = gnc_hbci_utf8ToLatin1(data, utf8text);
   title = gnc_hbci_utf8ToLatin1(data, utf8title);
@@ -385,6 +387,7 @@
   data = AB_Banking_GetUserData(ab);
   g_assert(data);
   g_assert(maxLen > minsize);
+  data->msgBoxError = 0;
 
   text = gnc_hbci_utf8ToLatin1(data, utf8text);
   title = gnc_hbci_utf8ToLatin1(data, utf8title);
@@ -494,6 +497,7 @@
   g_assert(ab);
   data = AB_Banking_GetUserData(ab);
   g_assert(data);
+  data->msgBoxError = flags & AB_BANKING_MSG_FLAGS_TYPE_ERROR;
   
   text = gnc_hbci_utf8ToLatin1(data, utf8text);
   title = gnc_hbci_utf8ToLatin1(data, utf8title);
@@ -530,6 +534,7 @@
   g_assert(ab);
   data = AB_Banking_GetUserData(ab);
   g_assert(data);
+  data->msgBoxError = flags & AB_BANKING_MSG_FLAGS_TYPE_ERROR;
 
   text = gnc_hbci_utf8ToLatin1(data, utf8text);
   title = gnc_hbci_utf8ToLatin1(data, utf8title);
@@ -630,8 +635,7 @@
 				   progress/data->action_max);
   }
 
-  keepAlive(data);
-  return 0;
+  return !keepAlive(data);
 }
 
 
@@ -655,8 +659,7 @@
   GNCInteractor_add_log_text (data, text);
 
   g_free(text);
-  keepAlive(data);
-  return 0;
+  return !keepAlive(data);
 }
 
 static int progressEndCB(AB_BANKING *ab, GWEN_TYPE_UINT32 id)
Index: gnc-hbci-gettrans.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-gettrans.c,v
retrieving revision 1.20.4.7
retrieving revision 1.20.4.8
diff -Lsrc/import-export/hbci/gnc-hbci-gettrans.c -Lsrc/import-export/hbci/gnc-hbci-gettrans.c -u -r1.20.4.7 -r1.20.4.8
--- src/import-export/hbci/gnc-hbci-gettrans.c
+++ src/import-export/hbci/gnc-hbci-gettrans.c
@@ -107,11 +107,11 @@
     AB_Banking_EnqueueJob(api, job);
 
     /* Execute Outbox. */
-    if (!gnc_AB_BANKING_execute (parent, api, job, interactor)) {
+    if (!gnc_AB_BANKING_execute (parent, api, job, interactor) ||
+	(AB_Job_GetStatus(job) == AB_Job_StatusError) ||
+	GNCInteractor_hadErrors (interactor)) {
       /* AB_BANKING_executeOutbox failed. */
-      AB_Banking_DequeueJob(api, job);
-      AB_Banking_DelFinishedJob(api, job);
-      AB_Banking_DelPendingJob(api, job);
+      gnc_hbci_cleanup_job(api, job);
       return;
     }
 
@@ -122,12 +122,11 @@
     gnc_hbci_gettrans_final(parent, gnc_acc, job, FALSE);
 
     /* Clean up behind ourself. */
-    AB_Banking_DequeueJob(api, job);
-    AB_Banking_DelFinishedJob(api, job);
-    AB_Banking_DelPendingJob(api, job);
+    gnc_hbci_cleanup_job(api, job);
     gnc_AB_BANKING_fini (api);
     GNCInteractor_hide (interactor);
-    GWEN_Time_free (from_date);
+    if (from_date) 
+      GWEN_Time_free (from_date);
     GWEN_Time_free (to_date);
   }
 }
@@ -152,35 +151,36 @@
   last_timespec = gnc_hbci_get_account_trans_retrieval (gnc_acc);
   if (last_timespec.tv_sec == 0) {
     use_last_date = FALSE;
-      timespecFromTime_t (&last_timespec, now);
-    }
-    timespecFromTime_t (&until_timespec, now);
+    timespecFromTime_t (&last_timespec, now);
+  }
+  timespecFromTime_t (&until_timespec, now);
 
-    /* Let the user choose the date range of retrieval */
-    if (!gnc_hbci_enter_daterange (parent, NULL, 
-				   &last_timespec, 
-				   &use_last_date, &use_earliest_date,
-				   &until_timespec, &use_until_now))
-      return FALSE;
-
-    /*printf("Retrieving transactions from date %s to date %s. \n",
-	   ctime(&()))*/
-    
-    /* Now calculate from date */
-    if (use_earliest_date)
-      *from_date = GWEN_Time_fromSeconds(0);
-    else {
-      if (use_last_date)
-	last_timespec = gnc_hbci_get_account_trans_retrieval (gnc_acc);
-      *from_date = GWEN_Time_fromSeconds(timespecToTime_t(last_timespec));
-    }
+  /* Let the user choose the date range of retrieval */
+  if (!gnc_hbci_enter_daterange (parent, NULL, 
+				 &last_timespec, 
+				 &use_last_date, &use_earliest_date,
+				 &until_timespec, &use_until_now))
+    return FALSE;
+
+  /*printf("Retrieving transactions from date %s to date %s. \n",
+    ctime(&()))*/
+    
+  /* Now calculate from date */
+  if (use_earliest_date)
+    *from_date = NULL;
+  /* for an old version this was: from_date = GWEN_Time_fromSeconds(0); */
+  else {
+    if (use_last_date)
+      last_timespec = gnc_hbci_get_account_trans_retrieval (gnc_acc);
+    *from_date = GWEN_Time_fromSeconds(timespecToTime_t(last_timespec));
+  }
 
-    /* Now calculate to date */
-    if (use_until_now)
-      timespecFromTime_t (&until_timespec, now);
-    *to_date = GWEN_Time_fromSeconds(timespecToTime_t (until_timespec));
+  /* Now calculate to date */
+  if (use_until_now)
+    timespecFromTime_t (&until_timespec, now);
+  *to_date = GWEN_Time_fromSeconds(timespecToTime_t (until_timespec));
 
-    return TRUE;
+  return TRUE;
 }
 
 
@@ -197,7 +197,7 @@
 
   trans_list = AB_JobGetTransactions_GetTransactions(trans_job);
   if (!trans_list) {
-    printf("gnc_hbci_gettrans_final: No transactions section. Response was:\n");
+    /* printf("gnc_hbci_gettrans_final: No transactions section. Response was:\n"); */
 
     gnome_ok_dialog_parented 
       (_("The HBCI import returned no transactions for the selected time period."),
@@ -208,7 +208,7 @@
   if (trans_list && (AB_Transaction_List2_GetSize(trans_list) > 0)) {
     struct trans_list_data data;
     GNCImportMainMatcher *importer_generic_gui = 
-      gnc_gen_trans_list_new(NULL, NULL, TRUE);
+      gnc_gen_trans_list_new(NULL, NULL, TRUE, 14);
 
     data.importer_generic = importer_generic_gui;
     data.gnc_acc = gnc_acc;
Index: gnc-hbci-transfer.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-transfer.c,v
retrieving revision 1.7.4.5
retrieving revision 1.7.4.6
diff -Lsrc/import-export/hbci/gnc-hbci-transfer.c -Lsrc/import-export/hbci/gnc-hbci-transfer.c -u -r1.7.4.5 -r1.7.4.6
--- src/import-export/hbci/gnc-hbci-transfer.c
+++ src/import-export/hbci/gnc-hbci-transfer.c
@@ -135,15 +135,9 @@
 	    xaccTransBeginEdit(gtrans);
 	    xaccTransDestroy(gtrans);
 	    xaccTransCommitEdit(gtrans);
-
-/* 	    AB_Banking_DequeueJob(api, job); */
-/* 	    AB_Banking_DelFinishedJob(api, job); */
-/* 	    AB_Banking_DelPendingJob(api, job); */
 	  }
 	  
-	  AB_Banking_DequeueJob(api, job);
-	  AB_Banking_DelFinishedJob(api, job);
-	  AB_Banking_DelPendingJob(api, job);
+	  gnc_hbci_cleanup_job(api, job);
 	} /* result == 0 */
 	else {
 	  /* huh? Only result == 0 should be possible. Simply ignore
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/Makefile.am,v
retrieving revision 1.22.4.6
retrieving revision 1.22.4.7
diff -Lsrc/import-export/hbci/Makefile.am -Lsrc/import-export/hbci/Makefile.am -u -r1.22.4.6 -r1.22.4.7
--- src/import-export/hbci/Makefile.am
+++ src/import-export/hbci/Makefile.am
@@ -84,7 +84,7 @@
   ${GNOME_CFLAGS} \
   ${GTKHTML_CFLAGS} \
   ${HBCI_CFLAGS} \
-  ${GNOME_XML_CFLAGS}
+  ${XML_CFLAGS}
 
 #gladedir = $(GNC_GLADE_DIR)
 #glade_DATA = 
Index: gnc-hbci-kvp.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/hbci/gnc-hbci-kvp.c,v
retrieving revision 1.4.4.4
retrieving revision 1.4.4.5
diff -Lsrc/import-export/hbci/gnc-hbci-kvp.c -Lsrc/import-export/hbci/gnc-hbci-kvp.c -u -r1.4.4.4 -r1.4.4.5
--- src/import-export/hbci/gnc-hbci-kvp.c
+++ src/import-export/hbci/gnc-hbci-kvp.c
@@ -31,6 +31,14 @@
 #define HBCI_TRANS_RETRIEVAL "trans-retrieval"
 #define HBCI_ACCOUNTS "hbci-accounts"
 
+static void force_account_dirty(Account *acct)
+{
+  /* This is necessary because modifying the KvpFrames doesn't mark
+     accounts dirty, which means the changes wont be propagated to the
+     backend. */
+  xaccAccountSetName(acct, xaccAccountGetName(acct));
+}
+
 /* Account */
 char *gnc_hbci_get_account_accountid (Account *a)
 {
@@ -56,6 +64,7 @@
   kvp_value *value = kvp_value_new_string (id);
   xaccAccountBeginEdit(a);
   kvp_frame_set_slot_nc (frame, HBCI_ACCOUNT_ID, value);
+  force_account_dirty (a);
   xaccAccountCommitEdit (a);
 }
 void gnc_hbci_set_account_bankcode (Account *a, const char *code)
@@ -64,6 +73,7 @@
   kvp_value *value = kvp_value_new_string (code);
   xaccAccountBeginEdit (a);
   kvp_frame_set_slot_nc (frame, HBCI_BANK_CODE, value);
+  force_account_dirty (a);
   xaccAccountCommitEdit (a);
 }
 void gnc_hbci_set_account_countrycode (Account *a, gint code)
@@ -72,6 +82,7 @@
   kvp_value *value = kvp_value_new_gint64 (code);
   xaccAccountBeginEdit (a);
   kvp_frame_set_slot_nc (frame, HBCI_COUNTRY_CODE, value);
+  force_account_dirty (a);
   xaccAccountCommitEdit (a);
 }
 gint gnc_hbci_get_account_uid (Account *a)
@@ -86,6 +97,7 @@
   kvp_value *value = kvp_value_new_gint64 (uid);
   xaccAccountBeginEdit (a);
   kvp_frame_set_slot_nc (frame, HBCI_ACCOUNT_UID, value);
+  force_account_dirty (a);
   xaccAccountCommitEdit (a);
 }
 Timespec gnc_hbci_get_account_trans_retrieval (Account *a)
@@ -100,6 +112,7 @@
   kvp_value *value = kvp_value_new_timespec (time);
   xaccAccountBeginEdit (a);
   kvp_frame_set_slot_nc (frame, HBCI_TRANS_RETRIEVAL, value);
+  force_account_dirty (a);
   xaccAccountCommitEdit (a);
 }
 
Index: configure.in
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/configure.in,v
retrieving revision 1.359.2.40
retrieving revision 1.359.2.41
diff -Lconfigure.in -Lconfigure.in -u -r1.359.2.40 -r1.359.2.41
--- configure.in
+++ configure.in
@@ -547,21 +547,35 @@
 	LIBOFX_CFLAGS="-I${OFXPREFIX}/include"
     fi
 
-    # check libofx version
+    ### Check libofx version
+    # Obtain version string
     AC_MSG_CHECKING(for libofx version >= 0.7.0)
     if test x${OFXPREFIX} = x ; then
-	LIBOFX_VERSION=`ofxdump --version | cut -d" " -f2`
+	ofx_version_output=`ofxdump --version`
     else
-	LIBOFX_VERSION=`${OFXPREFIX}/bin/ofxdump --version | cut -d" " -f2`
+	ofx_version_output=`${OFXPREFIX}/bin/ofxdump --version`
     fi
-    if test `echo ${LIBOFX_VERSION} | cut -d. -f1` -ge 1 -o \
-	     `echo ${LIBOFX_VERSION} | cut -d. -f2` -ge 7; then
+    # Extract version number; output format changed from 0.6.x to 0.7.x
+    LIBOFX_VERSION=`echo ${ofx_version_output} | sed 's/\([[^0-9]]*\)\([[0-9]]*\.\)/\2/' `
+    LIBOFX_VERSION_MAJOR=`echo ${LIBOFX_VERSION} | cut -d. -f1`
+    LIBOFX_VERSION_MINOR=`echo ${LIBOFX_VERSION} | cut -d. -f2`
+    # Make sure the numbers are not empty
+    if test x${LIBOFX_VERSION_MAJOR} = x ; then
+	LIBOFX_VERSION_MAJOR=0
+    fi
+    if test x${LIBOFX_VERSION_MINOR} = x ; then
+	LIBOFX_VERSION_MINOR=0
+    fi
+    # Now check for >= 0.7.x or >= 1.x.x
+    if test "${LIBOFX_VERSION_MAJOR}" -ge 1 -o \
+	     "${LIBOFX_VERSION_MINOR}" -ge 7; then
 	# This is libofx >= 0.7.x
 	AC_MSG_RESULT([found ${LIBOFX_VERSION}])
     else
-	AC_MSG_ERROR([Libofx 0.7.0 or newer needed for ofx support])
+	AC_MSG_ERROR([found ${LIBOFX_VERSION}; Libofx 0.7.0 or newer needed for ofx support])
     fi
 
+    # Version number verified. Now check header files.
     AC_MSG_CHECKING(for libofx/libofx.h)
     AS_SCRUB_INCLUDE(LIBOFX_CFLAGS)
     save_CPPFLAGS="${CPPFLAGS}"
@@ -607,7 +621,7 @@
 if test x${MT940_DIR} = xmt940 ;
 then
     AC_MSG_ERROR([Sorry, MT940 support is currently broken since it depended on the hbci module with the old openhbci 0.9.x library. But the hbci module has now been ported to a new hbci library called aqbanking. That library contains a MT940 parser, too, so porting shouldnt be too difficult. Nevertheless someone needs to do the porting work before this can be enabled again.])
-    AC_AQBANKING(0,9,8)
+    AC_AQBANKING(1,0,0)
     # Note: HBCI_LIBS is changed again below in the --enable-hbci
     # section. So check for mt940 first and *not* the other way round!
     HBCI_LIBS="${OPENHBCI_LIBS}"
@@ -629,7 +643,7 @@
 if test x${HBCI_DIR} = xhbci ;
 then
     # Check for Aqbanking library
-    AC_AQBANKING(0,9,8)
+    AC_AQBANKING(1,0,0)
     if test x${have_aqbanking} != xyes; 
     then
 	AC_MSG_ERROR([Could not find aqbanking. If you use --enable-hbci, you *have* to enable aqbanking.])
@@ -662,6 +676,11 @@
 dnl check for nl_langinfo(D_FMT) which is missing on FreeBSD
 LANGINFO_D_FMT_CHECK
 
+dnl Enable locale-specific tax-related information in the accounts
+AC_ARG_ENABLE( locale-specific-tax,
+  [  --enable-locale-specific-tax enable localized tax categories (experimental)],
+  AC_DEFINE(LOCALE_SPECIFIC_TAX,1,Enable the experimental locale-specific tax categories) )
+
 ### --------------------------------------------------------------------------
 ### help files
 
Index: ChangeLog
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/ChangeLog,v
retrieving revision 1.1487.2.185
retrieving revision 1.1487.2.186
diff -LChangeLog -LChangeLog -u -r1.1487.2.185 -r1.1487.2.186
--- ChangeLog
+++ ChangeLog
@@ -3192,6 +3192,216 @@
 -=-=-=- cvs HEAD ChangeLog is below this line -=-=-=-
 
 
+2005-04-02  Christian Stimming  <stimming at tuhh.de>
+
+	* src/import-export/hbci/dialog-hbcitrans.c: Fix warning about
+	deprecated aqbanking function in aqbanking-1.0.7
+
+2005-03-20  Christian Stimming  <stimming at tuhh.de>
+
+	* src/import-export/hbci/gnc-hbci-utils.c: Retrieve the current
+	book's character encoding which so far is identical to the
+	locale's encoding by nl_langinfo().
+
+	* src/import-export/hbci/hbci-interaction.c: Fixed ignored 'abort'
+	button.
+
+2005-03-19  Christian Stimming  <stimming at tuhh.de>
+
+	* src/import-export/hbci/gnc-hbci-utils.c (gnc_hbci_descr_tognc):
+	Correctly convert imported transaction description from utf-8 to
+	the local encoding.
+
+2005-03-13  Christian Stimming  <stimming at tuhh.de>
+
+	* src/import-export/hbci/gnc-hbci-getbalance.c: Improve user
+	message when downloaded balance is already identical to reconciled
+	balance.
+
+2005-03-12  Christian Stimming  <stimming at tuhh.de>
+
+	* src/import-export/hbci/gnc-hbci-gettrans.c, hbci-interaction.h:
+	Improve error handling in HBCI operations.
+
+2005-02-26  Christian Stimming  <stimming at tuhh.de>
+
+	* src/import-export/hbci/gnc-hbci-kvp.c (force_account_dirty):
+	Force account 'dirty' after modifying the kvp_frame. Hopefully
+	fixes #165096.
+
+2005-02-21  Christian Stimming  <stimming at tuhh.de>
+
+	* src/import-export/import-backend.c, import-backend.h,
+	import-main-matcher.h: Revert the change in December about date
+	matching thresholds that broke some OFX import. Now, the hard
+	limit days interval is set by the importing sub-module when
+	creating the dialog. This way, HBCI and OFX can set their
+	different requirements. (Note: QIF does not use this code at all.)
+
+2005-02-20  Neil Williams  <linux at codehelp.co.uk>
+	* src/engine/qof_book_merge.c: Fix double free of the targetList
+	entities that cause xaccGroupGetNumSubAccounts to generate a
+	segmentation fault.
+	* src/engine/kvp_frame.c: 
+	* src/engine/kvp_frame.h:
+	Add kvp_value_to_bare_string to
+	generate strings without debug information.
+	* src/engine/qofsession.h:
+	* src/engine/qofsession.c:
+	Documentation tweaks to bring them into line with QOF and the
+	gnucash-gnome2-dev branch.
+
+2005-02-16  Derek Atkins  <derek at ihtfp.com>
+
+	* src/gnome-utils/dialog-utils.c: When trying to load the symbol
+	  from a glade file, Fall back to dlsym() if g_module_symbol()
+	  fails.  This is necessary to find the symbols on on certain *BSD
+	  systems.
+
+	* acinclude.m4: Add mips, mipsel, arm, and m68k for Debian.
+
+2005-02-06  Chris Lyttle  <chris at wilddev.net>
+
+	* src/scm/main.scm: Update for 1.8.11 release
+
+2005-02-06  Derek Atkins  <derek at ihtfp.com>
+
+	* src/engine/date.c: Fix the last-day-of-month computation for
+	  leap years.  Need to use modulo, not divide.  (Patch by
+	  Neil Williams.
+
+2005-02-06  Christian Stimming  <stimming at tuhh.de>
+
+	* src/import-export/hbci/gnc-hbci-gettrans.c: Fix HBCI date range
+	for statement download.
+
+2005-02-05  Derek Atkins  <derek at ihtfp.com>
+
+	* src/report/locale-specific/us/Makefile.am: make sure the
+	  scheme reports are part of the DIST.
+
+2005-01-30  Derek Atkins  <derek at ihtfp.com>
+
+	* src/engine/Account.c:
+	  This patch fixes: (QofAccessFunc)xaccAccountSetNonStdSCU in
+	  src/engine/Account.c - that's a Set routine allocated as a
+	  QofAccessFunc - the patch changes it to the appropriate Get
+	  routine - the QofSetterFunc is OK.
+
+	Neil Williams' QOF sync patch:
+	* This patch updates the QOF merge code to current QOF to bring
+	  the HEAD branch into sync. This update also makes
+	  qof_book_merge_param_as_string output strings that are
+	  compatible with QSF: using false instead of FALSE in string
+	  output and using the QSF_XSD_TIME for the datestrings.
+	
+	* src/engine/Account.c:
+	  - updated implementation of qofAccountSetParent().
+
+	* src/engine/Scrub.c:
+	* src/engine/Transaction.c:
+	  Add the transaction guid to some error warning messages.
+	  Fixes #165571.
+	
+2005-01-29  Derek Atkins  <derek at ihtfp.com>
+
+	David Montenegro's patch for bugs #95551, #124367.
+	* src/report/standard-reports/account-summary.scm:
+	  Rewrote account summary report. Now has fields for
+	  more account metadata. Properly handles mixed
+	  asset/liability subaccounts.
+	* src/report/standard-reports/html-acct-table.scm:
+	  Added functionality (account-type &c) and bug fixes
+	  (lone zb subtotals, spurious 'recursive-bal, typos)
+	  needed to make the new account-summary.scm work.
+
+	Thomas Bushnell's patch to protect non-backup pruning (#164875)
+	* src/backend/file/gnc-backend-file.c:
+	  When working on the file foo.xac, backups are named
+	  foo.DATE.xac.  But the backup file pruner will prune any old
+	  file named foo.DATE.anything.
+
+2005-01-29  Christian Stimming  <stimming at tuhh.de>
+
+	* configure.in, src/tax/us/gncmod-tax-us.c,
+	src/report/locale-specific/us/gncmod-locale-reports-us.c,
+	src/app-utils/gnc-ui-util.c: Make localized tax categories
+	disabled by default; can be enabled by
+	--enable-locale-specific-tax switch.
+
+	* src/import-export/hbci/dialog-hbcitrans.c: Enable debit notes
+	again. Various other improvements.
+
+	* src/import-export/hbci/druid-hbci-initial.c (on_aqhbci_button),
+	configure.in: Adapt to latest changes in aqbanking; external
+	wizard name is no longer hard-coded here but is asked from
+	aqbanking.
+
+2005-01-23  Derek Atkins  <derek at ihtfp.com>
+
+	* src/business/business-core/gncInvoice.c: Properly accumulate
+	  splits (bug #165053).  Also fixes a (related) memory leak
+	  (caused by the same lack-of-reference to accumulated splits).
+
+2005-01-16  Christian Stimming  <stimming at tuhh.de>
+
+	* src/app-utils/gnc-ui-util.c: Modify tax option code to load
+	tax-de_DE module in the appropriate locale.
+	
+	* src/report/locale-specific/us/gncmod-locale-reports-us.c,
+	de_DE.scm: Add scheme module for locale-report/us
+	resp. locale-report/de_DE again because it seems to be required.
+
+2005-01-15  Derek Atkins  <derek at ihtfp.com>
+
+	* Neil William's patch to remove static mergeData context.
+
+2005-01-12  Christian Stimming  <stimming at tuhh.de>
+
+	* rpm/gnucash.spec.in, rpm/README: Remove obsolete package
+	requirements from rpm spec file. Add warnings about using these
+	spec files with caution.
+
+2005-01-10  Christian Stimming  <stimming at tuhh.de>
+
+	* src/engine/guid.h: Fix gcc4 warnings as pointed out by bug
+	#162635
+
+	* src/report/locale-specific/us/gncmod-locale-reports-us.c,
+	src/tax/us/gncmod-tax-us.c: For German tax categories, make sure
+	the module name will match the de_DE locale or will fall back to
+	us module name all the time.
+
+2004-12-31  Derek Atkins  <derek at ihtfp.com>
+
+	John Ellson's patch to fix some gcc4 warnings (bug #162582).
+
+	Chris Shoemaker's gnc-trace patch.
+	* src/engine/gnc-trace.[ch]:
+	  - Recent use of malloc in gnc-trace breaks my compile, use g_malloc
+	  - Fix leak of filename mem
+	  - add indenting of trace file according to ENTER/LEAVE stack depth
+	  - have ENTER report file name of function along with function name
+
+	Chris Shoemaker's typo-fix patch.
+	* src/engine/qofbook.h:
+	* src/engine/qofid.h:
+	  general fixed typos and comments
+
+2004-12-29  Christian Stimming  <stimming at tuhh.de>
+
+	* src/tax/us/txf-de_DE.scm: Add Tax TXF categories for the de_DE
+	locale, i.e. the German tax report. If the current locale begins
+	with de_DE, the new German tax categories will be loaded,
+	otherwise the conventional U.S. ones. This is the easiest method
+	to allow other (non-U.S.) tax categories to be selected in the
+	accounts' tax settings.
+	
+	* src/report/locale-specific/us/taxtxf-de_DE.scm: Add Tax report
+	for de_DE locale. If the current locale begins with de_DE, the new
+	German tax report will be loaded, otherwise the conventional
+	U.S. report.
+
 2004-12-23  Christian Stimming  <stimming at tuhh.de>
 
 	* src/import-export/hbci/druid-hbci-initial.c (on_aqhbci_button):
Index: acinclude.m4
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/acinclude.m4,v
retrieving revision 1.19.4.2
retrieving revision 1.19.4.3
diff -Lacinclude.m4 -Lacinclude.m4 -u -r1.19.4.2 -r1.19.4.3
--- acinclude.m4
+++ acinclude.m4
@@ -3374,7 +3374,7 @@
 # This must be Linux ELF.
 linux-gnu*)
   case $host_cpu in
-  alpha* | hppa* | i*86 | powerpc* | sparc* | ia64* )
+  alpha* | hppa* | i*86 | mips | mipsel | powerpc* | sparc* | ia64* | arm* | m68k )
     lt_cv_deplibs_check_method=pass_all ;;
   *)
     # glibc up to 2.1.1 does not perform some relocations on ARM
Index: GNOME2_STATUS
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/Attic/GNOME2_STATUS,v
retrieving revision 1.1.2.42
retrieving revision 1.1.2.43
diff -LGNOME2_STATUS -LGNOME2_STATUS -u -r1.1.2.42 -r1.1.2.43
--- GNOME2_STATUS
+++ GNOME2_STATUS
@@ -11,7 +11,7 @@
 functionality has been removed.
 
 ========================================
-   Last sync with HEAD on 2004-12-30
+   Last sync with HEAD on 2005-04-02
 ========================================
 
 ========================================
Index: dump-finance-quote
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/quotes/dump-finance-quote,v
retrieving revision 1.2.2.2
retrieving revision 1.2.2.3
diff -Lsrc/quotes/dump-finance-quote -Lsrc/quotes/dump-finance-quote -u -r1.2.2.2 -r1.2.2.3
--- src/quotes/dump-finance-quote
+++ src/quotes/dump-finance-quote
@@ -48,27 +48,51 @@
 sub report {
   my($itemname, $qh, $verbose) = @_;
   my ($symbol, $date, $currency, $last, $nav, $price, $timezone, $keyname);
-  my($success);
+  my($gccanuse);
+
+  # Sanity check returned results
+  if ((keys %$qh) < 1) {
+    printf("No results found for stock $itemname.\n");
+    return;
+  } else {
+    my ($stock, $attribute, %seen, $first);
+
+    foreach $keyname (sort keys %$qh) {
+      ($stock, $attribute) = split('\034', $keyname);
+      last if $stock eq $itemname;
+      $first = $stock if !defined $first;
+      $seen{$stock} = 1;
+    }
+
+    if ($stock ne $itemname) {
+      printf "\nNo results found for stock $itemname, but results were returned for\n";
+      printf "the stock(s) %s.  ", join(", ",  keys(%seen));
+      printf "Printing data for the first stock returned.\n\n";
+
+      # Print stats for the first stock returned.
+      $itemname = $first;
+    }
+  }
 
   # Parse the quote fields and put warnings where necessary.
-  $success = 1;
+  $gccanuse = 1;
   if (defined($$qh{$itemname, "symbol"})) {
     $symbol = $$qh{$itemname, "symbol"};
   } else {
     $symbol = "$itemname (deduced)";
-    $success = 0;
+    $gccanuse = 0;
   }
   if (defined($$qh{$itemname, "date"})) {
     $date = $$qh{$itemname, "date"};
   } else {
     $date = "** missing **";
-    $success = 0;
+    $gccanuse = 0;
   }
   if (defined($$qh{$itemname, "currency"})) {
     $currency = $$qh{$itemname, "currency"};
   } else {
     $currency = "** missing **";
-    $success = 0;
+    $gccanuse = 0;
   }
   if ((!defined($$qh{$itemname, "last"})) &&
       (!defined($$qh{$itemname, "nav" })) &&
@@ -76,7 +100,7 @@
     $$qh{$itemname, "last"} = "**missing**";
     $$qh{$itemname, "nav"} = "**missing**";
     $$qh{$itemname, "price"} = "**missing**";
-    $success = 0;
+    $gccanuse = 0;
   } else {
     $last = defined($$qh{$itemname, "last"})
       ? $$qh{$itemname, "last"} :  "";
@@ -88,20 +112,6 @@
   $timezone = defined($$qh{$itemname, "timezone"})
     ? $$qh{$itemname, "timezone"} :  "";
 
-  # Report failure
-  if ($success == 0) {
-    my ($stock, $key, %seen);
-    printf("\nThe query for $itemname failed!!");
-    foreach $keyname (sort keys %$qh) {
-      ($stock, $key) = split('\034', $keyname);
-      next if $stock eq $itemname;
-      next if $seen{$stock} == 1;
-      $seen{$stock} = 1;
-      printf "  Found data for stock(s) %s instead.\n", join(", ",  keys(%seen));
-    }
-    printf "\n";
-  }
-
   # Dump gnucash recognized fields
   printf "Finance::Quote fields Gnucash uses:\n";
   printf "    symbol: %-20s <=== required\n",	  $symbol;
@@ -112,6 +122,11 @@
   printf "     price: %-20s <=/        \n", 	  $price;
   printf "  timezone: %-20s <=== optional\n", 	  $timezone;
 
+  # Report failure
+  if ($gccanuse == 0) {
+    printf "\n** This stock quote cannot be used by gnucash!!\n\n";
+  }
+
   # Dump all fields if requested
   if ($verbose) {
     printf "\nAll fields returned by Finance::Quote for stock $itemname\n\n";
@@ -148,7 +163,6 @@
 while ($#ARGV >= 0) {
   my $stock = shift;
   my %quotes = $q->fetch($exchange, $stock);
-  $stock =~ tr/a-z/A-Z/;
   report($stock, \%quotes, $verbose);
   if ($#ARGV >= 0) {
     printf "=====\n\n";
Index: gnucash.spec.in
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/rpm/gnucash.spec.in,v
retrieving revision 1.46
retrieving revision 1.46.2.1
diff -Lrpm/gnucash.spec.in -Lrpm/gnucash.spec.in -u -r1.46 -r1.46.2.1
--- rpm/gnucash.spec.in
+++ rpm/gnucash.spec.in
@@ -1,3 +1,15 @@
+#
+# WATCH OUT: These spec file(s) might be heavily out of date and/or
+# absolutely NOT SUITED to your distribution! They are particularly
+# matched for the RedHat-8 distribution, but DO NOT USE THEM if you
+# don't have exactly that distribution! Your own distribution probably
+# has its own source RPM of gnucash, and this source RPM includes a
+# spec file that is much better suited to your distribution.
+#
+#  I repeat: DO NOT USE THIS SPEC file unless you either have Red Hat 8
+#  or you really know how you can modify it to suit your distribution.
+#
+#
 # Check whether GnuCash should build optional modules.
 # To modify parameters, edit the .spec file, 0 is off, 1 is on
 %define _with_postgres 0
@@ -19,10 +31,10 @@
 BuildRoot: 	%{_tmppath}/%{name}-%{version}-root
 Requires:  	gnome-libs >= 1.2.0, gdk-pixbuf >= 0.2.5, gnome-print >= 0.21
 Requires:	guile >= 1.3.4, gtkhtml >= 0.8, Guppi >= 0.35.3
-Requires:	g-wrap >= 1.3.4, umb-scheme >= 3.2, gal >= 0.8
+Requires:	g-wrap >= 1.3.4, gal >= 0.8
 BuildPrereq: 	g-wrap-devel >= 1.3.4, gtkhtml-devel >= 0.8
 BuildPrereq: 	Guppi-devel, gal-devel, libxml-devel
-BuildPrereq: 	libglade-devel, libghttp-devel, python-devel, libtermcap-devel
+BuildPrereq: 	libglade-devel, libghttp-devel, libtermcap-devel
 BuildPrereq: 	readline-devel
 Prereq: 	/sbin/ldconfig /sbin/install-info
 
@@ -62,8 +74,8 @@
 %package hbci
 Summary: Enables HBCI importing in GnuCash
 Group: Applications/Finance
-Requires: gnucash = %{version} openhbci >= 0.9.6
-BuildPrereq: openhbci
+Requires: gnucash = %{version} aqbanking >= 0.9.8
+BuildPrereq: aqbanking-devel
 
 %description hbci
 This package adds HBCI file import support to the base
Index: README
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/rpm/README,v
retrieving revision 1.3.30.1
retrieving revision 1.3.30.2
diff -Lrpm/README -Lrpm/README -u -r1.3.30.1 -r1.3.30.2
--- rpm/README
+++ rpm/README
@@ -1,12 +1,32 @@
 This directory contains spec files for building an RPM
 
+
+  WATCH OUT: These spec file(s) might be heavily out of date and/or
+  absolutely NOT SUITED to your distribution! They are particularly
+  matched for the RedHat-8 distribution, but DO NOT USE THEM if you
+  don't have exactly that distribution! Your own distribution probably
+  has its own source RPM of gnucash, and this source RPM includes a
+  spec file that is much better suited to your distribution.
+
+  I repeat: DO NOT USE THIS SPEC file unless you either have Red Hat 8
+  or you really know how you can modify it to suit your distribution.
+
+  For German-speaking users, there are German build instructions for
+  RPMs on http://linuxwiki.de/GnuCash/RpmInstallieren . 
+
+------------------------------
+Original file content:
+
+
 Short instructions:
 
 > I've never built an rpm; given a spec file, how do I do this?
 > I understand the theory, just not clear on what to type up.
 
-You'll need to be root.  (It is possible to avoid this requirement,
-but I haven't done the work to the RPM.)
+You'll need to be root in many distributions.  (It is possible to
+avoid this requirement, but I haven't done the work to the RPM.) 
+However, in some distributions (e.g. SuSE) these instructions will
+work even as a normal user.
 
 cd /usr/src/redhat/SOURCES
 tar -zxvf xacc-1.x.tar.gz
Index: gnc-ofx-import.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/ofx/gnc-ofx-import.c,v
retrieving revision 1.28.4.6
retrieving revision 1.28.4.7
diff -Lsrc/import-export/ofx/gnc-ofx-import.c -Lsrc/import-export/ofx/gnc-ofx-import.c -u -r1.28.4.6 -r1.28.4.7
--- src/import-export/ofx/gnc-ofx-import.c
+++ src/import-export/ofx/gnc-ofx-import.c
@@ -636,7 +636,7 @@
       DEBUG("Filename found: %s",selected_filename);
 
       /* Create the Generic transaction importer GUI. */
-      gnc_ofx_importer_gui = gnc_gen_trans_list_new(NULL, NULL, FALSE);
+      gnc_ofx_importer_gui = gnc_gen_trans_list_new(NULL, NULL, FALSE, 42);
 
       /* Initialize libofx */
 
Index: gnc-ui-util.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/app-utils/gnc-ui-util.c,v
retrieving revision 1.39.2.5
retrieving revision 1.39.2.6
diff -Lsrc/app-utils/gnc-ui-util.c -Lsrc/app-utils/gnc-ui-util.c -u -r1.39.2.5 -r1.39.2.6
--- src/app-utils/gnc-ui-util.c
+++ src/app-utils/gnc-ui-util.c
@@ -449,8 +449,21 @@
   if (get_form == SCM_UNDEFINED)
   {
     GNCModule module;
+    /* load the tax info */
+#ifdef LOCALE_SPECIFIC_TAX
+    const char *thislocale = setlocale(LC_ALL, NULL);
+    /* This is a very simple hack that loads the (new, special) German
+       tax definition file in a German locale, or (default) loads the
+       previous US tax file. */
+    gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
+#else
+    gboolean is_de_DE = FALSE;
+#endif /* LOCALE_SPECIFIC_TAX */
+    const char *tax_module = is_de_DE ? 
+      "gnucash/tax/de_DE" : 
+      "gnucash/tax/us";
 
-    module = gnc_module_load ("gnucash/tax/us", 0);
+    module = gnc_module_load ((char *)tax_module, 0);
 
     g_return_val_if_fail (module, NULL);
 
Index: gnc-backend-file.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/file/gnc-backend-file.c,v
retrieving revision 1.23.4.6
retrieving revision 1.23.4.7
diff -Lsrc/backend/file/gnc-backend-file.c -Lsrc/backend/file/gnc-backend-file.c -u -r1.23.4.6 -r1.23.4.7
--- src/backend/file/gnc-backend-file.c
+++ src/backend/file/gnc-backend-file.c
@@ -672,6 +672,7 @@
                 /* Make sure this file actually has a date before unlinking */
                 if (res && res != name+pathlen+1 &&
                     /* We consumed some but not all of the filename */
+		    !strcmp(res, ".xac") &&
                     file_time > 0 &&
                     /* we actually have a reasonable time and it is old enough */
                     days > file_retention_days) 
--- /dev/null
+++ src/report/locale-specific/us/de_DE.scm
@@ -0,0 +1,3 @@
+; This is unused and therefore no longer installed and/or loaded
+(define-module (gnucash report locale-specific de_DE))
+(use-modules (gnucash report taxtxf-de_DE))  
Index: gncmod-locale-reports-us.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/locale-specific/us/gncmod-locale-reports-us.c,v
retrieving revision 1.7.4.1
retrieving revision 1.7.4.2
diff -Lsrc/report/locale-specific/us/gncmod-locale-reports-us.c -Lsrc/report/locale-specific/us/gncmod-locale-reports-us.c -u -r1.7.4.1 -r1.7.4.2
--- src/report/locale-specific/us/gncmod-locale-reports-us.c
+++ src/report/locale-specific/us/gncmod-locale-reports-us.c
@@ -10,6 +10,8 @@
 #include <libguile.h>
 #include "guile-mappings.h"
 #include <glib.h>
+#include <locale.h>
+#include <string.h>
 
 #include "gnc-module.h"
 #include "gnc-module-api.h"
@@ -31,6 +33,10 @@
 
 char *
 libgncmod_locale_reports_us_LTX_gnc_module_path(void) {
+  /* const char *thislocale = setlocale(LC_ALL, NULL);
+  if (strncmp(thislocale, "de_DE", 5) == 0)
+    return g_strdup("gnucash/report/locale-specific/de_DE");
+    else */
   return g_strdup("gnucash/report/locale-specific/us");
 }
 
@@ -41,8 +47,29 @@
 
 int
 libgncmod_locale_reports_us_LTX_gnc_module_init(int refcount) {
-  /* load us tax info */
-  if(!gnc_module_load("gnucash/tax/us", 0)) {
+  /* load the tax info */
+#ifdef LOCALE_SPECIFIC_TAX
+  const char *thislocale = setlocale(LC_ALL, NULL);
+  /* This is a very simple hack that loads the (new, special) German
+     tax definition file in a German locale, or (default) loads the
+     previous US tax file. */
+  gboolean is_de_DE = (strncmp(thislocale, "de_DE", 5) == 0);
+#else
+  gboolean is_de_DE = FALSE;
+#endif /* LOCALE_SPECIFIC_TAX */
+  const char *tax_module = is_de_DE ? 
+    "gnucash/tax/de_DE" : 
+    "gnucash/tax/us";
+  const char *report_taxtxf = is_de_DE ? 
+    "(use-modules (gnucash report taxtxf-de_DE))" :
+    "(use-modules (gnucash report taxtxf))";
+  const char *report_locale = is_de_DE ?
+    "(use-modules (gnucash report locale-specific de_DE))" :
+    "(use-modules (gnucash report locale-specific us))";
+
+  /* The gchar* cast is only because the function declaration expects
+     a non-const string -- probably an api error. */
+  if(!gnc_module_load((gchar*)tax_module, 0)) {
     return FALSE;
   }
 
@@ -52,13 +79,14 @@
   }
 
   /* load the report generation scheme code */
-  if(scm_c_eval_string("(use-modules (gnucash report taxtxf))") 
+  if(scm_c_eval_string(report_taxtxf) 
      == SCM_BOOL_F) {
-    printf("failed to load (gnucash report taxtxf)\n");
+    printf("failed to load %s\n", report_taxtxf);
     return FALSE;
   }
 
-  if(scm_c_eval_string("(use-modules (gnucash report locale-specific us))") 
+  /* Load the module scheme code */
+  if(gh_eval_str(report_locale) 
      == SCM_BOOL_F) {
     return FALSE;
   }
Index: us.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/locale-specific/us/us.scm,v
retrieving revision 1.3
retrieving revision 1.3.6.1
diff -Lsrc/report/locale-specific/us/us.scm -Lsrc/report/locale-specific/us/us.scm -u -r1.3 -r1.3.6.1
--- src/report/locale-specific/us/us.scm
+++ src/report/locale-specific/us/us.scm
@@ -1,2 +1,3 @@
+; This is unused and therefore no longer installed and/or loaded
 (define-module (gnucash report locale-specific us))
 (use-modules (gnucash report taxtxf))  
--- /dev/null
+++ src/report/locale-specific/us/taxtxf-de_DE.scm
@@ -0,0 +1,885 @@
+;; -*-scheme-*-
+;;
+;; This file was copied from the file txf.scm by  Richard -Gilligan- Uschold
+;;
+;; Originally, these were meant to print Tax related accounts and
+;; exports TXF files for import to TaxCut, TurboTax, etc.  for the US
+;; tax TXF format. I modified this heavily so that it might become
+;; useful for the German Umsatzsteuer-Voranmeldung.
+;; 
+;; The report in this file extracts the amounts that belong to the
+;; Kennzahlen (from txf-de_DE.scm) as assigned to the different
+;; accounts, and will write it to some XML file as required by
+;; e.g. the Winston software
+;; http://www.felfri.de/winston/schnittstellen.htm
+;;
+;; This file might still contain a lot of US-TXF related stuff. This
+;; can surely be thrown out once someone was able to actually use this
+;; report for his/her taxes.
+;;
+;;
+;; Richard Gilligan Uschold's original comment continued here as follows:
+;;
+;; For this to work, the user has to segregate taxable and not taxable
+;; income to different accounts, as well as deductible and non
+;; deductible expenses.
+;;
+;; The user selects the accounts(s) to be printed, if none, all are checked.
+;; Automatically prints up to 15 sub-account levels below selected
+;; account.  Accounts below that are not printed. If you really need
+;; more levels, change the MAX_LEVELS constant
+;;
+;; Optionally, does NOT print accounts with $0.00 values.  Prints data
+;; between the From and To dates.  Optional alternate periods:
+;; "Last Year", "1st Est Tax Quarter", ... "4th Est Tax Quarter"
+;; "Last Yr Est Tax Qtr", ... "Last Yr Est Tax Qtr"
+;; Estimated Tax Quarters: Dec 31, Mar 31, Jun 30, Aug 31)
+;; Optionally prints brief or full account names
+;;
+;; NOTE: setting of specific dates is squirly! and seems to be
+;; current-date dependant!  Actually, time of day dependant!  Just
+;; after midnight gives diffenent dates than just before!  Referencing
+;; all times to noon seems to fix this.  Subtracting 1 year sometimes
+;; subtracts 2!  see "(to-value"
+
+;; depends must be outside module scope -- and should eventually go away.
+
+(define-module (gnucash report taxtxf-de_DE))
+(use-modules (gnucash main)) ;; FIXME: delete after we finish modularizing.
+(use-modules (srfi srfi-1))
+(use-modules (ice-9 slib))
+(require 'printf)
+
+(use-modules (gnucash gnc-module))
+(gnc:module-load "gnucash/tax/de_DE" 0)
+(gnc:module-load "gnucash/report/report-system" 0)
+
+
+(define reportname (N_ "Tax Report / TXF Export"))
+
+(define (make-level-collector num-levels)
+  (let ((level-collector (make-vector num-levels)))
+    (do ((i 0 (+ i 1)))
+        ((= i num-levels) i)
+      (vector-set! level-collector i (gnc:make-commodity-collector)))
+    level-collector))
+
+(define MAX-LEVELS 16)			; Maximum Account Levels
+
+(define levelx-collector (make-level-collector MAX-LEVELS))
+
+(define today (gnc:timepair-canonical-day-time
+               (cons (current-time) 0)))
+
+(define bdtm
+  (let ((result (gnc:timepair->date today)))
+    (set-tm:mday result 16)             ; 16
+    (set-tm:mon result 3)               ; Apr
+    (set-tm:isdst result -1)
+    result))
+
+(define tax-day (cons (car (mktime bdtm)) 0))
+
+(define after-tax-day (gnc:timepair-later tax-day today))
+
+(define (make-split-list account split-filter-pred)
+  (reverse (filter split-filter-pred
+                   (gnc:account-get-split-list account))))
+
+;; returns a predicate that returns true only if a split is
+;; between early-date and late-date
+(define (split-report-make-date-filter-predicate begin-date-tp
+                                                 end-date-tp)
+  (lambda (split) 
+    (let ((tp
+           (gnc:transaction-get-date-posted
+            (gnc:split-get-parent split))))
+      (and (gnc:timepair-ge-date tp begin-date-tp)
+           (gnc:timepair-le-date tp end-date-tp)))))
+
+;; This is nearly identical to, and could be shared with
+;; display-report-list-item in report.scm. This adds warn-msg parameter
+(define (gnc:display-report-list-item item port warn-msg)
+  (cond
+   ((string? item) (display item port))
+   ((null? item) #t)
+   ((list? item) (map (lambda (item)
+                        (gnc:display-report-list-item item port warn-msg))
+                      item))
+   (else (gnc:warn warn-msg item " is the wrong type."))))
+
+(define (lx-collector level action arg1 arg2)
+  ((vector-ref levelx-collector (- level 1)) action arg1 arg2))
+
+;; IRS asked congress to make the tax quarters the same as real quarters
+;;   This is the year it is effective.  THIS IS A Y10K BUG!
+(define tax-qtr-real-qtr-year 10000)
+
+(define (tax-options-generator)
+  (define options (gnc:new-options))
+  (define (gnc:register-tax-option new-option)
+    (gnc:register-option options new-option))
+
+  ;; date at which to report 
+  (gnc:options-add-date-interval!
+   options gnc:pagename-general 
+   (N_ "From") (N_ "To") "a")
+
+  (gnc:register-tax-option
+   (gnc:make-multichoice-option
+    gnc:pagename-general (N_ "Alternate Period")
+    "c" (N_ "Override or modify From: & To:")
+    (if after-tax-day 'from-to 'last-year)
+    (list (list->vector
+           (list 'from-to (N_ "Use From - To") (N_ "Use From - To period")))
+          (list->vector
+           (list '1st-est (N_ "1st Est Tax Quarter") (N_ "Jan 1 - Mar 31")))
+          (list->vector
+           (list '2nd-est (N_ "2nd Est Tax Quarter") (N_ "Apr 1 - May 31")))
+          (list->vector
+           (list '3rd-est (N_ "3rd Est Tax Quarter") (N_ "Jun 1 - Aug 31")))
+          (list->vector
+           (list '4th-est (N_ "4th Est Tax Quarter") (N_ "Sep 1 - Dec 31")))
+          (list->vector
+           (list 'last-year (N_ "Last Year") (N_ "Last Year")))
+          (list->vector
+           (list '1st-last (N_ "Last Yr 1st Est Tax Qtr")
+                 (N_ "Jan 1 - Mar 31, Last year")))
+          (list->vector
+           (list '2nd-last (N_ "Last Yr 2nd Est Tax Qtr")
+                 (N_ "Apr 1 - May 31, Last year")))
+          (list->vector
+           (list '3rd-last (N_ "Last Yr 3rd Est Tax Qtr")
+                 (N_ "Jun 1 - Aug 31, Last year")))
+          (list->vector
+           (list '4th-last (N_ "Last Yr 4th Est Tax Qtr")
+                 (N_ "Sep 1 - Dec 31, Last year"))))))
+
+  (gnc:register-tax-option
+   (gnc:make-account-list-option
+    gnc:pagename-accounts (N_ "Select Accounts (none = all)")
+    "d" (N_ "Select accounts")
+    (lambda () '())
+    #f #t))
+  
+  (gnc:register-tax-option
+   (gnc:make-simple-boolean-option
+    gnc:pagename-display (N_ "Suppress $0.00 values")
+    "f" (N_ "$0.00 valued Accounts won't be printed.") #t))
+
+  (gnc:register-tax-option
+   (gnc:make-simple-boolean-option
+    gnc:pagename-display (N_ "Print Full account names")
+    "g" (N_ "Print all Parent account names") #f))
+
+  (gnc:options-set-default-section options gnc:pagename-general)
+
+  options)
+
+;; Render txf information
+(define crlf (string #\return #\newline)) ; TurboTax seems to want these
+
+(define txf-last-payer "")		; if same as current, inc txf-l-count
+					; this only works if different
+					; codes from the same payer are
+					; grouped in the accounts list
+(define txf-l-count 0)		; count repeated N codes
+
+;; stores assigned txf codes so we can check for duplicates
+(define txf-dups-alist '())
+
+(define (txf-payer? payer)
+  (member payer (list 'current 'parent)))
+
+(define (gnc:account-get-txf account)
+  (and (gnc:account-get-tax-related account)
+       (not (equal? (gnc:account-get-txf-code account) 'N000))))
+
+(define (gnc:account-get-txf-code account)
+  (let ((code (gnc:account-get-tax-US-code account)))
+    (string->symbol (if code code "N000"))))
+
+(define (gnc:get-txf-format code income?)
+  (gnc:txf-get-format (if income?
+                          txf-income-categories
+                          txf-expense-categories)
+                      code))
+
+(define (gnc:account-get-txf-payer-source account)
+  (let ((pns (gnc:account-get-tax-US-payer-name-source account)))
+    (string->symbol (if pns pns "keine"))))
+
+;; check for duplicate txf codes
+(define (txf-check-dups account) 
+  (let* ((code (gnc:account-get-txf-code account))
+         (item (assoc-ref txf-dups-alist code))
+         (payer (gnc:account-get-txf-payer-source account)))
+    (if (not (txf-payer? payer))
+        (set! txf-dups-alist (assoc-set! txf-dups-alist code
+                                         (if item
+                                             (cons account item)
+                                             (list account)))))))
+
+;; Print error message for duplicate txf codes and accounts
+(define (txf-print-dups doc)
+  (let ((dups
+         (apply append
+                (map (lambda (x)
+                       (let ((cnt (length (cdr x))))
+                         (if (> cnt 1)
+                             (let* ((acc (cadr x))
+                                    (txf (gnc:account-get-txf acc)))
+                               (cons (string-append 
+                                      "Code \"" 
+                                      (symbol->string
+                                       (gnc:account-get-txf-code acc))
+                                      "\" has duplicates in "
+                                      (number->string cnt) " accounts:")
+                                     (map gnc:account-get-full-name 
+                                          (cdr x))))
+                             '())))
+                     txf-dups-alist)))
+        (text (gnc:make-html-text)))
+    (if (not (null? dups))
+        (begin
+          (gnc:html-document-add-object! doc text)
+          (gnc:html-text-append!
+           text
+           (gnc:html-markup-p
+            (gnc:html-markup
+             "blue"
+             (_ "WARNING: There are duplicate TXF codes assigned\
+ to some accounts. Only TXF codes with payer sources may be repeated."))))
+          (map (lambda (s)
+                 (gnc:html-text-append!
+                  text
+                  (gnc:html-markup-p
+                   (gnc:html-markup "blue" s))))
+               dups)))))
+
+;; some codes require special handling
+(define (txf-special-split? code)
+  (member code (list 'N521)))            ; only one for now
+
+(define (fill-clamp-sp str len)
+  (string-append (substring (string-append str (make-string len #\space))
+                            0 (- len 1)) " "))
+
+(define (fill-clamp str len)
+  (string-append (substring (string-append str (make-string len #\space))
+                            0 len)))
+
+(define (make-header-row table max-level)
+  (gnc:html-table-prepend-row!
+   table
+   (append (list (gnc:make-html-table-header-cell/markup
+                  "account-header" (_ "Account Name")))
+           (make-sub-headers max-level)
+           (list (gnc:make-html-table-header-cell/markup
+                  "number-header" (_ "Total"))))))
+
+(define (make-sub-headers max-level)
+  (if (<= max-level 1)
+      '()
+      (cons (gnc:make-html-table-header-cell/markup
+             "number-header"
+             (_ "Sub-")
+             (number->string (- max-level 1)))
+            (make-sub-headers (- max-level 1)))))
+
+(define (render-txf-account account account-value d? date x? x-date)
+  (let* ((print-info (gnc:account-print-info account #t))
+         (txf? (gnc:account-get-txf account)))
+    (if (and txf?
+             (not (gnc:numeric-zero-p account-value)))
+        (let* ((type (gw:enum-<gnc:AccountType>-val->sym
+                      (gnc:account-get-type account) #f))
+               (code (gnc:account-get-txf-code account))
+               (date-str (if date
+                             (strftime "%d.%m.%Y" (localtime (car date)))
+                             #f))
+               (x-date-str (if x-date
+                               (strftime "%d.%m.%Y" (localtime (car x-date)))
+                               #f))
+               ;; Only formats 1,3 implemented now! Others are treated as 1.
+               (format (gnc:get-txf-format code (eq? type 'income)))
+	       (value (string-append 
+		       (if (eq? type 'income) ;; negate expenses. FIXME: Necessary?
+			   ""
+			   "-")
+		       (number->string 
+			(gnc:numeric-num 
+			 (gnc:numeric-convert account-value (cond 
+							     ((eq? format 2) 1)
+							     (else 100))
+					      3))))) ;; 3 is the GNC_HOW_TRUNC truncation rounding
+	       (payer-src (gnc:account-get-txf-payer-source account))
+               (account-name (let* ((named-acct
+				    (if (eq? payer-src 'parent)
+					(gnc:group-get-parent
+					 (gnc:account-get-parent account))
+					account))
+				    (name (gnc:account-get-name named-acct)))
+			       (if name
+				   name
+				   (begin
+				     (display
+				      (string-append
+				       "Failed to get name for account: "
+				       (gnc:account-get-guid named-acct)
+				       (if (not (eq? account named-acct))
+					   (string-append
+					    " which is the parent of "
+					    (gnc:account-get-guid account)))
+				       "\n"))
+				     "<NONE> -- See the Terminal Output"))))
+               (action (if (eq? type 'income)
+                           (case code
+                             ((N286 N488) "ReinvD")
+                             (else "Ertraege"))
+                           "Aufwendungen"))
+               (category-key (if (eq? type 'income)
+                                 (gnc:txf-get-category-key 
+                                  txf-income-categories code)
+                                 (gnc:txf-get-category-key
+                                  txf-expense-categories code)))
+               (value-name (if (equal? "ReinvD" action)
+                               (string-append 
+                                (substring value 1 (string-length value))
+                                " " account-name)
+                               account-name))
+               (l-value (if (= format 3)
+                            (begin
+                              (set! txf-l-count 
+                                    (if (equal? txf-last-payer account-name)
+                                        txf-l-count
+                                        (+ 1 txf-l-count)))
+                              (set! txf-last-payer account-name)
+                              (number->string txf-l-count))
+                            "1")))
+	  ;(display "render-txf-account \n")
+	  ;(display-backtrace (make-stack #t) (current-output-port))
+
+	  ;; FIXME: Here the actual rendering of one account entry is
+	  ;; done. Use the German format here.
+          (list "  <Kennzahl Nr=\""
+		category-key
+		"\">"
+                value
+		"</Kennzahl>" crlf))
+;                (case format
+;                  ((3) (list "P" account-name crlf))
+;                  (else (if (and x? (txf-special-split? code))
+;                            (list "P" crlf)
+;                            '())))
+;                (if x?
+;                    (list "X" x-date-str " " (fill-clamp-sp account-name 31)
+;                          (fill-clamp-sp action 7) 
+;                          (fill-clamp-sp value-name 82)
+;                          (fill-clamp category-key 15) crlf)
+;                    '())
+;                "^" crlf))
+	"")))
+
+;; Render any level
+(define (render-level-x-account table level max-level account lx-value
+                                suppress-0 full-names txf-date)
+  (let* ((account-name (if txf-date	; special split
+                           (strftime "%d.%m.%Y" (localtime (car txf-date)))
+                           (if (or full-names (equal? level 1))
+                               (gnc:account-get-full-name account)
+                               (gnc:account-get-name account))))
+         (blue? (gnc:account-get-txf account))
+         (print-info (gnc:account-print-info account #f))
+         (value (gnc:amount->string lx-value print-info))
+         (value-formatted (if (= 1 level)
+                              (gnc:html-markup-b value)
+                              value))
+         (value-formatted (gnc:make-html-text
+                           (if blue?
+                               (gnc:html-markup "blue" value-formatted)
+                               value-formatted)))
+         (account-name (if blue?
+                           (gnc:html-markup "blue" account-name)
+                           ;; Note: gnc:html-markup adds an extra space
+                           ;; before the " <FONT" tag, so we compensate.
+                           (string-append " " account-name)))
+         (blank-cells (make-list (- max-level level)
+                                 (gnc:make-html-table-cell #f)))
+         (end-cells (make-list (- level 1) (gnc:make-html-table-cell #f))))
+
+    (if (and blue? (not txf-date))	; check for duplicate txf codes
+        (txf-check-dups account))
+
+    (if (or (not suppress-0) (= level 1)
+            (not (gnc:numeric-zero-p lx-value)))
+        (begin
+          (gnc:html-table-prepend-row!
+           table
+           (append
+            (list (gnc:make-html-table-cell
+                   (apply gnc:make-html-text
+                          (append (make-list (* 3 (- level 1)) "&nbsp; ")
+                                  (list account-name)))))
+            blank-cells
+            (list (gnc:make-html-table-cell/markup "number-cell"
+                                                   value-formatted))
+            end-cells))
+          (if (= level 1) (make-header-row table max-level))))))
+
+;; Recursivly validate children if parent is not a tax account.
+;; Don't check children if parent is valid.
+;; Returns the Parent if a child or grandchild is valid.
+(define (validate accounts)
+  (filter (lambda (a)
+            (if (gnc:account-get-tax-related a)
+                #t
+                ;; check children
+                (if (null? (validate
+                            (gnc:group-get-subaccounts
+                             (gnc:account-get-children a))))
+                    #f
+                    #t)))
+          accounts))
+
+(define (generate-tax-or-txf report-name
+                             report-description
+                             report-obj
+                             tax-mode?
+                             file-name)
+
+  (define (get-option pagename optname)
+    (gnc:option-value
+     (gnc:lookup-option 
+      (gnc:report-options report-obj) pagename optname)))
+
+  ;; the number of account generations: children, grandchildren etc.
+  (define (num-generations account gen)
+    (let ((children (gnc:account-get-children account)))
+      (if (eq? (gnc:group-get-num-accounts children) 0)
+          (if (and (gnc:account-get-tax-related account)
+                   (txf-special-split? (gnc:account-get-txf-code account)))
+              (+ gen 1)		; Est Fed Tax has a extra generation
+              gen)	       		; no kids, return input
+          (apply max (gnc:group-map-accounts
+                      (lambda (x) (num-generations x (+ 1 gen)))
+                      children)))))
+
+  (gnc:report-starting reportname)
+  (let* ((from-value (gnc:date-option-absolute-time 
+                      (get-option gnc:pagename-general "From")))
+         (to-value (gnc:timepair-end-day-time
+                    (gnc:date-option-absolute-time 		       
+                     (get-option gnc:pagename-general "To"))))
+         (alt-period (get-option gnc:pagename-general "Alternate Period"))
+         (suppress-0 (get-option gnc:pagename-display 
+                                 "Suppress $0.00 values"))
+         (full-names (get-option gnc:pagename-display
+                                 "Print Full account names"))
+         (user-sel-accnts (get-option gnc:pagename-accounts
+                                      "Select Accounts (none = all)"))
+         (valid-user-sel-accnts (validate user-sel-accnts))
+         ;; If no selected accounts, check all.
+         (selected-accounts (if (not (null? user-sel-accnts))
+                                valid-user-sel-accnts
+                                (validate (reverse 
+                                           (gnc:group-get-account-list
+                                            (gnc:get-current-group))))))
+         (generations (if (pair? selected-accounts)
+                          (apply max (map (lambda (x) (num-generations x 1))
+                                          selected-accounts))
+                          0))
+         (max-level (min MAX-LEVELS (max 1 generations)))
+	 (work-to-do 0)
+	 (work-done 0)
+
+         ;; Alternate dates are relative to from-date
+         (from-date (gnc:timepair->date from-value))
+         (from-value (gnc:timepair-start-day-time
+                      (let ((bdtm from-date))
+                        (if (member alt-period 
+                                    '(last-year 1st-last 2nd-last
+                                                3rd-last 4th-last))
+                            (set-tm:year bdtm (- (tm:year bdtm) 1)))
+                        (set-tm:mday bdtm 1)
+                        (if (< (gnc:date-get-year bdtm) 
+                               tax-qtr-real-qtr-year)
+                            (case alt-period
+                              ((1st-est 1st-last last-year) ; Jan 1
+                               (set-tm:mon bdtm 0))
+                              ((2nd-est 2nd-last) ; Apr 1
+                               (set-tm:mon bdtm 3))
+                              ((3rd-est 3rd-last) ; Jun 1
+                               (set-tm:mon bdtm 5))
+                              ((4th-est 4th-last) ; Sep 1
+                               (set-tm:mon bdtm 8)))
+                            ;; Tax quaters equal Real quarters
+                            (case alt-period
+                              ((1st-est 1st-last last-year) ; Jan 1
+                               (set-tm:mon bdtm 0))
+                              ((2nd-est 2nd-last) ; Apr 1
+                               (set-tm:mon bdtm 3))
+                              ((3rd-est 3rd-last) ; Jul 1
+                               (set-tm:mon bdtm 6))
+                              ((4th-est 4th-last) ; Oct 1
+                               (set-tm:mon bdtm 9))))
+                        (set-tm:isdst bdtm -1)
+                        (cons (car (mktime bdtm)) 0))))
+
+         (to-value (gnc:timepair-end-day-time
+                    (let ((bdtm from-date))
+                      (if (member alt-period 
+                                  '(last-year 1st-last 2nd-last
+                                              3rd-last 4th-last))
+                          (set-tm:year bdtm (- (tm:year bdtm) 1)))
+                      ;; Bug! Above subtracts two years, should only be one!
+                      ;; The exact same code, in from-value, further above,
+                      ;;   only subtraces one!  Go figure!
+                      ;; So, we add one back below!
+                      (if (member alt-period 
+                                  '(last-year 1st-last 2nd-last
+                                              3rd-last 4th-last))
+                          (set-tm:year bdtm (+ (tm:year bdtm) 1)))
+                      (set-tm:mday bdtm 31)
+                      (if (< (gnc:date-get-year bdtm) tax-qtr-real-qtr-year)
+                          (case alt-period
+                            ((1st-est 1st-last) ; Mar 31
+                             (set-tm:mon bdtm 2))
+                            ((2nd-est 2nd-last) ; May 31
+                             (set-tm:mon bdtm 4))
+                            ((3rd-est 3rd-last) ; Aug 31
+                             (set-tm:mon bdtm 7))
+                            ((4th-est 4th-last last-year) ; Dec 31
+                             (set-tm:mon bdtm 11))
+                            (else (set! bdtm (gnc:timepair->date to-value))))
+                          ;; Tax quaters equal Real quarters
+                          (case alt-period
+                            ((1st-est 1st-last) ; Mar 31
+                             (set-tm:mon bdtm 2))
+                            ((2nd-est 2nd-last) ; Jun 30
+                             (set-tm:mday bdtm 30)
+                             (set-tm:mon bdtm 5))
+                            ((3rd-est 3rd-last) ; Sep 30
+                             (set-tm:mday bdtm 30)
+                             (set-tm:mon bdtm 8))
+                            ((4th-est 4th-last last-year) ; Dec 31
+                             (set-tm:mon bdtm 11))
+                            (else 
+                             (set! bdtm (gnc:timepair->date to-value)))))
+                      (set-tm:isdst bdtm -1)
+                      (cons (car (mktime bdtm)) 0))))
+
+         (txf-feedback-str-lst '())
+         (doc (gnc:make-html-document))
+         (table (gnc:make-html-table)))
+
+    ;; for quarterly estimated tax payments, we need a different period
+    ;; return the sometimes changed (from-est to-est full-year?) dates
+    (define (txf-special-splits-period account from-value to-value)
+      (if (and (gnc:account-get-tax-related account)
+               (txf-special-split? (gnc:account-get-txf-code account)))
+          (let* 
+              ((full-year?
+                (let ((bdto (localtime (car to-value)))
+                      (bdfrom (localtime (car from-value))))
+                  (and (equal? (tm:year bdto) (tm:year bdfrom))
+                       (equal? (tm:mon bdfrom) 0)
+                       (equal? (tm:mday bdfrom) 1)
+                       (equal? (tm:mon bdto) 11)
+                       (equal? (tm:mday bdto) 31))))
+               ;; Adjust dates so we get the final Estimated Tax
+               ;; paymnent from the right year
+               (from-est (if full-year?
+                             (let ((bdtm (gnc:timepair->date
+                                          (gnc:timepair-canonical-day-time
+                                           from-value))))
+                               (set-tm:mday bdtm 1) ; 01
+                               (set-tm:mon bdtm 2) ; Mar
+                               (set-tm:isdst bdtm -1)
+                               (cons (car (mktime bdtm)) 0))
+                             from-value))
+               (to-est (if full-year?
+                           (let* ((bdtm (gnc:timepair->date
+                                         (gnc:timepair-canonical-day-time
+                                          from-value))))
+                             (set-tm:mday bdtm 28) ; 28
+                             (set-tm:mon bdtm 1) ; Feb
+                             (set-tm:year bdtm (+ (tm:year bdtm) 1))
+                             (set-tm:isdst bdtm -1)
+                             (cons (car (mktime bdtm)) 0))
+                           to-value)))
+            (list from-est to-est full-year?))
+          #f))
+    
+    ;; for quarterly estimated tax payments, we need to go one level down
+    ;; and get data from splits
+    (define (handle-txf-special-splits level account from-est to-est 
+                                       full-year? to-value)
+      (let*
+          ((split-filter-pred (split-report-make-date-filter-predicate
+                               from-est to-est))
+           (split-list (make-split-list account split-filter-pred))
+           (lev  (if (>= max-level (+ 1 level))
+                     (+ 1 level)
+                     level)))
+        (map (lambda (spl) 
+               (let* ((date (gnc:transaction-get-date-posted 
+                             (gnc:split-get-parent spl)))
+                      (amount (gnc:split-get-amount spl))
+                      ;; TurboTax 1999 and 2000 ignore dates after Dec 31
+                      (fudge-date (if (and full-year? 
+                                           (gnc:timepair-lt to-value date))
+                                      to-value
+                                      date)))
+                 (if tax-mode?
+                     (render-level-x-account table lev max-level account
+                                             amount suppress-0 #f date)
+                     (render-txf-account account amount
+                                         #t fudge-date  #t date))))
+             split-list)))
+    
+    (define (count-accounts level accounts)
+      (if (< level max-level)
+	  (let ((sum 0))
+	    (for-each (lambda (x)
+		   (if (gnc:account-is-inc-exp? x)
+		       (set! sum (+ sum (+ 1 (count-accounts (+ 1 level)
+							     (gnc:account-get-immediate-subaccounts x)))))
+		       0))
+		 accounts)
+	    sum)
+	  (length accounts)))
+
+    (define (handle-level-x-account level account)
+      (let ((type (gw:enum-<gnc:AccountType>-val->sym
+                   (gnc:account-get-type account) #f)))
+	(set! work-done (+ 1 work-done))
+	(gnc:report-percent-done (* 100 (if (> work-to-do 0)
+					    (/ work-done work-to-do)
+					    1)))
+        (if (gnc:account-is-inc-exp? account)
+            (let* ((children (gnc:account-get-children account))
+                   (to-special #f)	; clear special-splits-period
+                   (from-special #f)
+                   (childrens-output 
+                    (if (not children)
+                        (let* ((splits-period (txf-special-splits-period
+                                               account from-value to-value)))
+                          (if splits-period
+                              (let* ((full-year? (caddr splits-period)))
+                                (set! from-special (car splits-period))
+                                (set! to-special (cadr splits-period))
+                                (handle-txf-special-splits level account
+                                                           from-special
+                                                           to-special
+                                                           full-year?
+                                                           to-value))
+                              
+                              '()))
+
+                        (map (lambda (x)
+                               (if (>= max-level (+ 1 level))
+                                   (handle-level-x-account (+ 1 level) x)
+                                   '()))
+                             (reverse 
+                              (gnc:group-get-account-list children)))))
+
+                   (account-balance 
+                    (if (gnc:account-get-tax-related account)
+                        (if to-special
+                            (gnc:account-get-balance-interval
+                             account from-special to-special #f)
+                            (gnc:account-get-balance-interval
+                             account from-value to-value #f))
+                        (gnc:numeric-zero)))) ; don't add non tax related
+
+              (set! account-balance
+                    (gnc:numeric-add-fixed
+                     (if (> max-level level)
+                         (cadr
+                          (lx-collector (+ 1 level)
+                                        'getpair
+                                        (gnc:account-get-commodity account)
+                                        #f))
+                         (gnc:numeric-zero))
+                       ;; make positive
+                       (if (eq? type 'income)
+                           (gnc:numeric-neg account-balance)
+                           account-balance)))
+
+              (lx-collector level
+                            'add
+                            (gnc:account-get-commodity account)
+                            account-balance)
+
+              (let ((level-x-output
+                     (if tax-mode?
+                         (render-level-x-account table level
+                                                 max-level account
+                                                 account-balance
+                                                 suppress-0 full-names #f)
+                         (list 
+                          ;(if (not to-special)
+                          ;    (render-txf-account account account-balance
+                          ;                        #f #f #t from-value)
+                          ;    '())
+                          (render-txf-account account account-balance
+                                              #f #f #f #f)))))
+                (if (equal? 1 level)
+                    (lx-collector 1 'reset #f #f))
+
+                (if (> max-level level)
+                    (lx-collector (+ 1 level) 'reset #f #f))
+
+                (if (null? level-x-output)
+                    '()
+                    (if (null? childrens-output)
+                        level-x-output
+                        (if tax-mode?
+                            (list level-x-output
+                                  childrens-output)
+                            (if (not children) ; swap for txf special splt
+                                (list childrens-output level-x-output)
+                                (list level-x-output childrens-output)))))))
+            ;; Ignore
+            '())))
+
+    (let ((from-date  (strftime "%d.%m.%Y" (localtime (car from-value))))
+          (to-date    (strftime "%d.%m.%Y" (localtime (car to-value))))
+	  (to-year    (strftime "%Y" (localtime (car to-value))))
+          (today-date (strftime "%d.%m.%Y" 
+                                (localtime 
+                                 (car (gnc:timepair-canonical-day-time
+                                       (cons (current-time) 0))))))
+	  (tax-nr (or 
+		   (gnc:kvp-frame-get-slot-path
+		    (gnc:book-get-slots (gnc:get-current-book))
+		    (append gnc:*kvp-option-path*
+			    (list gnc:*tax-label* gnc:*tax-nr-label*)))
+		   ""))
+	  )
+
+      ;; Now, the main body
+      ;; Reset all the balance collectors
+      (do ((i 1 (+ i 1)))
+          ((> i MAX-LEVELS) i)
+        (lx-collector i 'reset #f #f))
+
+      (set! txf-last-payer "")
+      (set! txf-l-count 0)
+      (set! work-to-do (count-accounts 1 selected-accounts))
+
+      (if (not tax-mode?)		; Do Txf mode
+          (begin
+            (if file-name		; cancel TXF if no file selected
+                (let* ((port (open-output-file file-name))    
+                       (output
+                        (map (lambda (x) (handle-level-x-account 1 x))
+                             selected-accounts))
+		       ;; FIXME: Print the leading and trailing bits here
+                       (output-txf (list
+                                    "<WinstonAusgang>" crlf
+				    "  <Formular Typ=\"UST\"></Formular>" crlf
+				    ;; FIXME: Get this Ordnungsnummer somehow
+				    "  <Ordnungsnummer>"
+				    tax-nr
+				    "</Ordnungsnummer>" crlf
+                                    ;;"<software>GnuCash</software>" crlf
+				    ;;"<version>" gnc:version "</version>" crlf
+                                    ;; today-date crlf
+				    "  <AnmeldeJahr>" to-year "</AnmeldeJahr>" crlf
+				    ;; FIXME: Find out what this should mean
+				    "  <AnmeldeZeitraum>" "1" "</AnmeldeZeitraum>" crlf
+                                    output
+				    "</WinstonAusgang>")))
+
+                  (gnc:display-report-list-item output-txf port
+                                                "taxtxf-de.scm - ")
+                  (close-output-port port)
+                  #t)
+                #f))
+
+          (begin			; else do tax report
+            (gnc:html-document-set-style! 
+             doc "blue"
+             'tag "font"
+             'attribute (list "color" "#0000ff"))
+            
+            (gnc:html-document-set-style! 
+             doc "income"
+             'tag "font"
+             'attribute (list "color" "#0000ff"))
+            
+            (gnc:html-document-set-style! 
+             doc "expense"
+             'tag "font"
+             'attribute (list "color" "#ff0000"))
+            
+            (gnc:html-document-set-style!
+             doc "account-header"
+             'tag "th"
+             'attribute (list "align" "left"))
+            
+            (gnc:html-document-set-title! 
+             doc (gnc:html-markup "center" report-name))
+            
+            (gnc:html-document-add-object! 
+             doc (gnc:make-html-text         
+                  (gnc:html-markup 
+                   "center"
+                   (gnc:html-markup-p
+                    (gnc:html-markup/format
+                     (_ "Period from %s to %s") from-date to-date)))))
+            
+            (gnc:html-document-add-object!
+             doc (gnc:make-html-text
+                  (gnc:html-markup 
+                   "center"
+                   (gnc:html-markup
+                    "blue"
+                    (gnc:html-markup-p
+                     (_ "Blue items are exportable to a German Tax XML file. Press Export to actually export them."))))))
+            
+            (txf-print-dups doc)
+            
+            (gnc:html-document-add-object! doc table)
+            
+            (set! txf-dups-alist '())
+            (map (lambda (x) (handle-level-x-account 1 x))
+                 selected-accounts)
+            
+            (if (null? selected-accounts)
+                (gnc:html-document-add-object!
+                 doc
+                 (gnc:make-html-text
+                  (gnc:html-markup-p
+                   (_ "No Tax Related accounts were found.  Go to the\
+ Edit->Tax Options dialog to set up tax-related accounts.")))))
+
+	    (gnc:report-finished)
+            doc)))))
+
+(gnc:define-report
+ 'version 1
+ 'name reportname
+ 'menu-name (N_ "Tax Report & XML Export")
+ ;;'menu-path (list gnc:menuname-taxes)
+ 'menu-tip (N_ "Taxable Income / Deductible Expenses / Export to .XML file")
+ 'options-generator tax-options-generator
+ 'renderer (lambda (report-obj)
+             (generate-tax-or-txf
+              (_ "Taxable Income / Deductible Expenses")
+              (_ "This report shows your Taxable Income and \
+Deductible Expenses.")
+              report-obj
+              #t
+              #f))
+ 'export-types (list (cons (_ "XML") 'txf))
+ 'export-thunk (lambda (report-obj choice file-name)
+                 (generate-tax-or-txf
+                  (_ "Taxable Income / Deductible Expenses")
+                  (_ "This page shows your Taxable Income and \
+Deductible Expenses.")
+                  report-obj
+                  #f
+                  file-name)))
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/locale-specific/us/Makefile.am,v
retrieving revision 1.11.4.1
retrieving revision 1.11.4.2
diff -Lsrc/report/locale-specific/us/Makefile.am -Lsrc/report/locale-specific/us/Makefile.am -u -r1.11.4.1 -r1.11.4.2
--- src/report/locale-specific/us/Makefile.am
+++ src/report/locale-specific/us/Makefile.am
@@ -37,14 +37,15 @@
 
 noinst_DATA = .scm-links
 
+## This is unused and therefore no longer installed and/or loaded
 gncscmmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/report/locale-specific
-gncscmmod_DATA = us.scm 
+gncscmmod_DATA = us.scm de_DE.scm
 
 gncscmothermoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/report/
-gncscmothermod_DATA = taxtxf.scm 
+gncscmothermod_DATA = taxtxf.scm taxtxf-de_DE.scm
 
 EXTRA_DIST = \
-  ${gncscmmod_DATA} \
-  ${gncscmothermod_DATA}
+  ${gncscmothermod_DATA} \
+  ${gncscmmod_DATA} 
 
 CLEANFILES = ${SCM_FILE_LINKS} gnucash report locale-specific us .scm-links
Index: test-string-converters.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/backend/file/test/test-string-converters.c,v
retrieving revision 1.2.6.2
retrieving revision 1.2.6.3
diff -Lsrc/backend/file/test/test-string-converters.c -Lsrc/backend/file/test/test-string-converters.c -u -r1.2.6.2 -r1.2.6.3
--- src/backend/file/test/test-string-converters.c
+++ src/backend/file/test/test-string-converters.c
@@ -23,7 +23,7 @@
     {
         bin_data *test_data1;
         void *test_data2;
-        gint64 test_data2_len;
+        guint64 test_data2_len;
         gchar *converted;
         
         test_data1 = get_random_binary_data();
Index: account-summary.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/report/standard-reports/account-summary.scm,v
retrieving revision 1.11
retrieving revision 1.11.4.1
diff -Lsrc/report/standard-reports/account-summary.scm -Lsrc/report/standard-reports/account-summary.scm -u -r1.11 -r1.11.4.1
--- src/report/standard-reports/account-summary.scm
+++ src/report/standard-reports/account-summary.scm
@@ -1,5 +1,9 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; account-summary.scm : brief account listing 
+;; account-summary.scm : account listing/chart of accounts
+;; 
+;; Rewritten 2004.07.27 by David Montenegro <sunrise2000 at comcast.net>
+;;   same license & restrictions apply
+;; 
 ;; Copyright 2001 Christian Stimming <stimming at tu-harburg.de>
 ;; Copyright 2000-2001 Bill Gribble <grib at gnumatic.com>
 ;;
@@ -7,7 +11,25 @@
 ;;   Author makes no implicit or explicit guarantee of accuracy of
 ;;   these calculations and accepts no responsibility for direct
 ;;   or indirect losses incurred as a result of using this software.
-;;  
+;; 
+;;  * BUGS:
+;;    
+;;    Does not currently provide all possible account attributes.
+;;    
+;;    Table does not currently use row style attributes.
+;;    
+;;    Progress bar functionality is currently mostly broken.
+;;    
+;;    This code makes the assumption that you want your account
+;;    summary to no more than daily resolution.
+;;    
+;;    The Company Name field does not currently default to the name
+;;    in (gnc:get-current-book).
+;;    
+;;    The variables in this code could use more consistent naming.
+;;    
+;;    See also all the "FIXME"s in the code.
+;;    
 ;; This program is free software; you can redistribute it and/or    
 ;; modify it under the terms of the GNU General Public License as   
 ;; published by the Free Software Foundation; either version 2 of   
@@ -34,101 +56,234 @@
 
 (gnc:module-load "gnucash/report/report-system" 0)
 
-;; account summary report
-;; prints a table of account information with clickable 
-;; links to open the corresponding register window.
+;; account summary report prints a table of account information,
+;; optionally with clickable links to open the corresponding register
+;; window.
 
 (define reportname (N_ "Account Summary"))
 
-;; define all option's names such that typos etc. are no longer
-;; possible.
-(define optname-date (N_ "Date"))
-(define optname-display-depth (N_ "Account Display Depth"))
+(define optname-report-title (N_ "Report Title"))
+(define opthelp-report-title (N_ "Title for this report"))
 
-(define optname-show-foreign (N_ "Show Foreign Currencies/Shares of Stock"))
-(define optname-report-currency (N_ "Report's currency"))
-(define optname-price-source (N_ "Price Source"))
+(define optname-party-name (N_ "Company name"))
+(define opthelp-party-name (N_ "Name of company/individual"))
+
+(define optname-date (N_ "Date"))
+(define opthelp-date (N_ "Account summary as-of date"))
+;; FIXME this needs an indent option
 
-(define optname-show-subaccounts (N_ "Always show sub-accounts"))
-(define optname-accounts (N_ "Accounts"))
+(define optname-accounts (N_ "Accounts to include"))
+(define opthelp-accounts
+  (N_ "Report on these accounts, if display depth allows."))
+(define optname-depth-limit (N_ "Levels of Subaccounts"))
+(define opthelp-depth-limit
+  (N_ "Maximum number of levels in the account tree displayed"))
+(define optname-bottom-behavior (N_ "Depth limit behavior"))
+(define opthelp-bottom-behavior
+  (N_ "How to treat accounts which exceed the specified depth limit (if any)"))
+
+(define optname-parent-balance-mode (N_ "Parent account balances"))
+(define opthelp-parent-balance-mode
+  (N_ "How to show any balance in parent accounts"))
+(define optname-parent-total-mode (N_ "Parent account subtotals"))
+(define opthelp-parent-total-mode
+  (N_ "How to show account subtotals for selected accounts having children"))
+
+(define optname-show-zb-accts (N_ "Include accounts with zero total balances"))
+(define opthelp-show-zb-accts
+  (N_ "Include accounts with zero total (recursive) balances in this report"))
+(define optname-omit-zb-bals (N_ "Omit zero balance figures"))
+(define opthelp-omit-zb-bals
+  (N_ "Show blank space in place of any zero balances which would be shown"))
+
+(define optname-use-rules (N_ "Show accounting-style rules"))
+(define opthelp-use-rules
+  (N_ "Use rules beneath columns of added numbers like accountants do"))
+
+(define optname-account-links (N_ "Display accounts as hyperlinks"))
+(define opthelp-account-links (N_ "Shows each account in the table as a hyperlink to its register window"))
+
+(define optname-show-account-bals (N_ "Account Balance"))
+(define opthelp-show-account-bals (N_ "Show an account's balance"))
+(define optname-show-account-code (N_ "Account Code"))
+(define opthelp-show-account-code (N_ "Show an account's account code"))
+(define optname-show-account-type (N_ "Account Type"))
+(define opthelp-show-account-type (N_ "Show an account's account type"))
+(define optname-show-account-desc (N_ "Account Description"))
+(define opthelp-show-account-desc (N_ "Show an account's description"))
+(define optname-show-account-notes (N_ "Account Notes"))
+(define opthelp-show-account-notes (N_ "Show an account's notes"))
 
-(define optname-group-accounts (N_ "Group the accounts"))
-(define optname-show-parent-balance (N_ "Show balances for parent accounts"))
-(define optname-show-parent-total (N_ "Show subtotals"))
+(define pagename-commodities (N_ "Commodities"))
+(define optname-report-commodity (N_ "Report's currency"))
+(define optname-price-source (N_ "Price Source"))
+(define optname-show-foreign (N_ "Show Foreign Currencies"))
+(define opthelp-show-foreign
+  (N_ "Display any foreign currency amount in an account"))
 (define optname-show-rates (N_ "Show Exchange Rates"))
+(define opthelp-show-rates (N_ "Show the exchange rates used"))
+
+;; FIXME: add more account metadata options!
 
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; options generator
-;; select accounts to report on, whether to show subaccounts,
-;; whether to include subtotaled subaccount balances in the report,
-;; and what date to show the summary for.
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define (accsum-options-generator)
-  (let* ((options (gnc:new-options)))
+  (let* ((options (gnc:new-options))
+	 (add-option 
+          (lambda (new-option)
+            (gnc:register-option options new-option))))
+    
+    (add-option
+      (gnc:make-string-option
+      gnc:pagename-general optname-report-title
+      "a" opthelp-report-title reportname))
+    (add-option
+      (gnc:make-string-option
+      gnc:pagename-general optname-party-name
+      "b" opthelp-party-name (N_ "")))
+    ;; this should default to company name in (gnc:get-current-book)
+    ;; does anyone know the function to get the company name??
+
     ;; date at which to report balance
-    (gnc:options-add-report-date!
-     options gnc:pagename-general optname-date "a")
+    (add-option
+     (gnc:make-date-option
+      gnc:pagename-general optname-date
+      "c" opthelp-date
+      (lambda () (cons 'absolute (cons (current-time) 0)))
+      #f 'both '(start-cal-year start-prev-year end-prev-year) ))
 
+    ;; accounts to work on
+    (add-option
+     (gnc:make-account-list-option
+      gnc:pagename-accounts optname-accounts
+      "a"
+      opthelp-accounts
+      (lambda ()
+	(gnc:filter-accountlist-type 
+	 '(bank cash credit asset liability stock mutual-fund currency
+		payable receivable equity income expense)
+	 (gnc:group-get-subaccounts (gnc:get-current-group))))
+      #f #t))
+    (gnc:options-add-account-levels!
+     options gnc:pagename-accounts optname-depth-limit
+     "b" opthelp-depth-limit 3)
+    (add-option
+     (gnc:make-multichoice-option
+      gnc:pagename-accounts optname-bottom-behavior
+      "c" opthelp-bottom-behavior
+      'summarize
+      (list (vector 'summarize
+		    (N_ "Recursive balance")
+		    (N_ "Show the total balance, including balances in subaccounts, of any account at the depth limit"))
+	    (vector 'flatten
+		    (N_ "Raise accounts")
+		    (N_ "Shows accounts deeper than the depth limit at the depth limit"))
+	    (vector 'truncate
+		    (N_ "Omit Accounts")
+		    (N_ "Disregard completely any accounts deeper than the depth limit"))
+	    )
+      )
+     )
+    
     ;; all about currencies
     (gnc:options-add-currency!
-     options gnc:pagename-general 
-     optname-report-currency "b")
-
+     options pagename-commodities
+     optname-report-commodity "a")
+    
     (gnc:options-add-price-source! 
-     options gnc:pagename-general
-     optname-price-source "c" 'weighted-average)
-
-    ;; accounts to work on
-    (gnc:options-add-account-selection! 
-     options gnc:pagename-accounts 
-     optname-display-depth optname-show-subaccounts
-     optname-accounts "a" 2
-     (lambda ()
-       ;; FIXME : gnc:get-current-accounts disappeared
-       (let ((current-accounts '()))
-         (cond ((not (null? current-accounts)) current-accounts)
-               (else
-                (gnc:group-get-account-list (gnc:get-current-group))))))
-     #t)
-    
-    ;; with or without grouping
-    (gnc:options-add-group-accounts!      
-     options gnc:pagename-display optname-group-accounts "b" #t)
-    
-    ;; new options here
-    (gnc:register-option 
-     options
-     (gnc:make-simple-boolean-option
-      gnc:pagename-display optname-show-parent-balance 
-      "c" (N_ "Show balances for parent accounts") #t))
-
-    (gnc:register-option 
-     options
-     (gnc:make-simple-boolean-option
-      gnc:pagename-display optname-show-parent-total
-      "d" (N_ "Show subtotals for parent accounts") #t))
-
-    (gnc:register-option 
-     options
+     options pagename-commodities
+     optname-price-source "b" 'weighted-average)
+    
+    (add-option 
      (gnc:make-simple-boolean-option
-      gnc:pagename-display optname-show-foreign 
-      "e" (N_ "Display the account's foreign currency amount?") #f))
-
-    (gnc:register-option 
-     options
+      pagename-commodities optname-show-foreign 
+      "c" opthelp-show-foreign #t))
+    
+    (add-option 
      (gnc:make-simple-boolean-option
-      gnc:pagename-display optname-show-rates
-      "f" (N_ "Show the exchange rates used") #t))
-
+      pagename-commodities optname-show-rates
+      "d" opthelp-show-rates #f))
+    
+    ;; what to show for zero-balance accounts
+    (add-option 
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-zb-accts
+      "a" opthelp-show-zb-accts #t))
+    (add-option 
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-omit-zb-bals
+      "b" opthelp-omit-zb-bals #f))
+    ;; what to show for non-leaf accounts
+    (add-option
+     (gnc:make-multichoice-option
+      gnc:pagename-display optname-parent-balance-mode
+      "c" opthelp-parent-balance-mode
+      'immediate-bal
+      (list (vector 'immediate-bal
+		    (N_ "Show Immediate Balance")
+		    (N_ "Show only the balance in the parent account, excluding any subaccounts"))
+	    (vector 'recursive-bal
+		    (N_ "Recursive Balance")
+		    (N_ "Include subaccounts in balance"))
+	    (vector 'omit-bal
+		    (N_ "Omit Balance")
+		    (N_ "Do not show parent account balances")))))
+    (add-option
+     (gnc:make-multichoice-option
+      gnc:pagename-display optname-parent-total-mode
+      "d" opthelp-parent-total-mode
+      'f
+      (list (vector 't
+		    (N_ "Show subtotals")
+		    (N_ "Show subtotals for selected accounts which have subaccounts"))
+	    (vector 'f
+		    (N_ "Do not show subtotals")
+		    (N_ "Do not subtotal selected parent accounts"))
+	    (vector 'canonically-tabbed
+		    ;;(N_ "Subtotals indented text book style")
+		    (N_ "Text book style (experimental)")
+		    (N_ "Show parent account subtotals, indented per text book practice (experimental)")))))
+    
+    ;; some detailed formatting options
+    (add-option 
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-account-links
+      "e" opthelp-account-links #t))
+    (add-option 
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-use-rules
+      "f" opthelp-use-rules #f))
+    
+    (add-option 
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-account-bals
+      "g" opthelp-show-account-bals #t))
+    (add-option 
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-account-code
+      "h" opthelp-show-account-code #t))
+    (add-option 
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-account-desc
+      "i" opthelp-show-account-desc #f))
+    (add-option 
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-account-type
+      "j" opthelp-show-account-type #f))
+    (add-option 
+     (gnc:make-simple-boolean-option
+      gnc:pagename-display optname-show-account-notes
+      "k" opthelp-show-account-notes #f))
+    
     ;; Set the general page as default option tab
-    (gnc:options-set-default-section options gnc:pagename-general)      
-
+    (gnc:options-set-default-section options gnc:pagename-display)
     options))
 
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; accsum-renderer
-;; set up the document and add the table
+;; set up the table and put it in an html document
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define (accsum-renderer report-obj)
@@ -138,93 +293,249 @@
       (gnc:report-options report-obj) pagename optname)))
   
   (gnc:report-starting reportname)
-  (let ((display-depth (get-option gnc:pagename-accounts 
-                                   optname-display-depth ))
-        (show-subaccts? (get-option gnc:pagename-accounts
-                                    optname-show-subaccounts))
-        (accounts (get-option gnc:pagename-accounts optname-accounts))
-        (do-grouping? (get-option gnc:pagename-display
-                                  optname-group-accounts))
-        (show-parent-balance? (get-option gnc:pagename-display
-                                          optname-show-parent-balance))
-        (show-parent-total? (get-option gnc:pagename-display
-                                        optname-show-parent-total))
-        (show-fcur? (get-option gnc:pagename-display optname-show-foreign))
-        (report-currency (get-option gnc:pagename-general 
-                                     optname-report-currency))
-        (price-source (get-option gnc:pagename-general
-                                  optname-price-source))
-        (show-rates? (get-option gnc:pagename-display 
-                                 optname-show-rates))
-        (date-tp (gnc:timepair-end-day-time 
-                  (gnc:date-option-absolute-time
-                   (get-option gnc:pagename-general 
-                               optname-date))))
-        (report-title (get-option gnc:pagename-general
-                                  gnc:optname-reportname))
-        (doc (gnc:make-html-document))
-        (txt (gnc:make-html-text)))
-
+  
+  (let* (
+	 (report-title (get-option gnc:pagename-general optname-report-title))
+	 (company-name (get-option gnc:pagename-general optname-party-name))
+         (date-tp (gnc:timepair-end-day-time 
+                      (gnc:date-option-absolute-time
+                       (get-option gnc:pagename-general
+                                   optname-date))))
+         (accounts (get-option gnc:pagename-accounts
+                               optname-accounts))
+	 (depth-limit (get-option gnc:pagename-accounts 
+				  optname-depth-limit))
+	 (bottom-behavior (get-option gnc:pagename-accounts 
+				  optname-bottom-behavior))
+         (report-commodity (get-option pagename-commodities
+                                      optname-report-commodity))
+         (price-source (get-option pagename-commodities
+                                   optname-price-source))
+         (show-fcur? (get-option pagename-commodities
+                                 optname-show-foreign))
+         (show-rates? (get-option pagename-commodities
+                                  optname-show-rates))
+         (parent-balance-mode (get-option gnc:pagename-display
+                                           optname-parent-balance-mode))
+         (parent-total-mode
+	  (car
+	   (assoc-ref '((t #t) (f #f) (canonically-tabbed canonically-tabbed))
+		      (get-option gnc:pagename-display
+				  optname-parent-total-mode))))
+         (show-zb-accts? (get-option gnc:pagename-display
+				     optname-show-zb-accts))
+         (omit-zb-bals? (get-option gnc:pagename-display
+				    optname-omit-zb-bals))
+         (use-links? (get-option gnc:pagename-display
+				     optname-account-links))
+         (use-rules? (get-option gnc:pagename-display
+				    optname-use-rules))
+         (show-account-code? (get-option gnc:pagename-display
+					 optname-show-account-code))
+         (show-account-type? (get-option gnc:pagename-display
+					 optname-show-account-type))
+         (show-account-desc? (get-option gnc:pagename-display
+					 optname-show-account-desc))
+         (show-account-notes? (get-option gnc:pagename-display
+					  optname-show-account-notes))
+         (show-account-bals? (get-option gnc:pagename-display
+					 optname-show-account-bals))
+	 (indent 0)
+	 (tabbing #f)
+	 
+         (doc (gnc:make-html-document))
+	 ;; just in case we need this information...
+         (tree-depth (if (equal? depth-limit 'all)
+                         (gnc:get-current-group-depth) 
+			 depth-limit))
+         ;; exchange rates calculation parameters
+	 (exchange-fn
+	  (gnc:case-exchange-fn price-source report-commodity date-tp))
+	 )
+    
     (gnc:html-document-set-title! 
-     doc 
-     (string-append 
-      report-title
-      " "
-      (gnc:print-date date-tp)))
-
-    (if (not (null? accounts))
-        ;; if no max. tree depth is given we have to find the
-        ;; maximum existing depth
-        (let* ((tree-depth (+ (if (equal? display-depth 'all)
-				  (gnc:get-current-group-depth)
-				  display-depth)
-                              (if do-grouping? 1 0)))
-               (exchange-fn #f)
-	       (table #f))
-
-	  (gnc:report-percent-done 2)
-	  (set! exchange-fn (gnc:case-exchange-fn 
-                             price-source report-currency date-tp))
-	  (gnc:report-percent-done 10)
-
-	  ;; do the processing here
-	  (set! table (gnc:html-build-acct-table 
-                       #f date-tp 
-                       tree-depth show-subaccts? accounts
-		       10 80
-                       #t
-                       #t gnc:accounts-get-comm-total-assets 
-                       (_ "Total") do-grouping? 
-                       show-parent-balance? show-parent-total?
-                       show-fcur? report-currency exchange-fn #t))
-
-          ;; add the table 
-	  (gnc:report-percent-done 90)
-          (gnc:html-document-add-object! doc table)
-
+     doc (string-append company-name " " report-title " "
+			(gnc:print-date date-tp))
+     )
+    
+    (if (null? accounts)
+	
+	;; error condition: no accounts specified
+	;; is this *really* necessary??  i'd be fine with an all-zero
+	;; account summary that would, technically, be correct....
+        (gnc:html-document-add-object! 
+         doc 
+         (gnc:html-make-no-account-warning 
+	  reportname (gnc:report-id report-obj)))
+	
+	;; otherwise, generate the report...
+	(let* (
+	       (chart-table #f)                    ;; gnc:html-acct-table
+	       (hold-table (gnc:make-html-table))  ;; temporary gnc:html-table
+	       (build-table (gnc:make-html-table)) ;; gnc:html-table reported
+	       (get-total-balance-fn
+		(lambda (account)
+		  (gnc:account-get-comm-balance-at-date 
+		   account date-tp #f)))
+	       (table-env                      ;; parameters for :make-
+		(list
+		 (list 'start-date #f)
+		 (list 'end-date date-tp)
+		 (list 'display-tree-depth tree-depth)
+		 (list 'depth-limit-behavior bottom-behavior)
+		 (list 'report-commodity report-commodity)
+		 (list 'exchange-fn exchange-fn)
+		 (list 'parent-account-subtotal-mode parent-total-mode)
+		 (list 'zero-balance-mode (if show-zb-accts?
+					      'show-leaf-acct
+					      'omit-leaf-acct))
+		 (list 'account-label-mode (if use-links?
+					       'anchor
+					       'name))
+		 )
+		)
+	  (params                         ;; and -add-account-
+		(list
+		 (list 'parent-account-balance-mode parent-balance-mode)
+		 (list 'zero-balance-display-mode (if omit-zb-bals?
+						      'omit-balance
+						      'show-balance))
+		 (list 'multicommodity-mode (if show-fcur? 'table #f))
+		 (list 'rule-mode use-rules?)
+		  )
+		)
+	  
+	  ;; FIXME: this filtering is trivial and could probably be
+	  ;; greatly simplified (it just collects all selected
+	  ;; accounts)...
+	  (split-up-accounts (gnc:decompose-accountlist accounts))
+	  (all-accounts
+	   (append (assoc-ref split-up-accounts 'income)
+		   (assoc-ref split-up-accounts 'expense)
+		   (assoc-ref split-up-accounts 'asset)
+		   (assoc-ref split-up-accounts 'liability)
+		   (assoc-ref split-up-accounts 'equity)
+		   ))
+	  ;; (all-accounts (map (lambda (X) (cadr X)) split-up-accounts))
+	  ;; ^ will not do what we want
+	  
+	  (account-cols 0)
+	  (table-rows 0)
+	  (cur-col 0)
+	  (foo #f) ;; a dummy variable for when i'm too lazy to type much
+	  (add-col #f) ;; thunk to add a column to build-table
+	  (hold-table-width 0)
+	  )
+	  
+	  (set! chart-table
+		(gnc:make-html-acct-table/env/accts
+		 table-env all-accounts))
+	  (gnc:html-table-add-account-balances
+	   hold-table chart-table params)
+	  (set! table-rows (or (gnc:html-acct-table-num-rows chart-table) 0))
+	  (set! account-cols
+		(if (zero? table-rows)
+		    0
+		    (or (car (assoc-ref
+			      (gnc:html-acct-table-get-row-env chart-table 0)
+			      'account-cols))
+			0)
+		    )
+		)
+	  
+	  (set! add-col
+		(lambda(key)
+		  (let ((row 0)
+			(row-env #f)
+			)
+		    (while (< row table-rows)
+			   (set! row-env
+				 (gnc:html-acct-table-get-row-env
+				  chart-table row))
+			   (gnc:html-table-set-cell!
+			    build-table (+ row 1) cur-col ;; +1 for headers
+			    (car (assoc-ref row-env key))
+			    )
+			   (set! row (+ row 1))
+			   )
+		    )
+		  (set! cur-col (+ cur-col 1))
+		  )
+		)
+
+	  ;; place the column headers
+	  (gnc:html-table-append-row!
+	   build-table
+	   (append
+	    (if show-account-code? (list (N_ "Code")) '())
+	    (if show-account-type? (list (N_ "Type")) '())
+	    (if show-account-desc? (list (N_ "Description")) '())
+	    (list (N_ "Account title"))
+	    )
+	   )
+	  ;; add any fields to be displayed before the account name
+	  (if show-account-code? (add-col 'account-code))
+	  (if show-account-type? (add-col 'account-type-string))
+	  (if show-account-desc? (add-col 'account-description))
+	  
+	  (set! hold-table-width
+		(if show-account-bals?
+		    (gnc:html-table-num-columns hold-table)
+		    account-cols
+		    )
+		)
+	  (if show-account-bals?
+	      (gnc:html-table-set-cell!
+	       build-table 0 (+ cur-col account-cols) (N_ "Balance"))
+	      )
+	  (let ((row 0))
+	    (while (< row table-rows)
+		   (let ((col 0))
+		     (while (< col hold-table-width)
+			    (gnc:html-table-set-cell!
+			     build-table (+ row 1) (+ cur-col col)
+			     (gnc:html-table-get-cell hold-table row col)
+			     )
+			    (set! col (+ col 1))
+			    )
+		     )
+		   (set! row (+ row 1))
+		   )
+	    )
+	  (set! cur-col (+ cur-col hold-table-width))
+	  (if show-account-notes?
+	      (begin
+		(gnc:html-table-set-cell!
+		 build-table 0 cur-col (N_ "Notes"))
+		(add-col 'account-notes)
+		)
+	      )
+	  
+	  (gnc:html-document-add-object! doc build-table)
+	  
           ;; add currency information
           (if show-rates?
               (gnc:html-document-add-object! 
                doc ;;(gnc:html-markup-p
                (gnc:html-make-exchangerates 
-                report-currency exchange-fn 
-                (append-map 
+                report-commodity exchange-fn 
+                (append-map
                  (lambda (a)
                    (gnc:group-get-subaccounts
                     (gnc:account-get-children a)))
-                 accounts)))))
-
-        ;; error condition: no accounts specified
-        (gnc:html-document-add-object! 
-         doc 
-         (gnc:html-make-no-account-warning 
-	  report-title (gnc:report-id report-obj))))
-
+                 accounts))))
+	  )
+	)
+    
     (gnc:report-finished)
-    doc))
+    doc)
+  )
 
 (gnc:define-report 
- 'version 1
+ 'version 2
  'name reportname
  'options-generator accsum-options-generator
  'renderer accsum-renderer)
+
+;; END
+
Index: gncInvoice.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/business/business-core/gncInvoice.c,v
retrieving revision 1.56.4.7
retrieving revision 1.56.4.8
diff -Lsrc/business/business-core/gncInvoice.c -Lsrc/business/business-core/gncInvoice.c -u -r1.56.4.7 -r1.56.4.8
--- src/business/business-core/gncInvoice.c
+++ src/business/business-core/gncInvoice.c
@@ -855,23 +855,23 @@
     if (this_acc) {
       if (gnc_numeric_check (value) == GNC_ERROR_OK) {
 	if (accumulatesplits) {
-	    gncAccountValueAdd (splitinfo, this_acc, value);
+	    splitinfo = gncAccountValueAdd (splitinfo, this_acc, value);
 	} else {
-		Split *split;
+	  Split *split;
 
-		split = xaccMallocSplit (invoice->inst.book);
-		/* set action and memo? */
+	  split = xaccMallocSplit (invoice->inst.book);
+	  /* set action and memo? */
 
-		xaccSplitSetMemo (split, gncEntryGetDescription (entry));
-		xaccSplitSetAction (split, type);
+	  xaccSplitSetMemo (split, gncEntryGetDescription (entry));
+	  xaccSplitSetAction (split, type);
 
-		xaccSplitSetBaseValue (split, (reverse ? gnc_numeric_neg (value)
-				: value),
+	  xaccSplitSetBaseValue (split, (reverse ? gnc_numeric_neg (value)
+					 : value),
 				 invoice->currency);
-       	xaccAccountBeginEdit (this_acc);
-        xaccAccountInsertSplit (this_acc, split);
-        xaccAccountCommitEdit (this_acc);
-        xaccTransAppendSplit (txn, split);
+	  xaccAccountBeginEdit (this_acc);
+	  xaccAccountInsertSplit (this_acc, split);
+	  xaccAccountCommitEdit (this_acc);
+	  xaccTransAppendSplit (txn, split);
 	}
 
 	/* If there is a credit-card account, and this is a CCard
Index: main.scm
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/scm/main.scm,v
retrieving revision 1.109.2.10
retrieving revision 1.109.2.11
diff -Lsrc/scm/main.scm -Lsrc/scm/main.scm -u -r1.109.2.10 -r1.109.2.11
--- src/scm/main.scm
+++ src/scm/main.scm
@@ -358,7 +358,7 @@
      (_ "This is a development version. It may or may not work.\n")
      (_ "Report bugs and other problems to gnucash-devel at gnucash.org.\n")
      (_ "You can also lookup and file bug reports at http://bugzilla.gnome.org\n")
-     (_ "The last stable version was ") "GnuCash 1.8.10" "\n"
+     (_ "The last stable version was ") "GnuCash 1.8.11" "\n"
      (_ "The next stable version will be ") "GnuCash 2.0"
      "\n\n"))))
 
Index: test-book-merge.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/engine/test/test-book-merge.c,v
retrieving revision 1.2.2.3
retrieving revision 1.2.2.4
diff -Lsrc/engine/test/test-book-merge.c -Lsrc/engine/test/test-book-merge.c -u -r1.2.2.3 -r1.2.2.4
--- src/engine/test/test-book-merge.c
+++ src/engine/test/test-book-merge.c
@@ -450,11 +450,11 @@
 		/* do NOT use as_string for calculations or set_fcn */
 		importstring = qof_book_merge_param_as_string(eachParam, rule->importEnt);
 		do_test ((importstring != NULL), "loop:#16 import param_as_string is null");
-//		printf("importstring %s\t%s Type\n", importstring, eachParam->param_type);
+/*		printf("importstring %s\t%s Type\n", importstring, eachParam->param_type);*/
 		if(!skip_target) {
 		targetstring = qof_book_merge_param_as_string(eachParam, rule->targetEnt);
 		do_test ((targetstring != NULL), "loop:#17 target param_as_string is null");
-//		printf("targetstring %s\t%s Type\n", targetstring, eachParam->param_type);
+/*		printf("targetstring %s\t%s Type\n", targetstring, eachParam->param_type);*/
 			}
 		/* add your own code for user involvement here. */
 		/* either store the importstring and targetstring values and display separately,
Index: gnc-module.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnc-module/gnc-module.h,v
retrieving revision 1.3.4.1
retrieving revision 1.3.4.2
diff -Lsrc/gnc-module/gnc-module.h -Lsrc/gnc-module/gnc-module.h -u -r1.3.4.1 -r1.3.4.2
--- src/gnc-module/gnc-module.h
+++ src/gnc-module/gnc-module.h
@@ -35,7 +35,12 @@
 GList         * gnc_module_system_modinfo(void);
 
 /* load and unload a module.  gnc_module_system_init() must be called
- * before loading and unloading. */
+ * before loading and unloading. 
+ *
+ * Note/FIXME: There seems to be no real reason for why the argument
+ * module_name is not a const gchar?! It certainly should be const
+ * (because of passing string literals), and from a quick glance it is
+ * also only used in a const way. */
 GNCModule       gnc_module_load(gchar * module_name, gint interface);
 GNCModule       gnc_module_load_optional(gchar * module_name, gint interface);
 int             gnc_module_unload(GNCModule mod);
Index: import-settings.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/import-settings.h,v
retrieving revision 1.2
retrieving revision 1.2.4.1
diff -Lsrc/import-export/import-settings.h -Lsrc/import-export/import-settings.h -u -r1.2 -r1.2.4.1
--- src/import-export/import-settings.h
+++ src/import-export/import-settings.h
@@ -36,8 +36,17 @@
 
 
 
-/** Allocates a new GNCImportSettings object, and initialize it with the
-    appropriate user prefs.
+/** Allocates a new GNCImportSettings object, and initialize it with
+ *    the appropriate user prefs.
+ *
+ * @param match_date_hardlimit The number of days that a matching
+ * split may differ from the given transaction before it is discarded
+ * immediately. In other words, any split that is more distant from
+ * the given transaction than this match_date_hardlimit days will be
+ * ignored altogether. For use cases without paper checks (e.g. HBCI),
+ * values like 14 (days) might be appropriate, whereas for use cases
+ * with paper checks (e.g. OFX, QIF), values like 42 (days) seem more
+ * appropriate. 
 */
 GNCImportSettings * 
 gnc_import_Settings_new (void);
@@ -83,6 +92,20 @@
 /** Return the selected threshold.
 */
 gint gnc_import_Settings_get_display_threshold (GNCImportSettings *settings);
+
+/** @param match_date_hardlimit The number of days that a matching
+ * split may differ from the given transaction before it is discarded
+ * immediately. In other words, any split that is more distant from
+ * the given transaction than this match_date_hardlimit days will be
+ * ignored altogether. For use cases without paper checks (e.g. HBCI),
+ * values like 14 (days) might be appropriate, whereas for use cases
+ * with paper checks (e.g. OFX, QIF), values like 42 (days) seem more
+ * appropriate. 
+ */
+void gnc_import_Settings_set_match_date_hardlimit (GNCImportSettings *settings, gint match_date_hardlimit);
+/** Returns the hard-limiting number of days that a matching split may differ. */
+gint gnc_import_Settings_get_match_date_hardlimit (const GNCImportSettings *settings);
+
 /**@}*/
 /**@}*/
 
Index: import-backend.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/import-backend.h,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -Lsrc/import-export/import-backend.h -Lsrc/import-export/import-backend.h -u -r1.4 -r1.4.2.1
--- src/import-export/import-backend.h
+++ src/import-export/import-backend.h
@@ -71,10 +71,21 @@
  * @param fuzzy_amount_difference For fuzzy amount matching, a certain
  * fuzzyness in the matching amount is allowed up to this value. May
  * be e.g. 3.00 dollars for ATM fees, or 0.0 if you only want to allow
- * exact matches. */
+ * exact matches. 
+ *
+ * @param match_date_hardlimit The number of days that a matching
+ * split may differ from the given transaction before it is discarded
+ * immediately. In other words, any split that is more distant from
+ * the given transaction than this match_date_hardlimit days will be
+ * ignored altogether. For use cases without paper checks (e.g. HBCI),
+ * values like 14 (days) might be appropriate, whereas for use cases
+ * with paper checks (e.g. OFX, QIF), values like 42 (days) seem more
+ * appropriate. 
+ */
 void gnc_import_find_split_matches(GNCImportTransInfo *transaction_info,
 				   gint process_threshold, 
-				   double fuzzy_amount_difference);
+				   double fuzzy_amount_difference,
+				   gint match_date_hardlimit);
 
 /** Iterates through all splits of the originating account of
  * trans_info. Sorts the resulting list and sets the selected_match
@@ -83,21 +94,8 @@
  * @param trans_info The TransInfo for which the matches should be
  * found, sorted, and selected. 
  *
- * @param clear_threshold If the heuristics of the best matching split
- * is higher or equal this value, 'clear' is selected as default
- * action. 
- *
- * @param add_threshold If the heuristics of the best matching split
- * is lesser or equal this value, 'add' is selected as default
- * action. 
- *
- * @paran process_threshold Each potential match whose heuristics are
- * smaller than this value is totally ignored. 
- *
- * @param fuzzy_amount_difference For fuzzy amount matching, a certain
- * fuzzyness in the matching amount is allowed up to this value. May
- * be e.g. 3.00 dollars for ATM fees, or 0.0 if you only want to allow
- * exact matches. */
+ * @param settings The structure that holds all the user preferences.
+ */
 void 
 gnc_import_TransInfo_init_matches (GNCImportTransInfo *trans_info,
 				   GNCImportSettings *settings);
Index: import-settings.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/import-settings.c,v
retrieving revision 1.4.4.1
retrieving revision 1.4.4.2
diff -Lsrc/import-export/import-settings.c -Lsrc/import-export/import-settings.c -u -r1.4.4.1 -r1.4.4.2
--- src/import-export/import-settings.c
+++ src/import-export/import-settings.c
@@ -84,6 +84,7 @@
   /** The allowed amount range for fuzzy amount matching, 
       in the users default commodity.*/
   double fuzzy_amount;
+  gint match_date_hardlimit;
 };
 
 
@@ -122,7 +123,8 @@
   settings->fuzzy_amount =
     gnc_lookup_number_option(MATCHER_PREF_PAGE,"Commercial ATM fees threshold",
 			     DEFAULT_ATM_FEE_THRESHOLD);
-  
+
+  settings->match_date_hardlimit = 42; /* 6 weeks */
   return settings;
 }
 
@@ -183,4 +185,15 @@
   return settings->display_threshold;
 };
 
+void gnc_import_Settings_set_match_date_hardlimit (GNCImportSettings *s, gint m)
+{ 
+  g_assert(s);
+  s->match_date_hardlimit = m;
+}
+gint gnc_import_Settings_get_match_date_hardlimit (const GNCImportSettings *s)
+{
+  g_assert(s);
+  return s->match_date_hardlimit;
+}
+
 /**@}*/
Index: import-main-matcher.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/import-main-matcher.c,v
retrieving revision 1.13.2.5
retrieving revision 1.13.2.6
diff -Lsrc/import-export/import-main-matcher.c -Lsrc/import-export/import-main-matcher.c -u -r1.13.2.5 -r1.13.2.6
--- src/import-export/import-main-matcher.c
+++ src/import-export/import-main-matcher.c
@@ -380,8 +380,9 @@
 }
 
 GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent, 
-					   const gchar* heading,
-					   gboolean all_from_same_account)
+					      const gchar* heading,
+					      gboolean all_from_same_account,
+					      gint match_date_hardlimit)
 {
   GNCImportMainMatcher *info;
   GladeXML *xml;
@@ -391,6 +392,7 @@
 
   /* Initialize user Settings. */
   info->user_settings = gnc_import_Settings_new ();
+  gnc_import_Settings_set_match_date_hardlimit (info->user_settings, match_date_hardlimit);
 
   /* Initialize the GtkDialog. */
   xml = gnc_glade_xml_new ("generic-import.glade", "transaction_matcher");
Index: import-backend.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/import-backend.c,v
retrieving revision 1.19.2.5
retrieving revision 1.19.2.6
diff -Lsrc/import-export/import-backend.c -Lsrc/import-export/import-backend.c -u -r1.19.2.5 -r1.19.2.6
--- src/import-export/import-backend.c
+++ src/import-export/import-backend.c
@@ -616,11 +616,8 @@
 	{
 	  /* If a transaction's amount doesn't match within the
 	     threshold, it's very unlikely to be the same transaction
-	     so we give it an extra -5 penality. Changed 2004-11-27:
-	     The penalty is so high that we can forget about this
-	     split anyway and skip the rest of the tests. */
-	  return;
-	  /* prob = prob-5; */
+	     so we give it an extra -5 penality */
+	  prob = prob-5;
 	  /* DEBUG("heuristics:  probability - 1 (amount)"); */
 	}
       
@@ -648,12 +645,13 @@
       else if (datediff_day > MATCH_DATE_NOT_THRESHOLD)
 	{
 	  /* Extra penalty if that split lies awfully far away from
-	     the given one. Changed 2004-11-27: The penalty is so high
-	     that we can forget about this split anyway and skip the
-	     rest of the tests. */
-	  return;
-	  /* prob = prob-5; */
+	     the given one. */
+	  prob = prob-5;
 	  /*DEBUG("heuristics:  probability - 5 (date)"); */
+	  /* Changed 2005-02-21: Revert the hard-limiting behaviour
+	     back to the previous large penalty. (Changed 2004-11-27:
+	     The penalty is so high that we can forget about this
+	     split anyway and skip the rest of the tests.) */
 	}
       
       /* Check number heuristics */  
@@ -768,7 +766,8 @@
    transaction, and find all matching splits there. */
 void gnc_import_find_split_matches(GNCImportTransInfo *trans_info,
 				   gint process_threshold, 
-				   double fuzzy_amount_difference)
+				   double fuzzy_amount_difference,
+				   gint match_date_hardlimit)
 {
   GList * list_element;
   Query *query = xaccMallocQuery();
@@ -790,8 +789,8 @@
     xaccQueryAddSingleAccountMatch (query, importaccount,			    
 				    QOF_QUERY_AND);
     xaccQueryAddDateMatchTT (query,
-			     TRUE, download_time - MATCH_DATE_NOT_THRESHOLD*86400/2,
-			     TRUE, download_time + MATCH_DATE_NOT_THRESHOLD*86400/2,
+			     TRUE, download_time - match_date_hardlimit*86400,
+			     TRUE, download_time + match_date_hardlimit*86400,
 			     QOF_QUERY_AND);
     list_element = xaccQueryGetSplits (query);
     /* Sigh. Doesnt help too much. We still create and run one query
@@ -1072,7 +1071,8 @@
   /* Find all split matches in originating account. */
   gnc_import_find_split_matches(trans_info,  
 				gnc_import_Settings_get_display_threshold (settings),
-				gnc_import_Settings_get_fuzzy_amount (settings));
+				gnc_import_Settings_get_fuzzy_amount (settings),
+				gnc_import_Settings_get_match_date_hardlimit (settings));
   
   if (trans_info->match_list != NULL) 
     {
Index: import-main-matcher.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/import-export/import-main-matcher.h,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -Lsrc/import-export/import-main-matcher.h -Lsrc/import-export/import-main-matcher.h -u -r1.3 -r1.3.4.1
--- src/import-export/import-main-matcher.h
+++ src/import-export/import-main-matcher.h
@@ -33,25 +33,41 @@
 typedef struct _main_matcher_info GNCImportMainMatcher;
 
 /** Create a new generic transaction dialog window and return it. 
-    @param parent The parent GtkWidget. May be NULL.
-    @param heading The heading label in the Importer window. May be NULL.
-    @param all_from_same_account Set this to TRUE if ALL the transaction 
-    that will be added with gnc_gen_trans_list_add_trans are from the same
-    source account.  This will cause the account column to be hidden.
+ *
+ * @param parent The parent GtkWidget. May be NULL.
+ *
+ * @param heading The heading label in the Importer window. May be NULL.
+ *
+ * @param all_from_same_account Set this to TRUE if ALL the
+ * transaction that will be added with gnc_gen_trans_list_add_trans
+ * are from the same source account.  This will cause the account
+ * column to be hidden.
+ *
+ * @param match_date_hardlimit The number of days that a matching
+ * split may differ from the given transaction before it is discarded
+ * immediately. In other words, any split that is more distant from
+ * the given transaction than this match_date_hardlimit days will be
+ * ignored altogether. For use cases without paper checks (e.g. HBCI),
+ * values like 14 (days) might be appropriate, whereas for use cases
+ * with paper checks (e.g. OFX, QIF), values like 42 (days) seem more
+ * appropriate. 
 */
 GNCImportMainMatcher *gnc_gen_trans_list_new (GtkWidget *parent, 
 					   const gchar* heading,
-					   gboolean all_from_same_account);
+					   gboolean all_from_same_account,
+					      gint match_date_hardlimit);
 
 /** Deletes the given object. */
 void gnc_gen_trans_list_delete (GNCImportMainMatcher *info);
 
 /** Add a newly imported Transaction to the Transaction Importer.
-    @param gui The Transaction Importer to use.
-    @param trans The Transaction to add.     The must contain at least
-    one split, and this split must have been associated with an account
-    Only the first split will be used for matching.  The 
-    transaction must NOT be commited.
+ *
+ * @param gui The Transaction Importer to use.
+ *
+ * @param trans The Transaction to add.  The must contain at least one
+ * split, and this split must have been associated with an account
+ * Only the first split will be used for matching.  The transaction
+ * must NOT be commited.
  */
 void gnc_gen_trans_list_add_trans(GNCImportMainMatcher *gui, Transaction *trans);
 
--- /dev/null
+++ src/tax/us/de_DE.scm
@@ -0,0 +1,25 @@
+(define-module (gnucash tax de_DE))
+
+(use-modules (gnucash gnc-module))
+(gnc:module-load "gnucash/app-utils" 0)
+
+(export gnc:txf-get-payer-name-source)
+(export gnc:txf-get-form)
+(export gnc:txf-get-description)
+(export gnc:txf-get-format)
+(export gnc:txf-get-multiple)
+(export gnc:txf-get-category-key)
+(export gnc:txf-get-help)
+(export gnc:txf-get-codes)
+(export gnc:txf-get-code-info)
+(export txf-help-categories)
+(export txf-income-categories)
+(export txf-expense-categories)
+
+(define gnc:*tax-label* (N_ "Tax"))
+(define gnc:*tax-nr-label* (N_ "Tax Number"))
+
+(export gnc:*tax-label* gnc:*tax-nr-label*)
+
+(load-from-path "txf-de_DE.scm")
+(load-from-path "txf-help-de_DE.scm")
Index: Makefile.am
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/tax/us/Makefile.am,v
retrieving revision 1.9.4.1
retrieving revision 1.9.4.2
diff -Lsrc/tax/us/Makefile.am -Lsrc/tax/us/Makefile.am -u -r1.9.4.1 -r1.9.4.2
--- src/tax/us/Makefile.am
+++ src/tax/us/Makefile.am
@@ -17,7 +17,7 @@
 
 if GNUCASH_SEPARATE_BUILDDIR
 #For executing test cases
-SCM_FILE_LINKS = us.scm
+SCM_FILE_LINKS = us.scm de_DE.scm
 endif
 
 .scm-links:
@@ -34,10 +34,10 @@
 noinst_DATA = .scm-links
 
 gncscmmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/tax
-gncscmmod_DATA = us.scm
+gncscmmod_DATA = us.scm de_DE.scm
 
 gncscmdir = ${GNC_SHAREDIR}/scm
-gncscm_DATA = txf.scm txf-help.scm 
+gncscm_DATA = txf.scm txf-help.scm txf-de_DE.scm txf-help-de_DE.scm 
 
 EXTRA_DIST = \
   ${gncscmmod_DATA} \
--- /dev/null
+++ src/tax/us/txf-help-de_DE.scm
@@ -0,0 +1,38 @@
+;; -*-scheme-*-
+;;
+;; This file was copied from the file txf.scm by  Richard -Gilligan- Uschold
+;;
+;; Originally, these were meant to hold the codes for the US tax TXF
+;; format. I modified this heavily so that it might become useful for
+;; the German Umsatzsteuer-Voranmeldung. 
+;;
+;; This file holds the explanations to the categories from txf-de_DE.scm.
+;;
+
+(define txf-help-strings
+  '(
+    (H001 . "Categories marked with a \"&lt;\" or a \"^\", require a Payer identification to be exported.  \"&lt;\" indicates that the name of this account is exported as this Payer ID.  Typically, this is a bank, stock, or mutual fund name.")
+    (H002 . "Categories marked with a \"&lt;\" or a \"^\", require a Payer identification to be exported.  \"^\" indicates that the name of the PARENT of this account is exported as this Payer ID.  Typically, this is a bank, stock, or mutual fund name.")
+    (H003 . "Categories marked with a \"#\" are not fully implemented yet!  Do not use these codes!")
+    (N000 . "This is a dummy category and only shows up on the tax report, but is not exported.")
+
+
+    (K41 . "Innergemeinschaftliche Lieferungen (§ 4 Nr. 1 Buchst. b UStG) an Abnehmer mit USt-IdNr.  (Bemessungsgrundlage)")
+    (K44 . "Innergemeinschaftliche Lieferungen neuer Fahrzeuge an Abnehmer ohne USt-IdNr (Bemessungsgrundlage)")
+    (K49 . "Innergemeinschaftliche Lieferungen neuer Fahrzeuge außerhalb eines Unternehmens (§ 2a UStG)  (Bemessungsgrundlage)")
+    (K43 . "Weitere steuerfreie Umsätze mit Vorsteuerabzug (z.B. Ausfuhrlieferungen, Umsätze nach § 4 Nr. 2 bis 7 UStG) (Bemessungsgrundlage)")
+    (K48 . "Steuerfreie Umsätze ohne Vorsteuerabzug: Umsätze nach § 4 Nr. 8 bis 28 UStG (Bemessungsgrundlage)")
+
+    (K51 . "Steuerpflichtige Umsätze (Lieferungen und sonstige Leistungen einschl. unentgeltlicher Wertabgaben) zum Steuersatz von 16 v.H. (Bemessungsgrundlage)")
+    (K86 . "Steuerpflichtige Umsätze (Lieferungen und sonstige Leistungen einschl. unentgeltlicher Wertabgaben) zum Steuersatz von 7 v.H. (Bemessungsgrundlage)")
+    (K35 . "Umsätze, die anderen Steuersätzen unterliegen (Bemessungsgrundlage)")
+    (K36 . "Umsätze, die anderen Steuersätzen unterliegen (Steuer)")
+    (K77 . "Umsätze land- und forstwirtschaftlicher Betriebe nach § 24 UStG: Lieferungen in das übrige Gemeinschaftsgebiet an Abnehmer mit USt-IdNr. (Bemessungsgrundlage)")
+    (K76 . "Umsätze, für die eine Steuer nach § 24 UStG zu entrichten ist (Sägewerkserzeugnisse, Getränke und alkohol. Flüssigkeiten, z.B. Wein) (Bemessungsgrundlage)")
+    (K80 . "Umsätze, für die eine Steuer nach § 24 UStG zu entrichten ist (Sägewerkserzeugnisse, Getränke und alkohol. Flüssigkeiten, z.B. Wein) (Steuer)")
+
+    (K91 . "Steuerfreie innergemeinschaftliche Erwerbe: Erwerbe nach § 4b UStG (Bemessungsgrundlage)")
+
+
+    (K66 . "Vorsteuerbeträge aus Rechnungen von anderen Unternehmern (§ 15 Abs. 1 Satz 1 Nr. 1 UStG), aus Leistungen im Sinne des § 13a Abs. 1 Nr. 6 UStG (§ 15 Abs. 1 Satz 1 Nr. 5 UStG) und aus innergemeinschaftlichen Dreiecksgeschäften (§ 25b Abs. 5 UStG)")
+    ))
--- /dev/null
+++ src/tax/us/txf-de_DE.scm
@@ -0,0 +1,132 @@
+;; -*-scheme-*-
+;; 
+;; This file was copied from the file txf.scm by  Richard -Gilligan- Uschold
+;;
+;; Originally, these were meant to hold the codes for the US tax TXF
+;; format. I modified this heavily so that it might become useful for
+;; the German Umsatzsteuer-Voranmeldung. 
+;; 
+;; This file holds all the Kennzahlen for the
+;; Umsatzsteuer-Voranmeldung and their explanations, which can be
+;; assigned to particular accounts via the "Edit -> Tax options"
+;; dialog. The report in taxtxf-de_DE.scm then will extract the
+;; numbers for these Kennzahlen from the actual accounts for a given
+;; time period, and will write it to some XML file as required by
+;; e.g. the Winston software
+;; http://www.felfri.de/winston/schnittstellen.htm
+;;
+(define (gnc:txf-get-payer-name-source categories code)
+  (gnc:txf-get-code-info categories code 0))
+(define (gnc:txf-get-form categories code)
+  (gnc:txf-get-code-info categories code 1))
+(define (gnc:txf-get-description categories code)
+  (gnc:txf-get-code-info categories code 2))
+(define (gnc:txf-get-format categories code)
+  (gnc:txf-get-code-info categories code 3))
+(define (gnc:txf-get-multiple categories code)
+  (gnc:txf-get-code-info categories code 4))
+(define (gnc:txf-get-category-key categories code)
+  (gnc:txf-get-code-info categories code 5))
+(define (gnc:txf-get-help categories code)
+  (let ((pair (assv code txf-help-strings)))
+    (if pair
+        (cdr pair)
+        "No help available.")))
+
+(define (gnc:txf-get-codes categories)
+  (map car categories))
+
+;;;; Private
+
+(define (gnc:txf-get-code-info categories code index)
+  (vector-ref (cdr (assv code categories)) index))
+
+(define txf-help-categories
+  (list
+   (cons 'H000 #(current "help" "Name of Current account is exported." 0 #f ""))
+   (cons 'H002 #(parent "help" "Name of Parent account is exported." 0 #f ""))
+   (cons 'H003 #(not-impl "help" "Not implemented yet, Do NOT Use!" 0 #f ""))))
+
+;; We use several formats; nr. 1 means Euro+Cent, nr. 2 means only full Euro
+
+;; Also, we abuse the "category-key" for now to store the Kennzahl as
+;; well. We are not yet sure what to use the "form" field for.
+
+;; Format: (name-source  form  description  format  multiple  category-key)
+(define txf-income-categories
+  (list
+   (cons 'N000 #(none "" "Nur zur Voransicht im Steuer-Bericht -- kein Export" 0 #f ""))
+
+   (cons 'K41 #(none "41" "Innergemeinschaftliche Lieferungen an Abnehmer mit USt-IdNr. " 2 #f "41"))
+   (cons 'K44 #(none "44" "Innergemeinschaftliche Lieferungen neuer Fahrzeuge an Abnehmer ohne USt-IdNr" 2 #f "44"))
+   (cons 'K49 #(none "49" "Innergemeinschaftliche Lieferungen neuer Fahrzeuge außerhalb eines Unternehmens" 2 #f "49"))
+   (cons 'K43 #(none "43" "Weitere steuerfreie Umsätze mit Vorsteuerabzug" 2 #f "43"))
+   (cons 'K48 #(none "48" "Steuerfreie Umsätze ohne Vorsteuerabzug" 2 #f "48"))
+   
+   (cons 'K51 #(none "51" "Steuerpflichtige Umsätze, Steuersatz 16 v.H." 2 #f "51"))
+   (cons 'K86 #(none "86" "Steuerpflichtige Umsätze, Steuersatz 7 v.H." 2 #f "86"))
+   (cons 'K35 #(none "35" "Umsätze, die anderen Steuersätzen unterliegen (Bemessungsgrundlage)" 2 #f "35"))
+   (cons 'K36 #(none "36" "Umsätze, die anderen Steuersätzen unterliegen (Steuer)" 1 #f "36"))
+   (cons 'K77 #(none "77" "Umsätze land- und forstwirtschaftlicher Betriebe:: Lieferungen in das übrige Gemeinschaftsgebiet an Abnehmer mit USt-IdNr." 2 #f "77"))
+   (cons 'K76 #(none "76" "Umsätze, für die eine Steuer nach § 24 UStG zu entrichten ist (Bemessungsgrundlage)" 2 #f "76"))
+   (cons 'K80 #(none "80" "Umsätze, für die eine Steuer nach § 24 UStG zu entrichten ist (Steuer)" 1 #f "80"))
+
+   (cons 'K39 #(none "39" "Anrechnung (Abzug) der festgesetzten Sondervorauszahlung für Dauerfristverlängerung" 1 #f "39"))
+   (cons 'K83 #(none "83" "Verbleibende Umsatzsteuer-Vorauszahlung" 1 #f "83"))
+
+   ))
+
+
+;; We use several formats; nr. 1 means Euro+Cent, nr. 2 means only full Euro
+
+;; Also, we abuse the "category-key" for now to store the Kennzahl as
+;; well. We are not yet sure what to use the "form" field for.
+
+;; Format: (name-source  form  description  format  multiple  category-key)
+(define txf-expense-categories
+  (list
+   (cons 'N000 #(none "" "Nur zur Voransicht im Steuer-Bericht -- kein Export" 0 #f ""))
+
+   (cons 'K91 #(none "91" "Steuerfreie innergemeinschaftliche Erwerbe nach §4b UStG" 2 #f "91"))
+   (cons 'K97 #(none "97" "Steuerpflichtige innergemeinschaftliche Erwerbe zum Steuersatz von 16 v.H." 2 #f "97"))
+   (cons 'K93 #(none "93" "Steuerpflichtige innergemeinschaftliche Erwerbe zum Steuersatz von 7 v.H." 2 #f "93"))
+   (cons 'K95 #(none "95" "Steuerpflichtige innergemeinschaftliche Erwerbe zu anderen Steuersätzen (Bemessungsgrundlage)" 2 #f "95"))
+   (cons 'K98 #(none "98" "Steuerpflichtige innergemeinschaftliche Erwerbe zu anderen Steuersätzen (Steuer)" 1 #f "98"))
+   (cons 'K94 #(none "94" "Innergemeinschaftliche Erwerbe neuer Fahrzeuge von Lieferern ohne USt-IdNr. (Bemessungsgrundlage)" 2 #f "94"))
+   (cons 'K96 #(none "96" "Innergemeinschaftliche Erwerbe neuer Fahrzeuge von Lieferern ohne USt-IdNr. (Steuer)" 1 #f "96"))
+   (cons 'K42 #(none "42" "Lieferungen des ersten Abnehmers (§25b Abs. 2 UStG) bei innergemeinschaftlichen Dreiecksgeschäften" 2 #f "42"))
+
+   (cons 'K54 #(none "54" "Umsätze, für die der Leistungsempfänger die Steuer nach §13b Abs 2 UStG schuldet - zum Steuersatz von 16 v.H. (Bemessungsgrundlage)" 2 #f "54"))
+   (cons 'K55 #(none "55" "Umsätze, für die der Leistungsempfänger die Steuer nach §13b Abs 2 UStG schuldet - zum Steuersatz von 7 v.H. (Bemessungsgrundlage)" 2 #f "55"))
+   (cons 'K57 #(none "57" "Umsätze, für die der Leistungsempfänger die Steuer nach §13b Abs 2 UStG schuldet - zu anderen Steuersätzen (Bemessungsgrundlage)" 2 #f "57"))
+   (cons 'K45 #(none "45" "Umsätze, für die der Leistungsempfänger die Steuer nach §13b Abs 2 UStG schuldet - Nicht steuerbare Umsätze (Bemessungsgrundlage)" 2 #f "45"))
+
+   (cons 'K58 #(none "58" "Umsätze, für die der Leistungsempfänger die Steuer nach §13b Abs 2 UStG schuldet - zu anderen Steuersätzen (Steuer)" 1 #f "58"))
+   (cons 'K65 #(none "65" "Steuer infolge Wechsels der Besteuerungsart/-form" 1 #f "65"))
+
+   (cons 'K66 #(none "66" "Vorsteuerbeträge aus Rechnungen von anderen Unternehmern" 1 #f "66"))
+   (cons 'K61 #(none "61" "Vorsteuerbeträge aus dem innergemeinschaftlichen Erwerb von Gegenständen" 1 #f "61"))
+   (cons 'K62 #(none "62" "Entrichtete Einfuhrumsatzsteuer" 1 #f "62"))
+   (cons 'K67 #(none "67" "Vorsteuerbeträge aus Leistungen im Sinne des $13b Abs. 1 UStG" 1 #f "67"))
+   (cons 'K63 #(none "63" "Vorsteuerbeträge, die nach allgemeinen Durchschnittssätzen berechnet sind" 1 #f "63"))
+   (cons 'K64 #(none "64" "Berichtigung des Vorsteuerabzugs" 1 #f "64"))
+   (cons 'K59 #(none "59" "Vorsteuerabzug für innergemeinschaftliche Lieferungen neuer Fahrzeuge außerhalb eines Unternehmens" 1 #f "59"))
+
+   (cons 'K69 #(none "69" "Steuerbeträge, die vom letzten Abnehmer eines innergemeinschaftlichen Dreiecksgeschäfts geschuldet werden" 1 #f "69"))
+
+   ))
+
+
+
+;;; Register global options in this book
+(define (book-options-generator options)
+  (define (reg-option new-option)
+    (gnc:register-option options new-option))
+
+  (reg-option
+   (gnc:make-string-option
+    gnc:*tax-label* gnc:*tax-nr-label*
+    "a" (N_ "The electronic tax number of your business") ""))
+  )
+
+(gnc:register-kvp-option-generator gnc:id-book book-options-generator)
Index: gncmod-tax-us.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/tax/us/gncmod-tax-us.c,v
retrieving revision 1.3.4.1
retrieving revision 1.3.4.2
diff -Lsrc/tax/us/gncmod-tax-us.c -Lsrc/tax/us/gncmod-tax-us.c -u -r1.3.4.1 -r1.3.4.2
--- src/tax/us/gncmod-tax-us.c
+++ src/tax/us/gncmod-tax-us.c
@@ -9,6 +9,8 @@
 #include <stdio.h>
 #include <glib.h>
 #include <libguile.h>
+#include <locale.h>
+#include <string.h>
 
 #include "gnc-module.h"
 #include "gnc-module-api.h"
@@ -31,7 +33,13 @@
 
 char *
 libgncmod_tax_us_LTX_gnc_module_path(void) {
-  return g_strdup("gnucash/tax/us");
+#ifdef LOCALE_SPECIFIC_TAX
+  const char *thislocale = setlocale(LC_ALL, NULL);
+  if (strncmp(thislocale, "de_DE", 5) == 0)
+    return g_strdup("gnucash/tax/de_DE");
+  else
+#endif
+    return g_strdup("gnucash/tax/us");
 }
 
 char * 
@@ -49,7 +57,16 @@
 
 int
 libgncmod_tax_us_LTX_gnc_module_init(int refcount) {
-  lmod("(gnucash tax us)");
+  /* This is a very simple hack that loads the (new, special) German
+     tax definition file in a German locale, or (default) loads the
+     previous US tax file. */
+#ifdef LOCALE_SPECIFIC_TAX
+  const char *thislocale = setlocale(LC_ALL, NULL);
+  if (strncmp(thislocale, "de_DE", 5) == 0)
+    lmod("(gnucash tax de_DE)");
+  else
+#endif
+    lmod("(gnucash tax us)");
   return TRUE;
 }
 


More information about the gnucash-changes mailing list