gnucash maint: Multiple changes pushed

Frank H.Ellenberger fell at code.gnucash.org
Thu Jan 2 07:21:45 EST 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/9e8886ef (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1c6f3fc9 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/a574be63 (commit)
	from  https://github.com/Gnucash/gnucash/commit/7acc2706 (commit)



commit 9e8886efb6f0f7ad2339887a7809887286022508
Merge: 7acc2706c 1c6f3fc95
Author: Frank H. Ellenberger <frank.h.ellenberger at gmail.com>
Date:   Thu Jan 2 13:15:43 2020 +0100

    Merge PR #623 into maint


commit 1c6f3fc957bb3524d0ccbcb11de117bc84c6dab4
Author: Daniel Dittmann <ddittmann at gmx.net>
Date:   Mon Dec 30 17:53:05 2019 +0100

    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.

diff --git a/gnucash/import-export/aqb/gnc-ab-utils.c b/gnucash/import-export/aqb/gnc-ab-utils.c
index ffa025fd9..fbdc19307 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,

commit a574be635a638f08517b0c125c78050079fb7f2e
Author: Daniel Dittmann <ddittmann at gmx.net>
Date:   Mon Dec 30 15:02:44 2019 +0100

    gnucash/import-export/aqb/gnc-ab-utils.c: extract 'create_online_id' function

diff --git a/gnucash/import-export/aqb/gnc-ab-utils.c b/gnucash/import-export/aqb/gnc-ab-utils.c
index 4ba804ad6..ffa025fd9 100644
--- a/gnucash/import-export/aqb/gnc-ab-utils.c
+++ b/gnucash/import-export/aqb/gnc-ab-utils.c
@@ -63,6 +63,7 @@ G_GNUC_UNUSED static QofLogModule log_module = G_LOG_DOMAIN;
 static AB_BANKING *gnc_AB_BANKING = NULL;
 static gint gnc_AB_BANKING_refcount = 0;
 
+static gchar* create_online_id(const gchar *bankcode, const gchar *accountnumber);
 static gpointer join_ab_strings_cb(const gchar *str, gpointer user_data);
 static Account *gnc_ab_accinfo_to_gnc_acc(GtkWidget *parent,
     AB_IMEXPORTER_ACCOUNTINFO *account_info);
@@ -316,6 +317,19 @@ gnc_AB_VALUE_to_readable_string(const AB_VALUE *value)
         return g_strdup_printf("%.2f", 0.0);
 }
 
+
+static gchar*
+create_online_id(const gchar *bankcode, const gchar *accountnumber)
+{
+    gchar *online_id;
+
+    online_id = g_strconcat(bankcode ? bankcode : "",
+                            accountnumber ? accountnumber : "",
+                            (gchar*)NULL);
+
+    return online_id;
+}
+
 /**
  * Take a string from a GWEN_STRINGLIST, strip invalid utf8 and join it
  * to the rest.
@@ -646,9 +660,7 @@ gnc_ab_accinfo_to_gnc_acc(GtkWidget *parent, AB_IMEXPORTER_ACCOUNTINFO *acc_info
 
     bankcode = AB_ImExporterAccountInfo_GetBankCode(acc_info);
     accountnumber = AB_ImExporterAccountInfo_GetAccountNumber(acc_info);
-    online_id = g_strconcat(bankcode ? bankcode : "",
-                            accountnumber ? accountnumber : "",
-                            (gchar*)NULL);
+    online_id = create_online_id(bankcode, accountnumber);
     gnc_acc = gnc_import_select_account(
                   parent, online_id, 1, AB_ImExporterAccountInfo_GetAccountName(acc_info),
                   NULL, ACCT_TYPE_NONE, NULL, NULL);
@@ -687,9 +699,7 @@ gnc_ab_txn_to_gnc_acc(GtkWidget *parent, const AB_TRANSACTION *transaction)
         return NULL;
     }
 
-    online_id = g_strconcat(bankcode ? bankcode : "",
-                            accountnumber ? accountnumber : "",
-                            (gchar*)NULL);
+    online_id = create_online_id(bankcode, accountnumber);
     gnc_acc = gnc_import_select_account(
                   parent, online_id, 1, AB_Transaction_GetLocalName(transaction),
                   NULL, ACCT_TYPE_NONE, NULL, NULL);



Summary of changes:
 gnucash/import-export/aqb/gnc-ab-utils.c | 35 ++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)



More information about the gnucash-changes mailing list