gnucash master: Add ability to show HBCI Online Account matches to 'Import Map Editor'

Robert Fewell bobit at code.gnucash.org
Mon Mar 16 11:06:10 EDT 2020


Updated	 via  https://github.com/Gnucash/gnucash/commit/6b55222c (commit)
	from  https://github.com/Gnucash/gnucash/commit/1fa5fd0a (commit)



commit 6b55222ca9c5f4a531c94dc11dce2a8a415fcf5e
Author: Robert Fewell <14uBobIT at gmail.com>
Date:   Mon Mar 16 15:02:46 2020 +0000

    Add ability to show HBCI Online Account matches to 'Import Map Editor'

diff --git a/gnucash/gnome/dialog-imap-editor.c b/gnucash/gnome/dialog-imap-editor.c
index 4dc512127..a6721f2f9 100644
--- a/gnucash/gnome/dialog-imap-editor.c
+++ b/gnucash/gnome/dialog-imap-editor.c
@@ -549,6 +549,9 @@ list_type_selected_cb (GtkToggleButton* button, ImapDialog *imap_dialog)
     else
         type = ONLINE;
 
+    if (type != ONLINE)
+        gtk_widget_grab_focus (GTK_WIDGET(imap_dialog->filter_text_entry));
+
     // Lets do this only on change of list type
     if (type != imap_dialog->type)
     {
@@ -736,24 +739,27 @@ get_account_info_online (ImapDialog *imap_dialog, GList *accts)
     /* Go through list of accounts */
     for (ptr = accts; ptr; ptr = g_list_next (ptr))
     {
+        gchar  *hbci_account_id = NULL;
+        gchar  *hbci_bank_code = NULL;
         gchar  *text = NULL;
         Account *acc = ptr->data;
 
-        // Save source account
-        imapInfo.source_account = acc;
-        imapInfo.head = "online_id";
-        imapInfo.category = " ";
-
-        text = gnc_account_get_map_entry (acc, imapInfo.head);
+        // Check for online_id
+        text = gnc_account_get_map_entry (acc, "online_id", NULL);
 
         if (text != NULL)
         {
+            // Save source account
+            imapInfo.source_account = acc;
+            imapInfo.head = "online_id";
+            imapInfo.category = " ";
+
             if (g_strcmp0 (text, "") == 0)
                 imapInfo.map_account = NULL;
             else
                 imapInfo.map_account = imapInfo.source_account;
 
-            imapInfo.match_string  = text;
+            imapInfo.match_string = text;
             imapInfo.count = " ";
 
             // Add top level entry and pass iter to add_to_store
@@ -761,6 +767,34 @@ get_account_info_online (ImapDialog *imap_dialog, GList *accts)
             add_to_store (imap_dialog, &toplevel, _("Online Id"), &imapInfo);
         }
         g_free (text);
+
+        // Check for aqbanking hbci
+        hbci_account_id = gnc_account_get_map_entry (acc, "hbci", "account-id");
+        hbci_bank_code = gnc_account_get_map_entry (acc, "hbci", "bank-code");
+        text = g_strconcat (hbci_bank_code, ",", hbci_account_id, NULL);
+
+        if ((hbci_account_id != NULL) || (hbci_bank_code != NULL))
+        {
+            // Save source account
+            imapInfo.source_account = acc;
+            imapInfo.head = "hbci";
+            imapInfo.category = " ";
+
+            if (g_strcmp0 (text, "") == 0)
+                imapInfo.map_account = NULL;
+            else
+                imapInfo.map_account = imapInfo.source_account;
+
+            imapInfo.match_string = text;
+            imapInfo.count = " ";
+
+            // Add top level entry and pass iter to add_to_store
+            gtk_tree_store_append (GTK_TREE_STORE(imap_dialog->model), &toplevel, NULL);
+            add_to_store (imap_dialog, &toplevel, _("Online HBCI"), &imapInfo);
+        }
+        g_free (hbci_account_id);
+        g_free (hbci_bank_code);
+        g_free (text);
     }
 }
 
