From 614e6f347fd8401909bdc8f1c9405b6dc886c2f0 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sat, 9 Mar 2013 10:22:18 +0000 Subject: [PATCH] Bug #695423: Fix OFX Commodity Account handling. Patch by Burke. BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22825 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/import-export/ofx/gnc-ofx-import.c | 32 +++++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/import-export/ofx/gnc-ofx-import.c b/src/import-export/ofx/gnc-ofx-import.c index ed74eea609..23505430e9 100644 --- a/src/import-export/ofx/gnc-ofx-import.c +++ b/src/import-export/ofx/gnc-ofx-import.c @@ -318,7 +318,10 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_u Account *account; Account *investment_account = NULL; Account *income_account = NULL; - gchar *investment_account_text; +/***CPC 20130207 ref: OFX Commodity Account Patch, Burke*** + gchar *investment_account_text;************************/ +/***CPC 20130207 ref: OFX Commodity Account Patch, Burke***/ + gchar *investment_account_text, *investment_account_onlineid; gnc_commodity *currency = NULL; gnc_commodity *investment_commodity = NULL; gnc_numeric gnc_amount, gnc_units; @@ -531,13 +534,28 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_u in any translations. */ _("Stock account for security \"%s\""), data.security_data_ptr->secname); +/***CPC 20130207 ref: OFX Commodity Account Patch, Burke***/ + investment_account_onlineid = g_strdup_printf( "%s%s", data.account_id, data.unique_id); - // @FIXME: Add the automated selection or creation of account here! +/***CPC 20130207 ref: OFX Commodity Account Patch, Burke*** +* // @FIXME: Add the automated selection or creation of account here! +* +* // First check whether we can find the right investment_account without asking the user +* investment_account = gnc_import_select_account(NULL, +* data.unique_id, FALSE, investment_account_text, +* investment_commodity, ACCT_TYPE_STOCK, NULL, NULL); +***********************************************************/ + +/***CPC 20130207 ref: OFX Commodity Account Patch, Burke***/ + investment_account = gnc_import_select_account(NULL, + investment_account_onlineid, + 1, + investment_account_text, + investment_commodity, + ACCT_TYPE_STOCK, + NULL, + NULL); - // First check whether we can find the right investment_account without asking the user - investment_account = gnc_import_select_account(NULL, - data.unique_id, FALSE, investment_account_text, - investment_commodity, ACCT_TYPE_STOCK, NULL, NULL); // but use it only if that's really the right commodity if (investment_account && xaccAccountGetCommodity(investment_account) != investment_commodity) @@ -622,6 +640,8 @@ int ofx_proc_transaction_cb(struct OfxTransactionData data, void * transaction_u PERR("No investment account found for text: %s\n", investment_account_text); } g_free (investment_account_text); +/***CPC 20130207 ref: OFX Commodity Account Patch, Burke***/ + g_free (investment_account_onlineid); investment_account_text = NULL; if (investment_account != NULL &&