gnucash stable: [import-backend.cpp] gnc_import_exists_online_id shouldn't destroy transaction

Christopher Lam clam at code.gnucash.org
Mon Jul 24 11:28:01 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/52b7bdc7 (commit)
	from  https://github.com/Gnucash/gnucash/commit/73a78f70 (commit)



commit 52b7bdc7e9f01419cc2a7926b4eda475daabea9d
Author: Christopher Lam <christopher.lck at gmail.com>
Date:   Mon Jul 24 22:19:46 2023 +0800

    [import-backend.cpp] gnc_import_exists_online_id shouldn't destroy transaction
    
    Because gnc_import_exists_online_id is documented to only check that
    the online_id already exists. It is more appropriate for its caller to
    destroy the transaction.

diff --git a/gnucash/import-export/import-backend.cpp b/gnucash/import-export/import-backend.cpp
index 7943f8603f..7fe944b25a 100644
--- a/gnucash/import-export/import-backend.cpp
+++ b/gnucash/import-export/import-backend.cpp
@@ -1033,15 +1033,6 @@ gboolean gnc_import_exists_online_id (Transaction *trans, GHashTable* acct_id_ha
     }
 
     auto online_id_exists = g_hash_table_contains (online_id_hash, source_online_id);
-    
-    /* If it does, abort the process for this transaction, since it is
-       already in the system. */
-    if (online_id_exists)
-    {
-        DEBUG("%s", "Transaction with same online ID exists, destroying current transaction");
-        xaccTransDestroy(trans);
-        xaccTransCommitEdit(trans);
-    }
     g_free (source_online_id);
     return online_id_exists;
 }
diff --git a/gnucash/import-export/import-main-matcher.cpp b/gnucash/import-export/import-main-matcher.cpp
index 3716bbd492..36d1cad898 100644
--- a/gnucash/import-export/import-main-matcher.cpp
+++ b/gnucash/import-export/import-main-matcher.cpp
@@ -2225,7 +2225,14 @@ gnc_gen_trans_list_add_trans_internal (GNCImportMainMatcher *gui, Transaction *t
     g_assert (trans);
 
     if (gnc_import_exists_online_id (trans, gui->acct_id_hash))
+    {
+        /* If it does, abort the process for this transaction, since
+           it is already in the system. */
+        DEBUG("%s", "Transaction with same online ID exists, destroying current transaction");
+        xaccTransDestroy(trans);
+        xaccTransCommitEdit(trans);
         return;
+    }
 
     Split *split = xaccTransGetSplit (trans, 0);
     Account *acc = xaccSplitGetAccount (split);



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



More information about the gnucash-changes mailing list