GnuCash c935c2f+
Loading...
Searching...
No Matches
import-settings.cpp
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\********************************************************************/
27#include <config.h>
28
29#include <glib.h>
30
31#include "import-settings.h"
32#include "gnc-prefs.h"
33
34/********************************************************************\
35 * Default values for user prefs (or values for unimplemented prefs.*
36 * If you modify the value of any of these, you must do the same in *
37 * generic-import.scm *
38\********************************************************************/
39
40static const int DEFAULT_ACTION_ADD_ENABLED = TRUE;
41static const int DEFAULT_ACTION_CLEAR_ENABLED = TRUE;
42
43/********************************************************************\
44 * Structures passed between the functions *
45\********************************************************************/
46
48{
49
50 gboolean action_skip_enabled;
51 gboolean action_update_enabled;
52 gboolean action_add_enabled;
53 gboolean action_clear_enabled;
54
73 gint match_date_hardlimit;
74};
75
76
77/************************************************************************
78 * Getter/Setter Functions for the Data Types.
79 ************************************************************************/
80/* Constructor */
81GNCImportSettings *
83{
84 GNCImportSettings * settings;
85
86 settings = g_new0 ( GNCImportSettings, 1);
87
88
89 settings->action_skip_enabled =
90 gnc_prefs_get_bool (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ENABLE_SKIP);
91 settings->action_update_enabled =
92 gnc_prefs_get_bool (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ENABLE_UPDATE);
93 settings->action_add_enabled = DEFAULT_ACTION_ADD_ENABLED;
94 settings->action_clear_enabled = DEFAULT_ACTION_CLEAR_ENABLED;
95 settings->clear_threshold =
96 (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_AUTO_CLEAR_THRESHOLD);
97 settings->add_threshold =
98 (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_AUTO_ADD_THRESHOLD);
99 settings->display_threshold =
100 (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_MATCH_THRESHOLD);
101 settings->date_threshold =
102 (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_MATCH_DATE_THRESHOLD);
103 settings->date_not_threshold =
104 (int)gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_MATCH_DATE_NOT_THRESHOLD);
105 settings->fuzzy_amount =
106 gnc_prefs_get_float (GNC_PREFS_GROUP_IMPORT, GNC_PREF_ATM_FEE_THRESHOLD);
107
108 settings->match_date_hardlimit = 42; /* 6 weeks */
109 return settings;
110}
111
112/* Destructor */
113void gnc_import_Settings_delete (GNCImportSettings *settings)
114{
115 if (settings)
116 {
117 g_free(settings);
118 }
119}
120
121double
122gnc_import_Settings_get_fuzzy_amount (GNCImportSettings *settings)
123{
124 g_assert (settings);
125 return settings->fuzzy_amount;
126}
127
128gboolean gnc_import_Settings_get_action_skip_enabled (GNCImportSettings *settings)
129{
130 g_assert (settings);
131 return settings->action_skip_enabled;
132}
133
134gboolean gnc_import_Settings_get_action_add_enabled (GNCImportSettings *settings)
135{
136 g_assert (settings);
137 return settings->action_add_enabled;
138}
139
140gboolean gnc_import_Settings_get_action_update_enabled (GNCImportSettings *settings)
141{
142 g_assert (settings);
143 return settings->action_update_enabled;
144}
145
146gboolean gnc_import_Settings_get_action_clear_enabled (GNCImportSettings *settings)
147{
148 g_assert (settings);
149 return settings->action_clear_enabled;
150}
151
152gint gnc_import_Settings_get_clear_threshold (GNCImportSettings *settings)
153{
154 g_assert (settings);
155 return settings->clear_threshold;
156}
157
158gint gnc_import_Settings_get_add_threshold (GNCImportSettings *settings)
159{
160 g_assert (settings);
161 return settings->add_threshold;
162}
163
164gint gnc_import_Settings_get_display_threshold (GNCImportSettings *settings)
165{
166 g_assert (settings);
167 return settings->display_threshold;
168}
169
170gint gnc_import_Settings_get_date_threshold (GNCImportSettings *settings)
171{
172 g_assert (settings);
173 return settings->date_threshold;
174}
175
176gint gnc_import_Settings_get_date_not_threshold (GNCImportSettings *settings)
177{
178 g_assert (settings);
179 return settings->date_not_threshold;
180}
181
182void gnc_import_Settings_set_match_date_hardlimit (GNCImportSettings *s, gint m)
183{
184 g_assert(s);
185 s->match_date_hardlimit = m;
186}
187
188gint gnc_import_Settings_get_match_date_hardlimit (const GNCImportSettings *s)
189{
190 g_assert(s);
191 return s->match_date_hardlimit;
192}
193
Generic api to store and retrieve preferences.
gint gnc_import_Settings_get_add_threshold(GNCImportSettings *settings)
Return the selected threshold.
gboolean gnc_import_Settings_get_action_update_enabled(GNCImportSettings *settings)
Return the selected action is enable state.
gboolean gnc_import_Settings_get_action_clear_enabled(GNCImportSettings *settings)
Return the selected action is enable state.
GNCImportSettings * gnc_import_Settings_new(void)
Allocates a new GNCImportSettings object, and initialize it with the appropriate user prefs.
gint gnc_import_Settings_get_match_date_hardlimit(const GNCImportSettings *s)
Returns the hard-limiting number of days that a matching split may differ.
gboolean gnc_import_Settings_get_action_skip_enabled(GNCImportSettings *settings)
Return the selected action is enable state.
void gnc_import_Settings_delete(GNCImportSettings *settings)
Destructor.
void gnc_import_Settings_set_match_date_hardlimit(GNCImportSettings *s, gint m)
gint gnc_import_Settings_get_clear_threshold(GNCImportSettings *settings)
Return the selected threshold.
gboolean gnc_import_Settings_get_action_add_enabled(GNCImportSettings *settings)
Return the selected action is enable state.
gint gnc_import_Settings_get_display_threshold(GNCImportSettings *settings)
Return the selected threshold.
#define GNC_PREFS_GROUP_IMPORT
The preferences used by the importer.
double gnc_import_Settings_get_fuzzy_amount(GNCImportSettings *settings)
Return the allowed amount range for fuzzy amount matching.
gdouble gnc_prefs_get_float(const gchar *group, const gchar *pref_name)
Get an float value from the preferences backend.
gboolean gnc_prefs_get_bool(const gchar *group, const gchar *pref_name)
Get a boolean value from the preferences backend.
Import preference handling.
int date_threshold
Transaction who's date is within threshold is likely match.
int display_threshold
Transaction's match probability must be at least this much to be displayed in the match list.
double fuzzy_amount
The allowed amount range for fuzzy amount matching, in the users default commodity.
int clear_threshold
Transaction who's best match probability is equal or higher than this will reconcile their best match...
int add_threshold
Transaction who's best match probability is below or equal to this will be added as new by default.
int date_not_threshold
Transaction who's date is outside threshold is an unlikely match.