GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-ofx-kvp.c
1 /*******************************************************************\
2  * This program is free software; you can redistribute it and/or *
3  * modify it under the terms of the GNU General Public License as *
4  * published by the Free Software Foundation; either version 2 of *
5  * the License, or (at your option) any later version. *
6  * *
7  * This program is distributed in the hope that it will be useful, *
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
10  * GNU General Public License for more details. *
11  * *
12  * You should have received a copy of the GNU General Public License*
13  * along with this program; if not, contact: *
14  * *
15  * Free Software Foundation Voice: +1-617-542-5942 *
16  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
17  * Boston, MA 02110-1301, USA [email protected] *
18 \********************************************************************/
19 /*
20  * gnc-ofx-kvp.c
21  *
22  * Created on: 13.03.2011
23  * Author: cs
24  */
25 
26 #include "config.h"
27 #include "gnc-ofx-kvp.h"
28 
29 static const char *KEY_ASSOC_INCOME_ACCOUNT = "ofx/associated-income-account";
30 
31 
32 Account *gnc_ofx_kvp_get_assoc_account(const Account* investment_account)
33 {
34  Account *result = NULL;
35  GncGUID *income_guid= NULL;
36  g_assert(investment_account);
37  qof_instance_get (QOF_INSTANCE (investment_account),
38  KEY_ASSOC_INCOME_ACCOUNT, &income_guid,
39  NULL);
40  return xaccAccountLookup(income_guid,
41  gnc_account_get_book(investment_account));
42 }
43 
44 void gnc_ofx_kvp_set_assoc_account(Account* investment_account,
45  const Account *income_account)
46 {
47  const GncGUID * income_acc_guid;
48 
49  g_assert(investment_account);
50  g_assert(income_account);
51 
52  income_acc_guid = xaccAccountGetGUID(income_account);
53  xaccAccountBeginEdit(investment_account);
54  qof_instance_set (QOF_INSTANCE (investment_account),
55  KEY_ASSOC_INCOME_ACCOUNT, income_acc_guid,
56  NULL);
57  xaccAccountCommitEdit(investment_account);
58 }
void qof_instance_get(const QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_get.
void qof_instance_set(QofInstance *inst, const gchar *first_param,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
Definition: guid.h:65
#define xaccAccountGetGUID(X)
Definition: Account.h:239
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321
Account * xaccAccountLookup(const GncGUID *guid, QofBook *book)
Definition: Account.c:1827