GnuCash  5.6-150-g038405b370+
import-backend.h
Go to the documentation of this file.
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 gnu@gnu.org *
18 \********************************************************************/
28 #ifndef IMPORT_BACKEND_H
29 #define IMPORT_BACKEND_H
30 
31 #include "Transaction.h"
32 #include "import-settings.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 typedef struct _transactioninfo GNCImportTransInfo;
39 typedef struct _selected_match_info GNCImportSelectedMatchInfo;
40 typedef struct _matchinfo
41 {
42  Transaction * trans;
43  Split * split;
44  /*GNC_match_probability probability;*/
45  gint probability;
46  gboolean update_proposed;
48 
49 typedef struct _lsplitinfo
50 {
51  gnc_numeric price;
52  const char *action;
53  const char *memo;
54  gnc_numeric amount;
55  Account *account;
56  char rec_state;
57  time64 rec_date;
59 
60 typedef enum _action
61 {
62  GNCImport_SKIP,
63  GNCImport_ADD,
64  GNCImport_CLEAR,
65  GNCImport_UPDATE,
66  GNCImport_LAST_ACTION,
67  GNCImport_INVALID_ACTION
68 } GNCImportAction;
69 
70 /************************************************************************
71  ************************************************************************/
74 
82 gboolean gnc_import_exists_online_id (Transaction *trans, GHashTable* acct_id_hash);
83 
98 void split_find_match (GNCImportTransInfo * trans_info,
99  Split * split,
100  gint display_threshold,
101  gint date_threshold,
102  gint date_not_threshold,
103  double fuzzy_amount_difference);
104 
114 void
115 gnc_import_TransInfo_init_matches (GNCImportTransInfo *trans_info,
116  GNCImportSettings *settings);
117 
135 gboolean
137  GNCImportTransInfo *trans_info);
138 
152 GdkPixbuf* gen_probability_pixbuf (gint score,
153  GNCImportSettings *settings,
154  GtkWidget * widget);
155 
159 /************************************************************************
160  * Getter/Setter Functions for the Data Types.
161  ************************************************************************/
162 
165 
177 GNCImportTransInfo* gnc_import_TransInfo_new(Transaction* trans, Account* base_acc);
178 
180 void gnc_import_TransInfo_delete (GNCImportTransInfo *info);
181 
183 GList *gnc_import_TransInfo_get_match_list (const GNCImportTransInfo *info);
184 
186 void gnc_import_TransInfo_remove_top_match (GNCImportTransInfo *info);
187 
189 Transaction *gnc_import_TransInfo_get_trans (const GNCImportTransInfo *info);
190 
192 gboolean gnc_import_TransInfo_is_balanced (const GNCImportTransInfo *info);
193 
195 Split *gnc_import_TransInfo_get_fsplit (const GNCImportTransInfo *info);
196 
199 gnc_import_TransInfo_get_selected_match (const GNCImportTransInfo *info);
200 
205 void
206 gnc_import_TransInfo_set_selected_match_info (GNCImportTransInfo *info,
207  GNCImportMatchInfo *match,
208  gboolean selected_manually);
209 
211 gboolean
212 gnc_import_TransInfo_get_match_selected_manually (const GNCImportTransInfo *info);
213 
215 GNCImportAction
216 gnc_import_TransInfo_get_action (const GNCImportTransInfo *info);
217 
219 void
220 gnc_import_TransInfo_set_action (GNCImportTransInfo *info,
221  GNCImportAction action);
222 
224 Account *
225 gnc_import_TransInfo_get_destacc (const GNCImportTransInfo *info);
226 
231 void
232 gnc_import_TransInfo_set_destacc (GNCImportTransInfo *info,
233  Account *acc,
234  gboolean selected_manually);
235 
237 gboolean
238 gnc_import_TransInfo_get_destacc_selected_manually (const GNCImportTransInfo *info);
239 
240 
242 guint32
243 gnc_import_TransInfo_get_ref_id (const GNCImportTransInfo *info);
244 
246 void
247 gnc_import_TransInfo_set_ref_id (GNCImportTransInfo *info,
248  guint32 ref_id);
249 
251 gnc_numeric
252 gnc_import_TransInfo_get_price (const GNCImportTransInfo *info);
253 
255 void
256 gnc_import_TransInfo_set_price (GNCImportTransInfo *info,
257  gnc_numeric lprice);
258 
260 gnc_numeric
261 gnc_import_TransInfo_get_dest_amount (const GNCImportTransInfo *info);
262 
264 gnc_numeric
265 gnc_import_TransInfo_get_dest_value (const GNCImportTransInfo *info);
266 
268 void
269 gnc_import_TransInfo_set_last_split_info (GNCImportTransInfo *info,
270  GNCImportLastSplitInfo *lsplit);
271 
273 void
274 gnc_import_TransInfo_set_append_text (GNCImportTransInfo *info,
275  gboolean append_text);
276 
283 Split *
285 
286 
289 gint
293 #ifdef __cplusplus
294 }
295 #endif
296 
297 #endif
298 
gnc_numeric gnc_import_TransInfo_get_dest_value(const GNCImportTransInfo *info)
Returns the destination split value for this TransInfo.
void gnc_import_TransInfo_set_selected_match_info(GNCImportTransInfo *info, GNCImportMatchInfo *match, gboolean selected_manually)
Sets the currently selected match in this TransInfo.
void split_find_match(GNCImportTransInfo *trans_info, Split *split, gint display_threshold, gint date_threshold, gint date_not_threshold, double fuzzy_amount_difference)
The transaction matching heuristics are here.
GdkPixbuf * gen_probability_pixbuf(gint score_original, GNCImportSettings *settings, GtkWidget *widget)
This function generates a new pixmap representing a match score.
void gnc_import_TransInfo_delete(GNCImportTransInfo *info)
Destructor.
STRUCTS.
void gnc_import_TransInfo_set_ref_id(GNCImportTransInfo *info, guint32 ref_id)
Set the reference id for this TransInfo.
GNCImportTransInfo * gnc_import_TransInfo_new(Transaction *trans, Account *base_acc)
Create a new object of GNCImportTransInfo here.
Split * gnc_import_TransInfo_get_fsplit(const GNCImportTransInfo *info)
Returns the first split of the transaction of this TransInfo.
Transaction * gnc_import_TransInfo_get_trans(const GNCImportTransInfo *info)
Returns the transaction of this TransInfo.
void gnc_import_TransInfo_set_destacc(GNCImportTransInfo *info, Account *acc, gboolean selected_manually)
Set the 'other account' of this transaction (used for auto-balance if needed).
Import preference handling.
guint32 gnc_import_TransInfo_get_ref_id(const GNCImportTransInfo *info)
Returns the reference id for this TransInfo.
void gnc_import_TransInfo_init_matches(GNCImportTransInfo *trans_info, GNCImportSettings *settings)
Iterates through all splits of trans_info's originating account match list.
GNCImportAction gnc_import_TransInfo_get_action(const GNCImportTransInfo *info)
Returns the currently selected action for this TransInfo.
Split * gnc_import_MatchInfo_get_split(const GNCImportMatchInfo *info)
Get the split ('this-side split') of this MatchInfo.
gboolean gnc_import_process_trans_item(Account *base_acc, GNCImportTransInfo *trans_info)
/brief – Processes one match according to its selected action.
gint gnc_import_MatchInfo_get_probability(const GNCImportMatchInfo *info)
Get the probability (confidence level) of this MatchInfo.
void gnc_import_TransInfo_set_action(GNCImportTransInfo *info, GNCImportAction action)
Set the action for this TransInfo.
gboolean gnc_import_exists_online_id(Transaction *trans, GHashTable *acct_id_hash)
Checks whether the given transaction's online_id already exists in its parent account.
gnc_numeric gnc_import_TransInfo_get_dest_amount(const GNCImportTransInfo *info)
Returns the destination split amount for this TransInfo.
void gnc_import_TransInfo_set_append_text(GNCImportTransInfo *info, gboolean append_text)
Set the append_text for this TransInfo.
void gnc_import_TransInfo_set_price(GNCImportTransInfo *info, gnc_numeric lprice)
Set the exchange rate for this TransInfo.
gboolean gnc_import_TransInfo_get_match_selected_manually(const GNCImportTransInfo *info)
Returns if the currently selected match was selected by the user.
Account * gnc_import_TransInfo_get_destacc(const GNCImportTransInfo *info)
Returns the 'other account' of this transaction.
gnc_numeric gnc_import_TransInfo_get_price(const GNCImportTransInfo *info)
Returns the exchange rate for this TransInfo.
GList * gnc_import_TransInfo_get_match_list(const GNCImportTransInfo *info)
Returns the stored list of possible matches.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
GNCImportMatchInfo * gnc_import_TransInfo_get_selected_match(const GNCImportTransInfo *info)
Returns the currently selected match in this TransInfo.
void gnc_import_TransInfo_remove_top_match(GNCImportTransInfo *info)
Remove the first match in the list of possible matches.
API for Transactions and Splits (journal entries)
gboolean gnc_import_TransInfo_is_balanced(const GNCImportTransInfo *info)
Returns if the transaction stored in the TransInfo is currently balanced.
void gnc_import_TransInfo_set_last_split_info(GNCImportTransInfo *info, GNCImportLastSplitInfo *lsplit)
Sets additional parameters to be used to generate the closing split.
gboolean gnc_import_TransInfo_get_destacc_selected_manually(const GNCImportTransInfo *info)
Returns if the currently selected destination account for auto-matching was selected by the user...