From 52b7bdc7e9f01419cc2a7926b4eda475daabea9d Mon Sep 17 00:00:00 2001 From: Christopher Lam Date: Mon, 24 Jul 2023 22:19:46 +0800 Subject: [PATCH] [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. --- gnucash/import-export/import-backend.cpp | 9 --------- gnucash/import-export/import-main-matcher.cpp | 7 +++++++ 2 files changed, 7 insertions(+), 9 deletions(-) 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);