]> Dogcows Code - chaz/homebank/blob - src/hb-import.c
Merge branch 'upstream'
[chaz/homebank] / src / hb-import.c
1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2016 Maxime DOYEN
3 *
4 * This file is part of HomeBank.
5 *
6 * HomeBank is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * HomeBank is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "homebank.h"
21 #include "hb-import.h"
22
23
24 /****************************************************************************/
25 /* Debug macros */
26 /****************************************************************************/
27 #define MYDEBUG 0
28
29 #if MYDEBUG
30 #define DB(x) (x);
31 #else
32 #define DB(x);
33 #endif
34
35 /* our global datas */
36 extern struct HomeBank *GLOBALS;
37 extern struct Preferences *PREFS;
38
39
40
41
42
43 Account *import_create_account(gchar *name, gchar *number)
44 {
45 Account *accitem, *existitem;
46
47 //first check we do not have already this imported account
48 existitem = da_acc_get_by_imp_name(name);
49 if(existitem != NULL)
50 return existitem;
51
52 DB( g_print(" ** create acc: '%s' '%s'\n", name, number) );
53
54 accitem = da_acc_malloc();
55 accitem->key = da_acc_get_max_key() + 1;
56 accitem->pos = da_acc_length() + 1;
57
58 // existing named account ?
59 existitem = da_acc_get_by_name(name);
60 if(existitem != NULL)
61 accitem->imp_key = existitem->key;
62
63 if(!existitem && *name != 0)
64 accitem->name = g_strdup(name);
65 else
66 accitem->name = g_strdup_printf(_("(account %d)"), accitem->key);
67
68 accitem->imp_name = g_strdup(name);
69
70 if(number)
71 accitem->number = g_strdup(number);
72
73 //fixed 5.1.2
74 accitem->kcur = GLOBALS->kcur;
75
76 accitem->imported = TRUE;
77 da_acc_insert(accitem);
78
79 return accitem;
80 }
81
82
83
84
85
86
87
This page took 0.0314 seconds and 4 git commands to generate.