Skip to content

Commit

Permalink
Add ability to show HBCI Online Account matches to 'Import Map Editor'
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob-IT committed Mar 16, 2020
1 parent 1fa5fd0 commit 6b55222
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 16 deletions.
48 changes: 41 additions & 7 deletions gnucash/gnome/dialog-imap-editor.c
Expand Up @@ -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)
{
Expand Down Expand Up @@ -736,31 +739,62 @@ 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
gtk_tree_store_append (GTK_TREE_STORE(imap_dialog->model), &toplevel, NULL);
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);
}
}

Expand Down
13 changes: 8 additions & 5 deletions gnucash/gtkbuilder/dialog-imap-editor.glade
Expand Up @@ -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>
Expand Down Expand Up @@ -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"/>
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
6 changes: 4 additions & 2 deletions libgnucash/engine/Account.cpp
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions libgnucash/engine/Account.h
Expand Up @@ -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
Expand Down

0 comments on commit 6b55222

Please sign in to comment.