r23115 - gnucash/branches/2.4/src/import-export - [r23114]Bug 704183 - ofx file import tries to match online_id against ACCTID[space]ACCTKEY even when ACCTKEY is
John Ralls
jralls at code.gnucash.org
Fri Aug 2 13:57:46 EDT 2013
Author: jralls
Date: 2013-08-02 13:57:45 -0400 (Fri, 02 Aug 2013)
New Revision: 23115
Trac: http://svn.gnucash.org/trac/changeset/23115
Modified:
gnucash/branches/2.4/src/import-export/import-account-matcher.c
Log:
[r23114]Bug 704183 - ofx file import tries to match online_id against ACCTID[space]ACCTKEY even when ACCTKEY is
empty
Alters the gnucash account matching code to search a second time if
the original search fails and the account ID has a trailing space. The second
search tries with the trailing space removed.
Modified: gnucash/branches/2.4/src/import-export/import-account-matcher.c
===================================================================
--- gnucash/branches/2.4/src/import-export/import-account-matcher.c 2013-08-02 17:55:52 UTC (rev 23114)
+++ gnucash/branches/2.4/src/import-export/import-account-matcher.c 2013-08-02 17:57:45 UTC (rev 23115)
@@ -170,7 +170,7 @@
picker->new_account_default_commodity = new_account_default_commodity;
picker->new_account_default_type = new_account_default_type;
- /*DEBUG("Looking for account with online_id: %s", account_online_id_value);*/
+ /*DEBUG("Looking for account with online_id: \"%s\"", account_online_id_value);*/
if (account_online_id_value != NULL)
{
retval =
@@ -179,6 +179,34 @@
/* This argument will only be
used as a "const char*" */
(void*)account_online_id_value);
+
+ /* BEGIN: try again without extra space at the end */
+ /*
+ * libofx, used for file import, generates online_id as
+ * ACCTID + space + ACCTKEY which differs from the online_id
+ * generated by aqbanking for online ofx transfer as ACCTID.
+ *
+ * If a gnucash account has been associated with an online_id
+ * via aqbanking data, it is not possible to construct an OFX
+ * file for gnucash import that matches the same online_id
+ * because even with no ACCTKEY in the file, there will be a
+ * trailing space.
+ *
+ * This is a hack to overcome that problem.
+ */
+ if ((retval == NULL) && g_str_has_suffix(account_online_id_value, " "))
+ {
+ gchar *trimmed = g_strndup(account_online_id_value, strlen(account_online_id_value) - 1);
+ if (trimmed)
+ {
+ retval = gnc_account_foreach_descendant_until(
+ gnc_get_current_root_account (),
+ test_acct_online_id_match,
+ (void *)trimmed);
+ }
+ g_free(trimmed);
+ }
+ /* END: try again without extra space at the end */
}
if (retval == NULL && auto_create != 0)
{
More information about the gnucash-changes
mailing list