GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-sx-instance-model.h
Go to the documentation of this file.
1 /*
2  * gnc-sx-instance-model.h
3  *
4  * Copyright (C) 2006 Josh Sled <[email protected]>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 and/or version 3 of the GNU General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, contact:
17  *
18  * Free Software Foundation Voice: +1-617-542-5942
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
20  * Boston, MA 02110-1301, USA [email protected]
21  */
22 
26 #ifndef _GNC_SX_INSTANCE_MODEL_H
27 #define _GNC_SX_INSTANCE_MODEL_H
28 
29 #include "config.h"
30 #include <glib.h>
31 #include <glib-object.h>
32 #include "gnc-numeric.h"
33 #include "SchedXaction.h"
34 
35 G_BEGIN_DECLS
36 
37 #define GNC_TYPE_SX_INSTANCE_MODEL (gnc_sx_instance_model_get_type ())
38 #define GNC_SX_INSTANCE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_SX_INSTANCE_MODEL, GncSxInstanceModel))
39 #define GNC_SX_INSTANCE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_SX_INSTANCE_MODEL, GncSxInstanceModelClass))
40 #define GNC_IS_SX_INSTANCE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_SX_INSTANCE_MODEL))
41 #define GNC_IS_SX_INSTANCE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_SX_INSTANCE_MODEL))
42 #define GNC_SX_INSTANCE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_SX_INSTANCE_MODEL, GncSxInstanceModelClass))
43 
44 typedef struct _GncSxInstanceModel
45 {
46  GObject parent;
47  gboolean disposed;
48 
49  /* private */
50  gint qof_event_handler_id;
51 
52  /* signals */
53  /* void (*added)(SchedXaction *sx); // gpointer user_data */
54  /* void (*updated)(SchedXaction *sx); // gpointer user_data */
55  /* void (*removing)(SchedXaction *sx); // gpointer user_data */
56 
57  /* public */
58  GDate range_end;
59  gboolean include_disabled;
60  GList *sx_instance_list; /* <GncSxInstances*> */
62 
64 {
65  GObjectClass parent;
66 
67  guint removing_signal_id;
68  guint updated_signal_id;
69  guint added_signal_id;
71 
72 typedef struct _GncSxInstances
73 {
74  SchedXaction *sx;
75  GHashTable *variable_names;
76  gboolean variable_names_parsed;
77 
78  GDate next_instance_date;
79 
81  GList *instance_list;
83 
84 typedef enum
85 {
86  SX_INSTANCE_STATE_IGNORED,
87  SX_INSTANCE_STATE_POSTPONED,
88  SX_INSTANCE_STATE_TO_CREATE,
89  SX_INSTANCE_STATE_REMINDER,
90  SX_INSTANCE_STATE_CREATED,
91  SX_INSTANCE_STATE_MAX_STATE
92 } GncSxInstanceState;
93 
94 typedef struct _GncSxVariable
95 {
96  gchar *name;
98  gboolean editable;
100 
101 typedef struct _GncSxInstance
102 {
105  GncSxInstanceState orig_state;
106  GncSxInstanceState state;
107  GDate date;
108  GHashTable *variable_bindings;
109 } GncSxInstance;
110 
111 typedef struct _GncSxVariableNeeded
112 {
113  GncSxInstance *instance;
114  GncSxVariable *variable;
116 
117 GType gnc_sx_instance_model_get_type(void);
118 
121 
128 GncSxInstanceModel* gnc_sx_get_instances(const GDate *range_end, gboolean include_disabled);
129 
137 void gnc_sx_instance_model_remove_sx_instances(GncSxInstanceModel *model, SchedXaction *sx);
138 
141 
142 Account* gnc_sx_get_template_transaction_account(const SchedXaction *sx);
143 
147 GHashTable* gnc_sx_instance_get_variables_for_parser(GHashTable *instance_var_hash);
148 
149 GncSxVariable* gnc_sx_variable_new_full(gchar *name, gnc_numeric value, gboolean editable);
150 void gnc_sx_variable_free(GncSxVariable *var);
151 
179  GncSxInstance *instance,
180  GncSxInstanceState new_state);
181 
182 void gnc_sx_instance_model_set_variable(GncSxInstanceModel *model,
183  GncSxInstance *instance,
184  GncSxVariable *variable,
185  gnc_numeric *new_value);
186 
192 
196  gboolean auto_create_only,
197  GList **created_transaction_guids,
198  GList **creation_errors);
199 
200 typedef struct _GncSxSummary
201 {
202  gboolean need_dialog;
208 } GncSxSummary;
209 
216 
218 void gnc_sx_summary_print(const GncSxSummary *summary);
219 
220 void gnc_sx_get_variables(SchedXaction *sx, GHashTable *var_hash);
221 int gnc_sx_parse_vars_from_formula(const char *formula, GHashTable *var_hash, gnc_numeric *result);
222 void gnc_sx_randomize_variables(GHashTable *vars);
223 
229 GHashTable* gnc_g_hash_new_guid_numeric(void);
230 
239 void gnc_sx_all_instantiate_cashflow(GList *all_sxes,
240  const GDate *range_start, const GDate *range_end,
241  GHashTable* map, GList **creation_errors);
242 
250 GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end);
251 
252 G_END_DECLS
253 
254 #endif // _GNC_SX_INSTANCE_MODEL_H
GHashTable * gnc_g_hash_new_guid_numeric(void)
gint num_auto_create_no_notify_instances
void gnc_sx_instance_model_change_instance_state(GncSxInstanceModel *model, GncSxInstance *instance, GncSxInstanceState new_state)
GHashTable * gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end)
An exact-rational-number library for gnucash. (to be renamed qofnumeric.h in libqof2) ...
GncSxInstanceState orig_state
GHashTable * gnc_sx_instance_get_variables_for_parser(GHashTable *instance_var_hash)
void gnc_sx_instance_model_summarize(GncSxInstanceModel *model, GncSxSummary *summary)
void gnc_sx_instance_model_update_sx_instances(GncSxInstanceModel *model, SchedXaction *sx)
void gnc_sx_instance_model_effect_change(GncSxInstanceModel *model, gboolean auto_create_only, GList **created_transaction_guids, GList **creation_errors)
void gnc_sx_summary_print(const GncSxSummary *summary)
GncSxInstances * parent
void gnc_sx_all_instantiate_cashflow(GList *all_sxes, const GDate *range_start, const GDate *range_end, GHashTable *map, GList **creation_errors)
GList * gnc_sx_instance_get_variables(GncSxInstance *inst)
GHashTable * variable_bindings
GncSxInstanceModel * gnc_sx_get_instances(const GDate *range_end, gboolean include_disabled)
GncSxInstanceState state
GHashTable * variable_names
GncSxInstanceModel * gnc_sx_get_current_instances(void)
Scheduled Transactions public handling routines.
GList * gnc_sx_instance_model_check_variables(GncSxInstanceModel *model)