1 /* HomeBank -- Free, easy, personal accounting for everyone.
2 * Copyright (C) 1995-2019 Maxime DOYEN
4 * This file is part of HomeBank.
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.
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.
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/>.
20 #ifndef __HB_IMPORT_H__
21 #define __HB_IMPORT_H__
23 typedef struct _generic_file GenFile
;
25 typedef struct _generic_acc GenAcc
;
26 typedef struct _generic_split GenSplit
;
27 typedef struct _generic_txn GenTxn
;
30 //those are guin32 special values
31 #define DST_ACC_GLOBAL 100001
32 #define DST_ACC_NEW 100002
33 #define DST_ACC_SKIP 100010
41 const gchar
*encoding
;
44 gboolean invaliddatefmt
;
57 guint32 kacc
; //100001 = NEW, 100002 = SKIP
58 gboolean is_dupcheck
; //if target account was checked for duplicate
60 gboolean is_unamed
; //if src account has no name into file
62 gint n_txnall
; //nb of txn total
63 gint n_txnimp
; //nb of txn to import
64 gint n_txnbaddate
; //nb of txn with bad date
65 gint n_txnduplicate
; //nb of txn with duplicate
79 guint32 kfile
; //todo: remove this
84 gchar
*rawinfo
; //<n/a> ; check_number
85 gchar
*rawpayee
; //P ; name
86 gchar
*rawmemo
; //M ; memo
88 gchar
*date
; //D ; date_posted
89 gchar
*info
; //N ; <rawinfo>
96 gushort paymode
; //<n/a> ; transactiontype
97 gdouble amount
; //T ; amount
98 gboolean reconciled
; //R
102 gboolean is_imp_similar
;
103 gboolean is_dst_similar
;
106 GenSplit splits
[TXN_MAX_SPLIT
];
111 typedef struct _ImportContext ImportContext
;
112 struct _ImportContext
118 guint32 gen_next_acckey
;
120 //to keep track of where we are
127 gboolean curr_acc_isnew
;
135 gboolean opt_qifmemo
;
136 gboolean opt_qifswap
;
137 gboolean opt_ucfirst
;
141 //GList *trans_list; // trn storage
142 //gint next_acc_key; //max key account when start
144 //const gchar *encoding;
146 /*gint nb_src_acc, nb_new_acc;
169 void da_import_context_new(ImportContext
*ctx
);
170 void da_import_context_destroy(ImportContext
*ctx
);
173 GenFile
*da_gen_file_malloc(void);
174 void da_gen_file_free(GenFile
*genfile
);
175 GenFile
*da_gen_file_get(GList
*lst_file
, guint32 key
);
176 GenFile
*da_gen_file_append_from_filename(ImportContext
*ictx
, gchar
*filename
);
178 GenAcc
*da_gen_acc_malloc(void);
179 void da_gen_acc_free(GenAcc
*item
);
180 GenAcc
*da_gen_acc_get_by_key(GList
*lst_acc
, guint32 key
);
182 GenTxn
*da_gen_txn_malloc(void);
183 void da_gen_txn_free(GenTxn
*item
);
184 GList
*da_gen_txn_sort(GList
*list
);
186 void da_gen_txn_destroy(ImportContext
*ctx
);
187 void da_gen_txn_new(ImportContext
*ctx
);
188 void da_gen_txn_move(GenTxn
*sitem
, GenTxn
*ditem
);
189 void da_gen_txn_append(ImportContext
*ctx
, GenTxn
*item
);
191 gchar
*hb_import_filetype_char_get(GenAcc
*acc
);
193 GenAcc
*hb_import_gen_acc_get_next(ImportContext
*ictx
, gint filetype
, gchar
*name
, gchar
*number
);
194 gint
hb_import_gen_acc_count_txn(ImportContext
*ictx
, GenAcc
*genacc
);
196 Transaction
*hb_import_convert_txn(GenAcc
*genacc
, GenTxn
*gentxn
);
199 void hb_import_load_all(ImportContext
*ictx
);
200 gint
hb_import_gen_txn_check_target_similar(ImportContext
*ictx
, GenAcc
*genacc
);
201 gint
hb_import_gen_txn_check_duplicate(ImportContext
*ictx
, GenAcc
*genacc
);
203 gint
hb_import_option_apply(ImportContext
*ictx
, GenAcc
*genacc
);
205 Account
*import_create_account(gchar
*name
, gchar
*number
);
206 Account
*hb_import_acc_find_existing(gchar
*name
, gchar
*number
);
209 void hb_import_apply(ImportContext
*ictx
);
211 GList
*homebank_csv_import(ImportContext
*ictx
, GenFile
*genfile
);
212 GList
*homebank_ofx_import(ImportContext
*ictx
, GenFile
*genfile
);
213 GList
*homebank_qif_import(ImportContext
*ictx
, GenFile
*genfile
);
215 GList
*account_import_qif(gchar
*filename
, ImportContext
*ictx
);
216 gdouble
hb_qif_parser_get_amount(gchar
*string
);
218 gboolean
hb_csv_row_valid(gchar
**str_array
, guint nbcolumns
, gint
*csvtype
);
219 gchar
**hb_csv_row_get(gchar
*string
, gchar
*delimiter
, gint max_tokens
);
222 void _import_context_debug_file_list(ImportContext
*ctx
);
223 void _import_context_debug_acc_list(ImportContext
*ctx
);
224 void _import_context_debug_txn_list(ImportContext
*ctx
);