gnucash stable: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Thu Apr 27 07:48:58 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/b86eb964 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b5ac96f6 (commit)
	from  https://github.com/Gnucash/gnucash/commit/9b22cfc9 (commit)



commit b86eb964767a1f3513f7fcdd8424bdf514eb9e64
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Apr 27 13:47:30 2023 +0200

    Regression: bayesian matching in csv import doesn't find account
    
    This regression was introduced while improving import of
    multi currency transactions.

diff --git a/gnucash/import-export/import-backend.cpp b/gnucash/import-export/import-backend.cpp
index df80be0965..10e465568a 100644
--- a/gnucash/import-export/import-backend.cpp
+++ b/gnucash/import-export/import-backend.cpp
@@ -301,7 +301,11 @@ gnc_import_TransInfo_set_last_split_info (GNCImportTransInfo *info,
             info->lsplit_amount = lsplit->amount;
             info->lsplit_amount_selected_manually = true;
         }
-        info->dest_acc = lsplit->account;
+        /* Bayesian matching may have already set a candidate destination
+         * account. However if the csv data also provides one, the one from the
+         * csv data is preferred. */
+        if (lsplit->account)
+            info->dest_acc = lsplit->account;
         info->lsplit_rec_state = lsplit->rec_state;
         info->lsplit_rec_date = lsplit->rec_date;
     }

commit b5ac96f6d0424738cba7ae47558b9be0585b9fcf
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Apr 27 13:46:18 2023 +0200

    Rename function to align better with what it does

diff --git a/gnucash/import-export/import-main-matcher.c b/gnucash/import-export/import-main-matcher.c
index 9a6c55b1ff..1260d76ae1 100644
--- a/gnucash/import-export/import-main-matcher.c
+++ b/gnucash/import-export/import-main-matcher.c
@@ -2262,11 +2262,13 @@ void gnc_gen_trans_list_add_trans_with_split_data (GNCImportMainMatcher *gui,
     gnc_gen_trans_list_add_trans_internal (gui, trans, 0, lsplit);
 }
 
-/* Query the accounts used by the imported transactions to find a list of
- * candidate matching transactions.
+/* Return a list of splits from already existing transactions for
+ * which the account matches an account used by the transactions to
+ * import. The matching range is also date-limited (configurable
+ * via preferences) to not go too far in the past or future.
  */
 static GList*
-query_imported_transaction_accounts (GNCImportMainMatcher *gui)
+filter_existing_splits_on_account_and_date (GNCImportMainMatcher *gui)
 {
     static const int secs_per_day = 86400;
     gint match_date_limit =
@@ -2312,10 +2314,10 @@ query_imported_transaction_accounts (GNCImportMainMatcher *gui)
  * transactions based on their account and date and organized per account.
  */
 static GHashTable*
-create_hash_of_potential_matches (GList *candidate_txns,
+create_hash_of_potential_matches (GList *candidate_splits,
                                   GHashTable *account_hash)
 {
-    for (GList* candidate = candidate_txns; candidate != NULL;
+    for (GList* candidate = candidate_splits; candidate != NULL;
          candidate = g_list_next (candidate))
     {
         if (gnc_import_split_has_online_id (candidate->data))
@@ -2408,12 +2410,12 @@ gnc_gen_trans_list_create_matches (GNCImportMainMatcher *gui)
         g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
                               (GDestroyNotify)g_slist_free);
     g_assert (gui);
-    GList *candidate_txns = query_imported_transaction_accounts (gui);
+    GList *candidate_splits = filter_existing_splits_on_account_and_date (gui);
 
-    create_hash_of_potential_matches (candidate_txns, account_hash);
+    create_hash_of_potential_matches (candidate_splits, account_hash);
     perform_matching (gui, account_hash);
 
-    g_list_free (candidate_txns);
+    g_list_free (candidate_splits);
     g_hash_table_destroy (account_hash);
     return;
 }



Summary of changes:
 gnucash/import-export/import-backend.cpp    |  6 +++++-
 gnucash/import-export/import-main-matcher.c | 18 ++++++++++--------
 2 files changed, 15 insertions(+), 9 deletions(-)



More information about the gnucash-changes mailing list