|
GnuCash 2.4.99
|
00001 /* 00002 * gnc-sx-instance-model.h 00003 * 00004 * Copyright (C) 2006 Josh Sled <jsled@asynchronous.org> 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of version 2 and/or version 3 of the GNU General Public 00008 * License as published by the Free Software Foundation. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, contact: 00017 * 00018 * Free Software Foundation Voice: +1-617-542-5942 00019 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 00020 * Boston, MA 02110-1301, USA gnu@gnu.org 00021 */ 00022 00026 #ifndef _GNC_SX_INSTANCE_MODEL_H 00027 #define _GNC_SX_INSTANCE_MODEL_H 00028 00029 #include "config.h" 00030 #include <glib.h> 00031 #include <glib-object.h> 00032 #include "gnc-numeric.h" 00033 #include "SchedXaction.h" 00034 00035 G_BEGIN_DECLS 00036 00037 #define GNC_TYPE_SX_INSTANCE_MODEL (gnc_sx_instance_model_get_type ()) 00038 #define GNC_SX_INSTANCE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_SX_INSTANCE_MODEL, GncSxInstanceModel)) 00039 #define GNC_SX_INSTANCE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_SX_INSTANCE_MODEL, GncSxInstanceModelClass)) 00040 #define GNC_IS_SX_INSTANCE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_SX_INSTANCE_MODEL)) 00041 #define GNC_IS_SX_INSTANCE_MODEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_SX_INSTANCE_MODEL)) 00042 #define GNC_SX_INSTANCE_MODEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_SX_INSTANCE_MODEL, GncSxInstanceModelClass)) 00043 00044 typedef struct _GncSxInstanceModel 00045 { 00046 GObject parent; 00047 gboolean disposed; 00048 00049 /* private */ 00050 gint qof_event_handler_id; 00051 00052 /* signals */ 00053 /* void (*added)(SchedXaction *sx); // gpointer user_data */ 00054 /* void (*updated)(SchedXaction *sx); // gpointer user_data */ 00055 /* void (*removing)(SchedXaction *sx); // gpointer user_data */ 00056 00057 /* public */ 00058 GDate range_end; 00059 gboolean include_disabled; 00060 GList *sx_instance_list; /* <GncSxInstances*> */ 00061 } GncSxInstanceModel; 00062 00063 typedef struct _GncSxInstanceModelClass 00064 { 00065 GObjectClass parent; 00066 00067 guint removing_signal_id; 00068 guint updated_signal_id; 00069 guint added_signal_id; 00070 } GncSxInstanceModelClass; 00071 00072 typedef struct _GncSxInstances 00073 { 00074 SchedXaction *sx; 00075 GHashTable *variable_names; 00076 gboolean variable_names_parsed; 00077 00078 GDate next_instance_date; 00079 00081 GList *instance_list; 00082 } GncSxInstances; 00083 00084 typedef enum 00085 { 00086 SX_INSTANCE_STATE_IGNORED, 00087 SX_INSTANCE_STATE_POSTPONED, 00088 SX_INSTANCE_STATE_TO_CREATE, 00089 SX_INSTANCE_STATE_REMINDER, 00090 SX_INSTANCE_STATE_CREATED, 00091 SX_INSTANCE_STATE_MAX_STATE 00092 } GncSxInstanceState; 00093 00094 typedef struct _GncSxVariable 00095 { 00096 gchar *name; 00097 gnc_numeric value; 00098 gboolean editable; 00099 } GncSxVariable; 00100 00101 typedef struct _GncSxInstance 00102 { 00103 GncSxInstances *parent; 00104 void *temporal_state; 00105 GncSxInstanceState orig_state; 00106 GncSxInstanceState state; 00107 GDate date; 00108 GHashTable *variable_bindings; 00109 } GncSxInstance; 00110 00111 typedef struct _GncSxVariableNeeded 00112 { 00113 GncSxInstance *instance; 00114 GncSxVariable *variable; 00115 } GncSxVariableNeeded; 00116 00117 GType gnc_sx_instance_model_get_type(void); 00118 00120 GncSxInstanceModel* gnc_sx_get_current_instances(void); 00121 00128 GncSxInstanceModel* gnc_sx_get_instances(const GDate *range_end, gboolean include_disabled); 00129 00136 void gnc_sx_instance_model_update_sx_instances(GncSxInstanceModel *model, SchedXaction *sx); 00137 void gnc_sx_instance_model_remove_sx_instances(GncSxInstanceModel *model, SchedXaction *sx); 00138 00140 GList *gnc_sx_instance_get_variables(GncSxInstance *inst); 00141 00142 Account* gnc_sx_get_template_transaction_account(const SchedXaction *sx); 00143 00147 GHashTable* gnc_sx_instance_get_variables_for_parser(GHashTable *instance_var_hash); 00148 00149 GncSxVariable* gnc_sx_variable_new_full(gchar *name, gnc_numeric value, gboolean editable); 00150 void gnc_sx_variable_free(GncSxVariable *var); 00151 00178 void gnc_sx_instance_model_change_instance_state(GncSxInstanceModel *model, 00179 GncSxInstance *instance, 00180 GncSxInstanceState new_state); 00181 00182 void gnc_sx_instance_model_set_variable(GncSxInstanceModel *model, 00183 GncSxInstance *instance, 00184 GncSxVariable *variable, 00185 gnc_numeric *new_value); 00186 00191 GList* gnc_sx_instance_model_check_variables(GncSxInstanceModel *model); 00192 00195 void gnc_sx_instance_model_effect_change(GncSxInstanceModel *model, 00196 gboolean auto_create_only, 00197 GList **created_transaction_guids, 00198 GList **creation_errors); 00199 00200 typedef struct _GncSxSummary 00201 { 00202 gboolean need_dialog; 00204 gint num_instances; 00205 gint num_to_create_instances; 00206 gint num_auto_create_instances; 00207 gint num_auto_create_no_notify_instances; 00208 } GncSxSummary; 00209 00215 void gnc_sx_instance_model_summarize(GncSxInstanceModel *model, GncSxSummary *summary); 00216 00218 void gnc_sx_summary_print(const GncSxSummary *summary); 00219 00220 void gnc_sx_get_variables(SchedXaction *sx, GHashTable *var_hash); 00221 int gnc_sx_parse_vars_from_formula(const char *formula, GHashTable *var_hash, gnc_numeric *result); 00222 void gnc_sx_randomize_variables(GHashTable *vars); 00223 00229 GHashTable* gnc_g_hash_new_guid_numeric(void); 00230 00239 void gnc_sx_all_instantiate_cashflow(GList *all_sxes, 00240 const GDate *range_start, const GDate *range_end, 00241 GHashTable* map, GList **creation_errors); 00242 00250 GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end); 00251 00252 G_END_DECLS 00253 00254 #endif // _GNC_SX_INSTANCE_MODEL_H
1.7.4