diff --git a/gnucash/gtkbuilder/dialog-imap-editor.glade b/gnucash/gtkbuilder/dialog-imap-editor.glade
index c1e61c8cc..b7d7658e3 100644
--- a/gnucash/gtkbuilder/dialog-imap-editor.glade
+++ b/gnucash/gtkbuilder/dialog-imap-editor.glade
@@ -156,7 +156,7 @@
             </child>
             <child>
               <object class="GtkRadioButton" id="radio-online">
-                <property name="label" translatable="yes">Online ID</property>
+                <property name="label" translatable="yes">Online</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">False</property>
@@ -288,8 +288,8 @@
           <object class="GtkLabel" id="filter-label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="margin_top">5</property>
-            <property name="margin_bottom">5</property>
+            <property name="margin_top">3</property>
+            <property name="margin_bottom">3</property>
             <property name="label" translatable="yes">Filter will be applied to 'Match String' and 'Mapped to Account Name' fields, case sensitive.</property>
             <style>
               <class name="gnc-class-highlight"/>
@@ -320,6 +320,9 @@
               <object class="GtkEntry" id="filter-text-entry">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="has_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
                 <property name="invisible_char">●</property>
                 <property name="primary_icon_activatable">False</property>
                 <property name="secondary_icon_activatable">False</property>
@@ -394,8 +397,8 @@
           <object class="GtkLabel" id="label2">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="margin_top">5</property>
-            <property name="margin_bottom">5</property>
+            <property name="margin_top">3</property>
+            <property name="margin_bottom">3</property>
             <property name="label" translatable="yes">Multiple rows can be selected and then deleted by pressing the delete button.</property>
           </object>
           <packing>
diff --git a/libgnucash/engine/Account.cpp b/libgnucash/engine/Account.cpp
index f35d6507c..affe470e1 100644
--- a/libgnucash/engine/Account.cpp
+++ b/libgnucash/engine/Account.cpp
@@ -5802,11 +5802,13 @@ gnc_account_imap_get_info (Account *acc, const char *category)
 /*******************************************************************************/
 
 gchar *
-gnc_account_get_map_entry (Account *acc, const char *full_category)
+gnc_account_get_map_entry (Account *acc, const char *head, const char *category)
 {
     GValue v = G_VALUE_INIT;
     gchar *text = NULL;
-    std::vector<std::string> path {full_category};
+    std::vector<std::string> path {head};
+    if (category)
+        path.emplace_back (category);
     if (qof_instance_has_path_slot (QOF_INSTANCE (acc), path))
     {
         qof_instance_get_path_kvp (QOF_INSTANCE (acc), &v, path);
diff --git a/libgnucash/engine/Account.h b/libgnucash/engine/Account.h
index 8a326471a..0c121b972 100644
--- a/libgnucash/engine/Account.h
+++ b/libgnucash/engine/Account.h
@@ -1457,10 +1457,10 @@ GList *gnc_account_imap_get_info_bayes (Account *acc);
  */
 GList *gnc_account_imap_get_info (Account *acc, const char *category);
 
-/** Returns the text string pointed to by full_category for the Account, free
+/** Returns the text string pointed to by head and category for the Account, free
  *  the returned text
  */
-gchar *gnc_account_get_map_entry (Account *acc, const char *full_category);
+gchar *gnc_account_get_map_entry (Account *acc, const char *head, const char *category);
 
 /** Delete the entry for Account pointed to by head,category and match_string,
  *  if empty is TRUE then use delete if empty



Summary of changes:
 gnucash/gnome/dialog-imap-editor.c          | 48 ++++++++++++++++++++++++-----
 gnucash/gtkbuilder/dialog-imap-editor.glade | 13 +++++---
 libgnucash/engine/Account.cpp               |  6 ++--
 libgnucash/engine/Account.h                 |  4 +--
 4 files changed, 55 insertions(+), 16 deletions(-)



More information about the gnucash-changes mailing list