GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
qif-defaults.c
1 /*
2  * qif-defaults.c -- QIF Defaults -- default accounts...
3  *
4  * Created by: Derek Atkins <[email protected]>
5  * Copyright (c) 2003 Derek Atkins <[email protected]>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, contact:
19  *
20  * Free Software Foundation Voice: +1-617-542-5942
21  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
22  * Boston, MA 02110-1301, USA [email protected]
23  */
24 
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28 
29 #include <glib.h>
30 #include <glib/gi18n.h>
31 
32 #include "gnc-helpers.h"
33 #include "qif-import-p.h"
34 #include "qif-objects-p.h"
35 #include "qif-defaults.h"
36 
37 
38 static GList *stock_list = NULL;
39 static GList *ext_stock_list = NULL;
40 static GList *income_list = NULL;
41 static GList *expense_list = NULL;
42 static GList *equity_list = NULL;
43 
44 #define RETURN_ACCT(c,n,l) { if (stock_list == NULL) acct_type_init(); \
45  return find_or_make_acct(c, n, l); \
46 }
47 
48 static void
49 acct_type_init(void)
50 {
51  stock_list = qif_parse_acct_type("__stock__", -1);
52  ext_stock_list = qif_parse_acct_type("__extstock__", -1);
53  income_list = qif_parse_acct_type("__income__", -1);
54  expense_list = qif_parse_acct_type("__expense__", -1);
55  equity_list = qif_parse_acct_type("__equity__", -1);
56 }
57 
58 QifAccount qif_default_equity_acct(QifContext ctx)
59 {
60  char *name = g_strdup(_("Retained Earnings"));
61  RETURN_ACCT(ctx, name, equity_list);
62 }
63 
64 QifAccount qif_default_margin_interest_acct(QifContext ctx)
65 {
66  char *name = g_strdup_printf("%s%s%s", _("Margin Interest"),
68  ctx->current_acct->name);
69  RETURN_ACCT(ctx, name, expense_list);
70 }
71 
72 QifAccount qif_default_commission_acct(QifContext ctx)
73 {
74  char *name = g_strdup_printf("%s%s%s", _("Commissions"),
76  ctx->current_acct->name);
77  RETURN_ACCT(ctx, name, expense_list);
78 }
79 
80 QifAccount qif_default_stock_acct(QifContext ctx, const char *security)
81 {
82  char *name = g_strdup_printf("%s%s%s", ctx->current_acct->name,
84  security);
85  RETURN_ACCT(ctx, name, stock_list);
86 }
87 
88 QifAccount qif_default_cglong_acct(QifContext ctx, const char *security)
89 {
90  char *name = g_strdup_printf("%s%s%s%s%s", _("Cap. gain (long)"),
92  ctx->current_acct->name,
94  security);
95  RETURN_ACCT(ctx, name, income_list);
96 }
97 
98 QifAccount qif_default_cgmid_acct(QifContext ctx, const char *security)
99 {
100  char *name = g_strdup_printf("%s%s%s%s%s", _("Cap. gain (mid)"),
102  ctx->current_acct->name,
104  security);
105  RETURN_ACCT(ctx, name, income_list);
106 }
107 
108 QifAccount qif_default_cgshort_acct(QifContext ctx, const char *security)
109 {
110  char *name = g_strdup_printf("%s%s%s%s%s", _("Cap. gain (short)"),
112  ctx->current_acct->name,
114  security);
115  RETURN_ACCT(ctx, name, income_list);
116 }
117 
118 QifAccount qif_default_dividend_acct(QifContext ctx, const char *security)
119 {
120  char *name = g_strdup_printf("%s%s%s%s%s", _("Dividends"),
122  ctx->current_acct->name,
124  security);
125  RETURN_ACCT(ctx, name, income_list);
126 }
127 
128 QifAccount qif_default_interest_acct(QifContext ctx, const char *security)
129 {
130  char *name = g_strdup_printf("%s%s%s%s%s", _("Interest"),
132  ctx->current_acct->name,
134  security);
135  RETURN_ACCT(ctx, name, income_list);
136 }
137 
138 QifAccount qif_default_capital_return_acct(QifContext ctx, const char *security)
139 {
140  char *name = g_strdup_printf("%s%s%s%s%s", _("Cap Return"),
142  ctx->current_acct->name,
144  security);
145  RETURN_ACCT(ctx, name, income_list);
146 }
147 
148 QifAccount qif_default_equity_holding(QifContext ctx, const char *security)
149 {
150  return qif_default_equity_acct(ctx);
151 }
152 
const gchar * gnc_get_account_separator_string(void)
Definition: Account.c:129