gnucash stable: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Thu May 16 06:48:49 EDT 2024


Updated	 via  https://github.com/Gnucash/gnucash/commit/31095c12 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f7f42bf6 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3547885e (commit)
	from  https://github.com/Gnucash/gnucash/commit/c5194902 (commit)



commit 31095c1205f769dd6dccaf4bb8f60ab14e56fe7c
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu May 16 12:48:30 2024 +0200

    Import Matcher - select row if none is selected yet when right-clicking the list of matches

diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp
index bcbb1d7469..84f795bbde 100644
--- a/gnucash/import-export/import-main-matcher.cpp
+++ b/gnucash/import-export/import-main-matcher.cpp
@@ -1462,15 +1462,27 @@ gnc_gen_trans_onButtonPressed_cb (GtkTreeView *treeview,
         GdkEventButton *event_button = (GdkEventButton *) event;
         if (event_button->button == GDK_BUTTON_SECONDARY)
         {
-            DEBUG("Right mouseClick detected- popup the menu.");
-            // Only pop up the menu if there's more than 1 selected transaction,
-            // or the selected transaction is an ADD.
-            GtkTreeSelection *selection = gtk_tree_view_get_selection (treeview);
+            DEBUG("Right mouseClick detected - popup the menu.");
+
+            auto selection = gtk_tree_view_get_selection (treeview);
+            auto selected_rows = gtk_tree_selection_count_selected_rows (selection);
+            /* If no rows are selected yet, select the row that was clicked on
+             * before proceeding */
+            if (!selected_rows)
+            {
+                GtkTreePath* path = nullptr;
+                if (gtk_tree_view_get_path_at_pos (treeview, event_button->x,
+                    event_button->y, &path, nullptr, nullptr, nullptr))
+                {
+                    gtk_tree_selection_select_path (selection, path);
+                    selected_rows++;
+                    gtk_tree_path_free (path);
+                }
+            }
             if (gtk_tree_selection_count_selected_rows (selection) > 0)
             {
-                GList* selected;
                 GtkTreeModel *model;
-                selected = gtk_tree_selection_get_selected_rows (selection, &model);
+                auto selected = gtk_tree_selection_get_selected_rows (selection, &model);
                 if (get_action_for_path (static_cast<GtkTreePath*>(selected->data), model) == GNCImport_ADD)
                     gnc_gen_trans_view_popup_menu (treeview, event, info);
                 g_list_free_full (selected, (GDestroyNotify)gtk_tree_path_free);

commit f7f42bf6fbadde06bce40c506c0fb75eea09f3bb
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu May 16 12:18:08 2024 +0200

    Bug 799279 - Import Matcher (CSV) does not compute correctly the share amount based on security price - part 2
    
    Do proper conversion based on entered exchange rate.

diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp
index 9f1997fe00..bcbb1d7469 100644
--- a/gnucash/import-export/import-main-matcher.cpp
+++ b/gnucash/import-export/import-main-matcher.cpp
@@ -1138,8 +1138,17 @@ gnc_gen_trans_set_price_to_selection_cb (GtkMenuItem *menuitem,
         if (!gnc_xfer_dialog_run_until_done(xfer))
             break; /* If the user cancels, return to the payment dialog without changes */
 
-        gnc_import_TransInfo_set_price (row.get_trans_info (), exch);
-        refresh_model_row (info, model, row.get_iter(), row.get_trans_info());
+
+        /* Note the exchange rate we received is backwards from what we really need:
+         * it converts value to amount, but the remainder of the code expects
+         * an exchange rate that converts from amount to value. So let's invert
+         * the result (though only if that doesn't result in a division by 0). */
+        if (!gnc_numeric_zero_p(exch))
+        {
+            gnc_import_TransInfo_set_price (row.get_trans_info (),
+                                            gnc_numeric_invert(exch));
+            refresh_model_row (info, model, row.get_iter(), row.get_trans_info());
+        }
     }
     g_list_free_full (selected_rows, (GDestroyNotify)gtk_tree_path_free);
     LEAVE("");

commit 3547885e23a95f46dcd6c576b4bdb555e72f2e40
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Wed May 15 18:32:30 2024 +0200

    Bug 799279 - Import Matcher (CSV) does not compute correctly the share amount based on security price - part 1
    
    When modifying the exchange rate in the transaction matcher page
    refresh the modified transactions.

diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp
index 5acc3ba474..9f1997fe00 100644
--- a/gnucash/import-export/import-main-matcher.cpp
+++ b/gnucash/import-export/import-main-matcher.cpp
@@ -1139,6 +1139,7 @@ gnc_gen_trans_set_price_to_selection_cb (GtkMenuItem *menuitem,
             break; /* If the user cancels, return to the payment dialog without changes */
 
         gnc_import_TransInfo_set_price (row.get_trans_info (), exch);
+        refresh_model_row (info, model, row.get_iter(), row.get_trans_info());
     }
     g_list_free_full (selected_rows, (GDestroyNotify)gtk_tree_path_free);
     LEAVE("");



Summary of changes:
 gnucash/import-export/import-main-matcher.cpp | 36 +++++++++++++++++++++------
 1 file changed, 29 insertions(+), 7 deletions(-)



More information about the gnucash-changes mailing list