X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fhomebank;a=blobdiff_plain;f=src%2Fhb-import.c;fp=src%2Fhb-import.c;h=221a9ab3f6014fd6234584f927cd6118c83d9d9e;hp=276ae6b4ff14c8a961565d24ba73e75668b1c923;hb=59c5e08a64798d4303ae7eb3a2713bc93d98fa7b;hpb=8988b3bef0760b4cab8144715cc3d8f55688861c diff --git a/src/hb-import.c b/src/hb-import.c index 276ae6b..221a9ab 100644 --- a/src/hb-import.c +++ b/src/hb-import.c @@ -1,5 +1,5 @@ /* HomeBank -- Free, easy, personal accounting for everyone. - * Copyright (C) 1995-2014 Maxime DOYEN + * Copyright (C) 1995-2016 Maxime DOYEN * * This file is part of HomeBank. * @@ -20,6 +20,7 @@ #include "homebank.h" #include "hb-import.h" + /****************************************************************************/ /* Debug macros */ /****************************************************************************/ @@ -33,4 +34,54 @@ /* our global datas */ extern struct HomeBank *GLOBALS; +extern struct Preferences *PREFS; + + + + + +Account *import_create_account(gchar *name, gchar *number) +{ +Account *accitem, *existitem; + + //first check we do not have already this imported account + existitem = da_acc_get_by_imp_name(name); + if(existitem != NULL) + return existitem; + + DB( g_print(" ** create acc: '%s' '%s'\n", name, number) ); + + accitem = da_acc_malloc(); + accitem->key = da_acc_get_max_key() + 1; + accitem->pos = da_acc_length() + 1; + + // existing named account ? + existitem = da_acc_get_by_name(name); + if(existitem != NULL) + accitem->imp_key = existitem->key; + + if(!existitem && *name != 0) + accitem->name = g_strdup(name); + else + accitem->name = g_strdup_printf(_("(account %d)"), accitem->key); + + accitem->imp_name = g_strdup(name); + + if(number) + accitem->number = g_strdup(number); + + //fixed 5.1.2 + accitem->kcur = GLOBALS->kcur; + + accitem->imported = TRUE; + da_acc_insert(accitem); + + return accitem; +} + + + + + +