AUDIT: r23114 - gnucash/trunk/src/import-export - Bug 704183 - ofx file import tries to match online_id against ACCTID[space]ACCTKEY even when ACCTKEY is empty
John Ralls
jralls at code.gnucash.org
Fri Aug 2 13:55:52 EDT 2013
Author: jralls
Date: 2013-08-02 13:55:52 -0400 (Fri, 02 Aug 2013)
New Revision: 23114
Trac: http://svn.gnucash.org/trac/changeset/23114
Modified:
gnucash/trunk/src/import-export/import-account-matcher.c
Log:
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.
BP
Modified: gnucash/trunk/src/import-export/import-account-matcher.c
===================================================================
--- gnucash/trunk/src/import-export/import-account-matcher.c 2013-08-02 17:55:40 UTC (rev 23113)
+++ gnucash/trunk/src/import-export/import-account-matcher.c 2013-08-02 17:55:52 UTC (rev 23114)
@@ -249,7 +249,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 =
@@ -257,6 +257,34 @@
test_acct_online_id_match,
/* 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