GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
SchedXaction.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 [email protected] *
18  * *
19 \********************************************************************/
36 #ifndef XACC_SCHEDXACTION_H
37 #define XACC_SCHEDXACTION_H
38 
40 
41 #include <time.h>
42 #include <glib.h>
43 #include "qof.h"
44 #include "Recurrence.h"
45 #include "gnc-engine.h"
46 
47 /* --- type macros --- */
48 #define GNC_TYPE_SCHEDXACTION (gnc_schedxaction_get_type ())
49 #define GNC_SCHEDXACTION(o) \
50  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SCHEDXACTION, SchedXaction))
51 #define GNC_SCHEDXACTION_CLASS(k) \
52  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SCHEDXACTION, SchedXactionClass))
53 #define GNC_IS_SCHEDXACTION(o) \
54  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SCHEDXACTION))
55 #define GNC_IS_SCHEDXACTION_CLASS(k) \
56  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SCHEDXACTION))
57 #define GNC_SCHEDXACTION_GET_CLASS(o) \
58  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SCHEDXACTION, SchedXactionClass))
59 GType gnc_schedxaction_get_type(void);
60 
61 #define GNC_IS_SX(obj) GNC_IS_SCHEDXACTION(obj)
62 #define GNC_SX(obj) GNC_SCHEDXACTION(obj)
63 
64 typedef struct _SchedXaction SchedXaction;
65 
88 {
89  QofInstance inst;
90  gchar *name;
91 
92  GList *schedule;
93 
94  GDate last_date;
95 
96  GDate start_date;
97  /* if end_date is invalid, then no end. */
98  GDate end_date;
99 
100  /* if num_occurances_total == 0, then no limit */
101  gint num_occurances_total;
102  /* remaining occurrences are as-of the 'last_date'. */
103  gint num_occurances_remain;
104 
105  /* the current instance-count of the SX. */
106  gint instance_num;
107 
108  gboolean enabled;
109  gboolean autoCreateOption;
110  gboolean autoCreateNotify;
111  gint advanceCreateDays;
112  gint advanceRemindDays;
113 
114  Account *template_acct;
115 
118  GList /* <SXTmpStateData*> */ *deferredList;
119 };
120 
122 {
123  QofInstanceClass parent_class;
124 };
125 
127 typedef struct _SXTmpStateData
128 {
129  GDate last_date;
130  gint num_occur_rem;
131  gint num_inst;
133 
134 #define xaccSchedXactionSetGUID(X,G) qof_instance_set_guid(QOF_INSTANCE(X),(G))
135 
140 
141 void sx_set_template_account (SchedXaction *sx, Account *account);
142 
147 
148 void gnc_sx_begin_edit (SchedXaction *sx);
149 void gnc_sx_commit_edit (SchedXaction *sx);
150 
152 /*@ dependent @*/
153 GList* gnc_sx_get_schedule(const SchedXaction *sx);
155 void gnc_sx_set_schedule(SchedXaction *sx, /*@ null @*//*@ only @*/ GList *schedule);
156 
157 gchar *xaccSchedXactionGetName( const SchedXaction *sx );
161 void xaccSchedXactionSetName( SchedXaction *sx, const gchar *newName );
162 
163 const GDate* xaccSchedXactionGetStartDate(const SchedXaction *sx );
164 void xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart );
165 
166 int xaccSchedXactionHasEndDate( const SchedXaction *sx );
170 const GDate* xaccSchedXactionGetEndDate(const SchedXaction *sx );
174 void xaccSchedXactionSetEndDate( SchedXaction *sx, const GDate* newEnd );
175 
176 const GDate* xaccSchedXactionGetLastOccurDate(const SchedXaction *sx );
177 void xaccSchedXactionSetLastOccurDate( SchedXaction *sx, const GDate* newLastOccur );
178 
183 gboolean xaccSchedXactionHasOccurDef( const SchedXaction *sx );
184 gint xaccSchedXactionGetNumOccur( const SchedXaction *sx );
188 void xaccSchedXactionSetNumOccur( SchedXaction *sx, gint numNum );
189 gint xaccSchedXactionGetRemOccur( const SchedXaction *sx );
190 void xaccSchedXactionSetRemOccur( SchedXaction *sx, gint numRemain );
191 
194 gint gnc_sx_get_num_occur_daterange(const SchedXaction *sx, const GDate* start_date, const GDate* end_date);
195 
205 gint gnc_sx_get_instance_count( const SchedXaction *sx, /*@ null @*/ SXTmpStateData *stateData );
210 void gnc_sx_set_instance_count( SchedXaction *sx, gint instanceNum );
211 
212 GList *xaccSchedXactionGetSplits( const SchedXaction *sx );
213 void xaccSchedXactionSetSplits( SchedXaction *sx, GList *newSplits );
214 
215 gboolean xaccSchedXactionGetEnabled( const SchedXaction *sx );
216 void xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled );
217 
218 void xaccSchedXactionGetAutoCreate( const SchedXaction *sx,
219  /*@ out @*/ gboolean *outAutoCreate,
220  /*@ out @*/ gboolean *outNotify );
221 void xaccSchedXactionSetAutoCreate( SchedXaction *sx,
222  gboolean newAutoCreate,
223  gboolean newNotify );
224 
225 gint xaccSchedXactionGetAdvanceCreation( const SchedXaction *sx );
226 void xaccSchedXactionSetAdvanceCreation( SchedXaction *sx, gint createDays );
227 
228 gint xaccSchedXactionGetAdvanceReminder( const SchedXaction *sx );
229 void xaccSchedXactionSetAdvanceReminder( SchedXaction *sx, gint reminderDays );
230 
244 
247 void gnc_sx_incr_temporal_state(const SchedXaction *sx, SXTmpStateData *stateData );
248 
251 
272 GDate xaccSchedXactionGetNextInstance(const SchedXaction *sx, SXTmpStateData *stateData );
273 GDate xaccSchedXactionGetInstanceAfter(const SchedXaction *sx,
274  GDate *date,
275  SXTmpStateData *stateData );
276 
283  GList *t_t_list,
284  QofBook *book );
285 
290 void gnc_sx_add_defer_instance( SchedXaction *sx, void *deferStateData );
291 
296 void gnc_sx_remove_defer_instance( SchedXaction *sx, void *deferStateData );
297 
305 
306 /* #defines for Properties and GncModule */
307 #define GNC_SX_SHARES "shares"
308 #define GNC_SX_FREQ_SPEC "scheduled-frequency"
309 #define GNC_SX_NAME "sched-xname"
310 #define GNC_SX_START_DATE "sched-start-date"
311 #define GNC_SX_LAST_DATE "sched-last-date"
312 #define GNC_SX_NUM_OCCUR "sx-total-number"
313 #define GNC_SX_REM_OCCUR "sx-remaining-num"
314 
316 gboolean SXRegister (void);
317 
319 #define xaccSchedXactionIsDirty(X) qof_instance_is_dirty (QOF_INSTANCE(X))
320 
321 #define xaccSchedXactionGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
322 
323 #define xaccSchedXactionGetSlots(X) qof_instance_get_slots(QOF_INSTANCE(X))
324 
325 #endif /* XACC_SCHEDXACTION_H */
326 
const GDate * xaccSchedXactionGetEndDate(const SchedXaction *sx)
Definition: SchedXaction.c:628
void gnc_sx_set_schedule(SchedXaction *sx, GList *schedule)
Definition: SchedXaction.c:565
void gnc_sx_set_instance_count(SchedXaction *sx, gint instanceNum)
GList * gnc_sx_get_schedule(const SchedXaction *sx)
Definition: SchedXaction.c:559
void gnc_sx_destroy_temporal_state(SXTmpStateData *stateData)
void xaccSchedXactionSetNumOccur(SchedXaction *sx, gint numNum)
Definition: SchedXaction.c:690
SXTmpStateData * gnc_sx_create_temporal_state(const SchedXaction *sx)
GDate xaccSchedXactionGetNextInstance(const SchedXaction *sx, SXTmpStateData *stateData)
Returns the next occurrence of a scheduled transaction.
Definition: SchedXaction.c:874
gboolean SXRegister(void)
QOF registration.
void gnc_sx_incr_temporal_state(const SchedXaction *sx, SXTmpStateData *stateData)
struct _SXTmpStateData SXTmpStateData
GList * deferredList
Definition: SchedXaction.h:118
void gnc_sx_add_defer_instance(SchedXaction *sx, void *deferStateData)
Adds an instance to the deferred list of the SX.
gint gnc_sx_get_num_occur_daterange(const SchedXaction *sx, const GDate *start_date, const GDate *end_date)
Definition: SchedXaction.c:726
SXTmpStateData * gnc_sx_clone_temporal_state(SXTmpStateData *stateData)
Allocates and returns a one-by-one copy of the given temporal state.
void xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list, QofBook *book)
Set the schedxaction's template transaction.
All type declarations for the whole Gnucash engine.
void xaccSchedXactionSetName(SchedXaction *sx, const gchar *newName)
Definition: SchedXaction.c:581
void gnc_sx_remove_defer_instance(SchedXaction *sx, void *deferStateData)
Removes an instance from the deferred list.
SchedXaction * xaccSchedXactionMalloc(QofBook *book)
Definition: SchedXaction.c:404
gboolean xaccSchedXactionHasOccurDef(const SchedXaction *sx)
Definition: SchedXaction.c:678
void xaccSchedXactionSetEndDate(SchedXaction *sx, const GDate *newEnd)
Definition: SchedXaction.c:635
void xaccSchedXactionDestroy(SchedXaction *sx)
Definition: SchedXaction.c:473
GList * gnc_sx_get_defer_instances(SchedXaction *sx)
Returns the defer list from the SX.
gint gnc_sx_get_instance_count(const SchedXaction *sx, SXTmpStateData *stateData)
Get the instance count.