GnuCash c935c2f+
Loading...
Searching...
No Matches
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 <jsled@asynchronous.org>
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 gnu@gnu.org
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
35G_BEGIN_DECLS
36
37#define GNC_TYPE_SX_INSTANCE_MODEL (gnc_sx_instance_model_get_type ())
38G_DECLARE_FINAL_TYPE (GncSxInstanceModel, gnc_sx_instance_model, GNC, SX_INSTANCE_MODEL, GObject)
39
40typedef struct _GncSxInstances
41{
42 SchedXaction *sx;
43 GHashTable *variable_names;
44 gboolean variable_names_parsed;
45
46 GDate next_instance_date;
47
51
52typedef enum
53{
54 SX_INSTANCE_STATE_IGNORED,
55 SX_INSTANCE_STATE_POSTPONED,
56 SX_INSTANCE_STATE_TO_CREATE,
57 SX_INSTANCE_STATE_REMINDER,
58 SX_INSTANCE_STATE_CREATED,
59 SX_INSTANCE_STATE_MAX_STATE
60} GncSxInstanceState;
61
62typedef struct _GncSxVariable
63{
64 gchar *name;
65 gnc_numeric value;
66 gboolean editable;
68
69typedef struct _GncSxInstance
70{
73 GncSxInstanceState orig_state;
74 GncSxInstanceState state;
75 GDate date;
76 GHashTable *variable_bindings;
78
79typedef struct _GncSxVariableNeeded
80{
81 GncSxInstance *instance;
82 GncSxVariable *variable;
84
86GncSxInstanceModel* gnc_sx_get_current_instances(void);
87
94GncSxInstanceModel* gnc_sx_get_instances(const GDate *range_end, gboolean include_disabled);
95
103GncSxInstanceModel* gnc_sx_get_select_instances(GList *sel_sxes);
104
111void gnc_sx_instance_model_update_sx_instances(GncSxInstanceModel *model, SchedXaction *sx);
112void gnc_sx_instance_model_remove_sx_instances(GncSxInstanceModel *model, SchedXaction *sx);
113
119void gnc_sx_scrub_split_numerics (gpointer psplit, gpointer user);
120
123
124Account* gnc_sx_get_template_transaction_account(const SchedXaction *sx);
125
129GHashTable* gnc_sx_instance_get_variables_for_parser(GHashTable *instance_var_hash);
130
131GncSxVariable* gnc_sx_variable_new_full(gchar *name, gnc_numeric value, gboolean editable);
132void gnc_sx_variable_free(GncSxVariable *var);
133
160void gnc_sx_instance_model_change_instance_state(GncSxInstanceModel *model,
161 GncSxInstance *instance,
162 GncSxInstanceState new_state);
163
164void gnc_sx_instance_model_set_variable(GncSxInstanceModel *model,
165 GncSxInstance *instance,
166 GncSxVariable *variable,
167 gnc_numeric *new_value);
168
173GList* gnc_sx_instance_model_check_variables(GncSxInstanceModel *model);
174
177void gnc_sx_instance_model_effect_change(GncSxInstanceModel *model,
178 gboolean auto_create_only,
179 GList **created_transaction_guids,
180 GList **creation_errors);
181
191
197void gnc_sx_instance_model_summarize(GncSxInstanceModel *model, GncSxSummary *summary);
198
200void gnc_sx_summary_print(const GncSxSummary *summary);
201
202void gnc_sx_get_variables(SchedXaction *sx, GHashTable *var_hash);
203int gnc_sx_parse_vars_from_formula(const char *formula, GHashTable *var_hash, gnc_numeric *result);
204void gnc_sx_randomize_variables(GHashTable *vars);
205
211GHashTable* gnc_g_hash_new_guid_numeric(void);
212
221void gnc_sx_all_instantiate_cashflow(GList *all_sxes,
222 const GDate *range_start, const GDate *range_end,
223 GHashTable* map, GList **creation_errors);
224
232GHashTable* gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end);
233
239GList *gnc_sx_instance_model_get_sx_instances_list (GncSxInstanceModel *model);
240
241G_END_DECLS
242
243
244#endif // _GNC_SX_INSTANCE_MODEL_H
Scheduled Transactions public handling routines.
An exact-rational-number library for gnucash.
void gnc_sx_instance_model_update_sx_instances(GncSxInstanceModel *model, SchedXaction *sx)
Regenerates and updates the GncSxInstances* for the given SX.
GList * gnc_sx_instance_model_check_variables(GncSxInstanceModel *model)
GList * gnc_sx_instance_model_get_sx_instances_list(GncSxInstanceModel *model)
Returns the list of GncSxInstances in the model (Each element in the list has type GncSxInstances)
GncSxInstanceModel * gnc_sx_get_instances(const GDate *range_end, gboolean include_disabled)
Allocates a new SxInstanceModel and fills it with generated instances for all scheduled transactions ...
void gnc_sx_instance_model_change_instance_state(GncSxInstanceModel *model, GncSxInstance *instance, GncSxInstanceState new_state)
There is a constraint around a sequence of upcoming instance states.
GncSxInstanceModel * gnc_sx_get_current_instances(void)
Shorthand for get_instances(now, FALSE);.
GncSxInstanceModel * gnc_sx_get_select_instances(GList *sel_sxes)
Allocates a new SxInstanceModel and fills it with generated instances for the given scheduled transac...
void gnc_sx_scrub_split_numerics(gpointer psplit, gpointer user)
Fix up numerics where they've gotten out-of-sync with the formulas.
void gnc_sx_summary_print(const GncSxSummary *summary)
Debug output to trace file.
void gnc_sx_instance_model_effect_change(GncSxInstanceModel *model, gboolean auto_create_only, GList **created_transaction_guids, GList **creation_errors)
Really ("effectively") create the transactions from the SX instances in the given model.
GHashTable * gnc_sx_instance_get_variables_for_parser(GHashTable *instance_var_hash)
void gnc_sx_all_instantiate_cashflow(GList *all_sxes, const GDate *range_start, const GDate *range_end, GHashTable *map, GList **creation_errors)
Instantiates the cash flow of all given SXs (in the given GList<SchedXAction*>) into the GHashTable<G...
GHashTable * gnc_sx_all_instantiate_cashflow_all(GDate range_start, GDate range_end)
Simplified wrapper around gnc_sx_all_instantiate_cashflow(): Run that function on all SX of the curre...
GList * gnc_sx_instance_get_variables(GncSxInstance *inst)
GHashTable * gnc_g_hash_new_guid_numeric(void)
Returns a GHashTable<GUID*, gnc_numeric*> with no destructor for the key, but a destructor for the va...
void gnc_sx_instance_model_summarize(GncSxInstanceModel *model, GncSxSummary *summary)
STRUCTS.
GncSxInstanceState orig_state
the original state at generation time.
SXTmpStateData * temporal_state
the sx creation temporal state.
GHashTable * variable_bindings
variable bindings.
GDate date
the instance date.
GncSxInstanceState state
the current state of the instance (during editing)
GncSxInstances * parent
the parent instances collection.
GList * instance_list
GList<GncSxInstance*>
GHashTable * variable_names
<name:char*,GncSxVariable*>
gint num_auto_create_no_notify_instances
The number of automatically-created instances that do no request notification.
gint num_to_create_instances
The number of (not-auto-create) to-create instances.
gboolean need_dialog
If the dialog needs to be displayed.
gint num_instances
The number of total instances (in any state).
gint num_auto_create_instances
The total number of auto-create instances.
gnc_numeric value
only numeric values are supported.
Just the variable temporal bits from the SX structure.