From 1c6f3fc957bb3524d0ccbcb11de117bc84c6dab4 Mon Sep 17 00:00:00 2001 From: Daniel Dittmann Date: Mon, 30 Dec 2019 17:53:05 +0100 Subject: [PATCH] create a more consistent aqbanking online_id The online_id will generated based on bankcode and accountnumber. The accountnumber may have leading zeros which shall be ignored to make the creation reliable. In my case the accountnumber of the accountinfo has no leading zeros, but the accountnumber of the imported transactions has leading zeros. In the result the generated online_id was different and the widget to assign the transactions to a account appears always. --- gnucash/import-export/aqb/gnc-ab-utils.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gnucash/import-export/aqb/gnc-ab-utils.c b/gnucash/import-export/aqb/gnc-ab-utils.c index ffa025fd93..fbdc19307d 100644 --- a/gnucash/import-export/aqb/gnc-ab-utils.c +++ b/gnucash/import-export/aqb/gnc-ab-utils.c @@ -323,6 +323,15 @@ create_online_id(const gchar *bankcode, const gchar *accountnumber) { gchar *online_id; + /* The accountnumber may have leading zeros, depending on where them + * accountnumber is came from, e.g. the accountnumber of accountinfo + * has no leading zeros while the (local)accountnumber of a transaction + * has leading zeros. + * So remove all leading '0', to get a consistent online_id. + */ + while (accountnumber && *accountnumber == '0') + accountnumber++; + online_id = g_strconcat(bankcode ? bankcode : "", accountnumber ? accountnumber : "", (gchar*)NULL); @@ -342,7 +351,7 @@ join_ab_strings_cb(const gchar *str, gpointer user_data) if (!str || !*str) return NULL; - + tmp = g_strdup(str); g_strstrip(tmp); gnc_utf8_strip_invalid_and_controls(tmp); @@ -406,7 +415,7 @@ gnc_ab_get_purpose(const AB_TRANSACTION *ab_trans, gboolean is_ofx) g_return_val_if_fail(ab_trans, g_strdup("")); - if (!is_ofx && gnc_prefs_get_bool(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_USE_TRANSACTION_TXT)) + if (!is_ofx && gnc_prefs_get_bool(GNC_PREFS_GROUP_AQBANKING, GNC_PREF_USE_TRANSACTION_TXT)) { /* According to AqBanking, some of the non-swift lines have a special * meaning. Some banks place valuable text into the transaction text,