r20144 - gnucash/trunk - Bug #640233: Don't add "Account unknown Bank Unknown" memo when account and/or bank does not exist
Christian Stimming
cstim at code.gnucash.org
Sat Jan 22 09:36:18 EST 2011
Author: cstim
Date: 2011-01-22 09:36:18 -0500 (Sat, 22 Jan 2011)
New Revision: 20144
Trac: http://svn.gnucash.org/trac/changeset/20144
Modified:
gnucash/trunk/AUTHORS
gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c
Log:
Bug #640233: Don't add "Account unknown Bank Unknown" memo when account and/or bank does not exist
Patch by Jeff Kletsky:
At least for the online OFX sources I use in the US, downloaded
transactions are populated with memos of
"Account unknown Bank unknown"
Past being annoying, this can cause improper "matches" when comparing
transactions.
The root cause is found in src/import-export/aqbanking/gnc-ab-utils.c
in the function gnc_ab_memo_to_gnc where the code seems to check for
the existence of a remote account number from the aqbanking
transaction
if (ab_other_accountid && *ab_other_accountid)
and appears to intend to return the empty string if one is not present.
However, an earlier line in the code sets ab_other_accountid to
"unknown" so that the test always returns true.
This patch should return:
* "Account <account number> Bank <bank number>" if both are present
* "Account <account number>" if only the account is present
* "Bank <bank number>" if only the bank is present
* "" if neither is present
Additionally, ordering of trimming was changed to handle the
possibility that the leading and/or trailing character(s) were stripped
as invalid UTF-8, resulting in an untrimmed string.
Modified: gnucash/trunk/AUTHORS
===================================================================
--- gnucash/trunk/AUTHORS 2011-01-22 10:13:04 UTC (rev 20143)
+++ gnucash/trunk/AUTHORS 2011-01-22 14:36:18 UTC (rev 20144)
@@ -182,6 +182,7 @@
Prakash Kailasa <PrakashK at bigfoot.com> for gnome build fixes
Alexey Kakunin <small at arcadia.spb.ru> quickfill patch for Cyrillic
Ben Kelly <ben.kelly at ieee.org> for Motif menu bug fix, core dump fixes
+Jeff Kletsky <gnomebugzilla at allycomm.com> Various patches, including for OFX import
Tom Kludy <tkludy at csd.sgi.com> for SGI Irix port
Tuomo Kohvakka <tuomo.kohvakka at iki.fi> Finnish translation
Matt Kraai <kraai at alumni.carnegiemellon.edu> date accelerator bug fix
Modified: gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c 2011-01-22 10:13:04 UTC (rev 20143)
+++ gnucash/trunk/src/import-export/aqbanking/gnc-ab-utils.c 2011-01-22 14:36:18 UTC (rev 20144)
@@ -410,30 +410,42 @@
AB_Transaction_GetRemoteAccountNumber(ab_trans);
const gchar *ab_remote_bankcode =
AB_Transaction_GetRemoteBankCode(ab_trans);
- gchar *ab_other_accountid =
- g_strdup(ab_remote_accountnumber ? ab_remote_accountnumber
- : _("unknown"));
- gchar *ab_other_bankcode =
- g_strdup(ab_remote_bankcode ? ab_remote_bankcode
- : _("unknown"));
+
+ gchar *ab_other_accountid = g_strdup(ab_remote_accountnumber);
+ gchar *ab_other_bankcode = g_strdup(ab_remote_bankcode);
+
+ gboolean have_accountid;
+ gboolean have_bankcode;
+
gchar *retval;
- g_strstrip(ab_other_accountid);
- g_strstrip(ab_other_bankcode);
/* Ensure string is in utf8 */
gnc_utf8_strip_invalid(ab_other_accountid);
gnc_utf8_strip_invalid(ab_other_bankcode);
- if (ab_other_accountid && *ab_other_accountid)
+ /* and -then- trim it */
+ g_strstrip(ab_other_accountid);
+ g_strstrip(ab_other_bankcode);
+
+
+ have_accountid = ab_other_accountid && *ab_other_accountid;
+ have_bankcode = ab_other_bankcode && *ab_other_bankcode;
+
+ if ( have_accountid || have_bankcode )
{
retval = g_strdup_printf("%s %s %s %s",
- _("Account"), ab_other_accountid,
- _("Bank"), ab_other_bankcode);
+ have_accountid ? _("Account") : "",
+ have_accountid ? ab_other_accountid : "",
+ have_bankcode ? _("Bank") : "",
+ have_bankcode ? ab_other_bankcode : ""
+ );
+ g_strstrip(retval);
}
else
{
retval = g_strdup("");
}
+
g_free(ab_other_accountid);
g_free(ab_other_bankcode);
More information about the gnucash-changes
mailing list