gnucash maint: Bug 796756 - OFX import fails to recognize associated income accounts.
John Ralls
jralls at code.gnucash.org
Fri Jul 13 14:47:04 EDT 2018
Updated via https://github.com/Gnucash/gnucash/commit/9db7d894 (commit)
from https://github.com/Gnucash/gnucash/commit/983c7ce0 (commit)
commit 9db7d89474ce8133bf8459b514297ab081881c7b
Author: John Ralls <jralls at ceridwen.us>
Date: Fri Jul 13 11:46:50 2018 -0700
Bug 796756 - OFX import fails to recognize associated income accounts.
Because qof_instance_set and qof_instance_get were being called with the
KVP key instead of the property name.
Since we don't really want references to KVP outside of engine and since
the two functions are called exactly once each in qof-ofx-import.c move
them inside qof-ofx-import.c and get rid of gnc-ofx-kvp.[ch] as well as
fix the bug.
diff --git a/gnucash/import-export/ofx/CMakeLists.txt b/gnucash/import-export/ofx/CMakeLists.txt
index ffabfd1..0d1ea93 100644
--- a/gnucash/import-export/ofx/CMakeLists.txt
+++ b/gnucash/import-export/ofx/CMakeLists.txt
@@ -3,7 +3,6 @@ add_subdirectory(test)
set(ofx_SOURCES
gnc-ofx-import.c
- gnc-ofx-kvp.c
gncmod-ofx-import.c
gnc-plugin-ofx.c
)
@@ -13,7 +12,6 @@ set_source_files_properties (${ofx_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H
set(ofx_noinst_HEADERS
gnc-ofx-import.h
- gnc-ofx-kvp.h
gnc-plugin-ofx.h
)
diff --git a/gnucash/import-export/ofx/gnc-ofx-import.c b/gnucash/import-export/ofx/gnc-ofx-import.c
index b8df83e..d7c927b 100644
--- a/gnucash/import-export/ofx/gnc-ofx-import.c
+++ b/gnucash/import-export/ofx/gnc-ofx-import.c
@@ -51,8 +51,6 @@
#include "dialog-account.h"
#include "dialog-utils.h"
-#include "gnc-ofx-kvp.h"
-
#define GNC_PREFS_GROUP "dialogs.import.ofx"
#define GNC_PREF_AUTO_COMMODITY "auto-create-commodity"
@@ -78,6 +76,36 @@ int ofx_proc_status_cb(struct OfxStatusData data)
}
*/
+static const char *PROP_OFX_INCOME_ACCOUNT = "ofx-income-account";
+
+static Account*
+get_associated_income_account(const Account* investment_account)
+{
+ GncGUID *income_guid= NULL;
+ g_assert(investment_account);
+ qof_instance_get (QOF_INSTANCE (investment_account),
+ PROP_OFX_INCOME_ACCOUNT, &income_guid,
+ NULL);
+ return xaccAccountLookup(income_guid,
+ gnc_account_get_book(investment_account));
+}
+
+void set_associated_income_account(Account* investment_account,
+ const Account *income_account)
+{
+ const GncGUID * income_acc_guid;
+
+ g_assert(investment_account);
+ g_assert(income_account);
+
+ income_acc_guid = xaccAccountGetGUID(income_account);
+ xaccAccountBeginEdit(investment_account);
+ qof_instance_set (QOF_INSTANCE (investment_account),
+ PROP_OFX_INCOME_ACCOUNT, income_acc_guid,
+ NULL);
+ xaccAccountCommitEdit(investment_account);
+}
+
int ofx_proc_security_cb(const struct OfxSecurityData data, void * security_user_data);
int ofx_proc_transaction_cb (struct OfxTransactionData data, void *user_data);
int ofx_proc_account_cb(struct OfxAccountData data, void * account_user_data);
@@ -756,7 +784,8 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
{
DEBUG("Now let's find an account for the destination split");
- income_account = gnc_ofx_kvp_get_assoc_account(investment_account);
+ income_account =
+ get_associated_income_account(investment_account);
if (income_account == NULL)
{
@@ -778,7 +807,7 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void *user_data)
NULL);
if (income_account != NULL)
{
- gnc_ofx_kvp_set_assoc_account(investment_account,
+ set_associated_income_account(investment_account,
income_account);
DEBUG("KVP written");
}
diff --git a/gnucash/import-export/ofx/gnc-ofx-kvp.c b/gnucash/import-export/ofx/gnc-ofx-kvp.c
deleted file mode 100644
index 0eb456d..0000000
--- a/gnucash/import-export/ofx/gnc-ofx-kvp.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************\
- * This program is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU General Public License as *
- * published by the Free Software Foundation; either version 2 of *
- * the License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact: *
- * *
- * Free Software Foundation Voice: +1-617-542-5942 *
- * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
- * Boston, MA 02110-1301, USA gnu at gnu.org *
-\********************************************************************/
-/*
- * gnc-ofx-kvp.c
- *
- * Created on: 13.03.2011
- * Author: cs
- */
-
-#include <config.h>
-#include "gnc-ofx-kvp.h"
-
-static const char *KEY_ASSOC_INCOME_ACCOUNT = "ofx/associated-income-account";
-
-
-Account *gnc_ofx_kvp_get_assoc_account(const Account* investment_account)
-{
- GncGUID *income_guid= NULL;
- g_assert(investment_account);
- qof_instance_get (QOF_INSTANCE (investment_account),
- KEY_ASSOC_INCOME_ACCOUNT, &income_guid,
- NULL);
- return xaccAccountLookup(income_guid,
- gnc_account_get_book(investment_account));
-}
-
-void gnc_ofx_kvp_set_assoc_account(Account* investment_account,
- const Account *income_account)
-{
- const GncGUID * income_acc_guid;
-
- g_assert(investment_account);
- g_assert(income_account);
-
- income_acc_guid = xaccAccountGetGUID(income_account);
- xaccAccountBeginEdit(investment_account);
- qof_instance_set (QOF_INSTANCE (investment_account),
- KEY_ASSOC_INCOME_ACCOUNT, income_acc_guid,
- NULL);
- xaccAccountCommitEdit(investment_account);
-}
diff --git a/gnucash/import-export/ofx/gnc-ofx-kvp.h b/gnucash/import-export/ofx/gnc-ofx-kvp.h
deleted file mode 100644
index 58cd36a..0000000
--- a/gnucash/import-export/ofx/gnc-ofx-kvp.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************\
- * This program is free software; you can redistribute it and/or *
- * modify it under the terms of the GNU General Public License as *
- * published by the Free Software Foundation; either version 2 of *
- * the License, or (at your option) any later version. *
- * *
- * This program is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. *
- * *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact: *
- * *
- * Free Software Foundation Voice: +1-617-542-5942 *
- * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
- * Boston, MA 02110-1301, USA gnu at gnu.org *
-\********************************************************************/
-/*
- * gnc-ofx-kvp.h
- *
- * Created on: 13.03.2011
- * Author: cs
- */
-
-#ifndef GNC_OFX_KVP_H_
-#define GNC_OFX_KVP_H_
-
-#include <glib.h>
-#include <Account.h>
-
-Account *gnc_ofx_kvp_get_assoc_account(const Account* investment_account);
-
-void gnc_ofx_kvp_set_assoc_account(Account* investment_account,
- const Account *associated_income_accout);
-
-
-#endif /* GNC_OFX_CONVERSIONS_H_ */
Summary of changes:
gnucash/import-export/ofx/CMakeLists.txt | 2 --
gnucash/import-export/ofx/gnc-ofx-import.c | 37 ++++++++++++++++---
gnucash/import-export/ofx/gnc-ofx-kvp.c | 57 ------------------------------
gnucash/import-export/ofx/gnc-ofx-kvp.h | 38 --------------------
4 files changed, 33 insertions(+), 101 deletions(-)
delete mode 100644 gnucash/import-export/ofx/gnc-ofx-kvp.c
delete mode 100644 gnucash/import-export/ofx/gnc-ofx-kvp.h
More information about the gnucash-changes
mailing list