GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
import-utilities.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 \********************************************************************/
26 #include "config.h"
27 
28 
29 #include <glib.h>
30 
31 #include <stdlib.h>
32 #include "import-utilities.h"
33 #include "qof.h"
34 #include "Account.h"
35 #include "Transaction.h"
36 
37 
38 /********************************************************************\
39  * Setter and getter functions for the online_id kvp frame in
40  * Account, Transaction and Split
41 \********************************************************************/
42 
43 const gchar * gnc_import_get_acc_online_id (Account * account)
44 {
45  gchar *id = NULL;
46  qof_instance_get (QOF_INSTANCE (account), "online-id", &id, NULL);
47  return id;
48 }
49 
50 /* Used in the midst of editing a transaction; make it save the
51  * account data. */
52 void gnc_import_set_acc_online_id (Account *account, const gchar *id)
53 {
54  g_return_if_fail (account != NULL);
55  xaccAccountBeginEdit (account);
56  qof_instance_set (QOF_INSTANCE (account), "online-id", id, NULL);
57  xaccAccountCommitEdit (account);
58 }
59 
60 const gchar * gnc_import_get_trans_online_id (Transaction * transaction)
61 {
62  gchar *id = NULL;
63  qof_instance_get (QOF_INSTANCE (transaction), "online-id", &id, NULL);
64  return id;
65 }
66 /* Not actually used */
67 void gnc_import_set_trans_online_id (Transaction *transaction,
68  const gchar *id)
69 {
70  g_return_if_fail (transaction != NULL);
71  xaccTransBeginEdit (transaction);
72  qof_instance_set (QOF_INSTANCE (transaction), "online-id", id, NULL);
73  xaccTransCommitEdit (transaction);
74 }
75 
76 gboolean gnc_import_trans_has_online_id(Transaction * transaction)
77 {
78  const gchar * online_id;
79  online_id = gnc_import_get_trans_online_id(transaction);
80  return (online_id != NULL && strlen(online_id) > 0);
81 }
82 
83 const gchar * gnc_import_get_split_online_id (Split * split)
84 {
85  gchar *id = NULL;
86  qof_instance_get (QOF_INSTANCE (split), "online-id", &id, NULL);
87  return id;
88 }
89 /* Used several places in a transaction edit where many other
90  * parameters are also being set, so individual commits wouldn't be
91  * appropriate. Besides, there isn't a function for one.*/
92 void gnc_import_set_split_online_id (Split *split, const gchar *id)
93 {
94  g_return_if_fail (split != NULL);
95  qof_instance_set (QOF_INSTANCE (split), "online-id", id, NULL);
96 }
97 
98 gboolean gnc_import_split_has_online_id(Split * split)
99 {
100  const gchar * online_id;
101  online_id = gnc_import_get_split_online_id(split);
102  return (online_id != NULL && strlen(online_id) > 0);
103 }
104 
105 /* @} */
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.
Account handling public routines.
void xaccTransCommitEdit(Transaction *trans)
Definition: Transaction.c:1579
void xaccTransBeginEdit(Transaction *trans)
Definition: Transaction.c:1380
Definition: SplitP.h:71
void xaccAccountBeginEdit(Account *acc)
Definition: Account.c:1280
Utility functions for writing import modules.
API for Transactions and Splits (journal entries)
void xaccAccountCommitEdit(Account *acc)
Definition: Account.c:1321