GnuCash  5.6-150-g038405b370+
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 gnu@gnu.org *
18  * *
19 \********************************************************************/
36 #ifndef XACC_SCHEDXACTION_H
37 #define XACC_SCHEDXACTION_H
38 
39 typedef struct _SchedXactionClass SchedXactionClass;
40 
41 #include <time.h>
42 #include <glib.h>
43 #include "qof.h"
44 #include "Recurrence.h"
45 #include "gnc-engine.h"
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 /* --- type macros --- */
52 #define GNC_TYPE_SCHEDXACTION (gnc_schedxaction_get_type ())
53 #define GNC_SCHEDXACTION(o) \
54  (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SCHEDXACTION, SchedXaction))
55 #define GNC_SCHEDXACTION_CLASS(k) \
56  (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SCHEDXACTION, SchedXactionClass))
57 #define GNC_IS_SCHEDXACTION(o) \
58  (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SCHEDXACTION))
59 #define GNC_IS_SCHEDXACTION_CLASS(k) \
60  (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SCHEDXACTION))
61 #define GNC_SCHEDXACTION_GET_CLASS(o) \
62  (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SCHEDXACTION, SchedXactionClass))
63 GType gnc_schedxaction_get_type(void);
64 
65 #define GNC_IS_SX(obj) GNC_IS_SCHEDXACTION(obj)
66 #define GNC_SX(obj) GNC_SCHEDXACTION(obj)
67 
68 typedef struct _SchedXaction SchedXaction;
69 
92 {
93  QofInstance inst;
94  gchar *name;
95 
96  GList *schedule;
97 
98  GDate last_date;
99 
100  GDate start_date;
101  /* if end_date is invalid, then no end. */
102  GDate end_date;
103 
104  /* if num_occurances_total == 0, then no limit */
105  gint num_occurances_total;
106  /* remaining occurrences are as-of the 'last_date'. */
107  gint num_occurances_remain;
108 
109  /* the current instance-count of the SX. */
110  gint instance_num;
111 
112  gboolean enabled;
113  gboolean autoCreateOption;
114  gboolean autoCreateNotify;
115  gint advanceCreateDays;
116  gint advanceRemindDays;
117 
118  Account *template_acct;
119 
122  GList /* <SXTmpStateData*> */ *deferredList;
123 };
124 
126 {
127  QofInstanceClass parent_class;
128 };
129 
131 typedef struct _SXTmpStateData
132 {
133  GDate last_date;
134  gint num_occur_rem;
135  gint num_inst;
137 
138 #define xaccSchedXactionSetGUID(X,G) qof_instance_set_guid(QOF_INSTANCE(X),(G))
139 
143 SchedXaction *xaccSchedXactionMalloc(QofBook *book);
144 
145 void sx_set_template_account (SchedXaction *sx, Account *account);
146 
150 void xaccSchedXactionDestroy( SchedXaction *sx );
151 
152 void gnc_sx_begin_edit (SchedXaction *sx);
153 void gnc_sx_commit_edit (SchedXaction *sx);
154 
156 /*@ dependent @*/
157 GList* gnc_sx_get_schedule(const SchedXaction *sx);
159 void gnc_sx_set_schedule(SchedXaction *sx, /*@ null @*//*@ only @*/ GList *schedule);
160 
161 gchar *xaccSchedXactionGetName( const SchedXaction *sx );
165 void xaccSchedXactionSetName( SchedXaction *sx, const gchar *newName );
166 
167 const GDate* xaccSchedXactionGetStartDate(const SchedXaction *sx );
168 time64 xaccSchedXactionGetStartDateTT(const SchedXaction *sx );
169 void xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart );
170 void xaccSchedXactionSetStartDateTT( SchedXaction *sx, const time64 newStart );
171 
172 int xaccSchedXactionHasEndDate( const SchedXaction *sx );
176 const GDate* xaccSchedXactionGetEndDate(const SchedXaction *sx );
180 void xaccSchedXactionSetEndDate( SchedXaction *sx, const GDate* newEnd );
181 
182 const GDate* xaccSchedXactionGetLastOccurDate(const SchedXaction *sx );
183 time64 xaccSchedXactionGetLastOccurDateTT(const SchedXaction *sx );
184 void xaccSchedXactionSetLastOccurDate( SchedXaction *sx, const GDate* newLastOccur );
185 void xaccSchedXactionSetLastOccurDateTT( SchedXaction *sx, const time64 newLastOccur );
186 
191 gboolean xaccSchedXactionHasOccurDef( const SchedXaction *sx );
192 gint xaccSchedXactionGetNumOccur( const SchedXaction *sx );
196 void xaccSchedXactionSetNumOccur( SchedXaction *sx, gint numNum );
197 gint xaccSchedXactionGetRemOccur( const SchedXaction *sx );
198 void xaccSchedXactionSetRemOccur( SchedXaction *sx, gint numRemain );
199 
202 gint gnc_sx_get_num_occur_daterange(const SchedXaction *sx, const GDate* start_date, const GDate* end_date);
203 
213 gint gnc_sx_get_instance_count( const SchedXaction *sx, /*@ null @*/ SXTmpStateData *stateData );
218 void gnc_sx_set_instance_count( SchedXaction *sx, gint instanceNum );
219 
220 /* must be g_list_freed */
221 GList *xaccSchedXactionGetSplits( const SchedXaction *sx );
222 void xaccSchedXactionSetSplits( SchedXaction *sx, GList *newSplits );
223 
224 gboolean xaccSchedXactionGetEnabled( const SchedXaction *sx );
225 void xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled );
226 
227 void xaccSchedXactionGetAutoCreate( const SchedXaction *sx,
228  /*@ out @*/ gboolean *outAutoCreate,
229  /*@ out @*/ gboolean *outNotify );
230 void xaccSchedXactionSetAutoCreate( SchedXaction *sx,
231  gboolean newAutoCreate,
232  gboolean newNotify );
233 
234 gint xaccSchedXactionGetAdvanceCreation( const SchedXaction *sx );
235 void xaccSchedXactionSetAdvanceCreation( SchedXaction *sx, gint createDays );
236 
237 gint xaccSchedXactionGetAdvanceReminder( const SchedXaction *sx );
238 void xaccSchedXactionSetAdvanceReminder( SchedXaction *sx, gint reminderDays );
239 
252 SXTmpStateData *gnc_sx_create_temporal_state(const SchedXaction *sx );
253 
256 void gnc_sx_incr_temporal_state(const SchedXaction *sx, SXTmpStateData *stateData );
257 
260 
281 GDate xaccSchedXactionGetNextInstance(const SchedXaction *sx,
282  SXTmpStateData *stateData);
283 
288 void gnc_sx_add_defer_instance( SchedXaction *sx, void *deferStateData );
289 
294 void gnc_sx_remove_defer_instance( SchedXaction *sx, void *deferStateData );
295 
302 GList *gnc_sx_get_defer_instances( SchedXaction *sx );
303 
304 /* #defines for Properties and GncModule */
305 #define GNC_SX_SHARES "shares"
306 #define GNC_SX_FREQ_SPEC "scheduled-frequency"
307 #define GNC_SX_NAME "sched-xname"
308 #define GNC_SX_START_DATE "sched-start-date"
309 #define GNC_SX_LAST_DATE "sched-last-date"
310 #define GNC_SX_NUM_OCCUR "sx-total-number"
311 #define GNC_SX_REM_OCCUR "sx-remaining-num"
312 
314 gboolean SXRegister (void);
315 
317 #define xaccSchedXactionIsDirty(X) qof_instance_is_dirty (QOF_INSTANCE(X))
318 
319 #define xaccSchedXactionGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
320 
321 #ifdef __cplusplus
322 }
323 #endif
324 
325 #endif /* XACC_SCHEDXACTION_H */
326 
const GDate * xaccSchedXactionGetEndDate(const SchedXaction *sx)
Returns invalid date when there is no end-date specified.
void gnc_sx_set_schedule(SchedXaction *sx, GList *schedule)
void gnc_sx_set_instance_count(SchedXaction *sx, gint instanceNum)
Sets the instance count to something other than the default.
GList * gnc_sx_get_schedule(const SchedXaction *sx)
GList * deferredList
The list of deferred SX instances.
Definition: SchedXaction.h:122
void gnc_sx_destroy_temporal_state(SXTmpStateData *stateData)
Frees the given stateDate object.
void xaccSchedXactionSetNumOccur(SchedXaction *sx, gint numNum)
Set to &#39;0&#39; to turn off number-of-occurrences definition.
STRUCTS.
SXTmpStateData * gnc_sx_create_temporal_state(const SchedXaction *sx)
Allocates a new SXTmpStateData object and fills it with the current state of the given sx...
Just the variable temporal bits from the SX structure.
Definition: SchedXaction.h:131
GDate xaccSchedXactionGetNextInstance(const SchedXaction *sx, SXTmpStateData *stateData)
Returns the next occurrence of a scheduled transaction.
gboolean SXRegister(void)
QOF registration.
void gnc_sx_incr_temporal_state(const SchedXaction *sx, SXTmpStateData *stateData)
Calculates the next occurrence of the given SX and stores that occurrence in the remporalStateDate.
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)
Calculates and returns the number of occurrences of the given SX in the given date range (inclusive)...
SXTmpStateData * gnc_sx_clone_temporal_state(SXTmpStateData *stateData)
Allocates and returns a one-by-one copy of the given temporal state.
All type declarations for the whole Gnucash engine.
A single scheduled transaction.
Definition: SchedXaction.h:91
void xaccSchedXactionSetName(SchedXaction *sx, const gchar *newName)
A copy of the name is made.
void gnc_sx_remove_defer_instance(SchedXaction *sx, void *deferStateData)
Removes an instance from the deferred list.
SchedXaction * xaccSchedXactionMalloc(QofBook *book)
Creates and initializes a scheduled transaction.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87
gboolean xaccSchedXactionHasOccurDef(const SchedXaction *sx)
Returns true if the scheduled transaction has a defined number of occurrences, false if not...
void xaccSchedXactionSetEndDate(SchedXaction *sx, const GDate *newEnd)
Set to an invalid GDate to turn off &#39;end-date&#39; definition.
void xaccSchedXactionDestroy(SchedXaction *sx)
Cleans up and frees a SchedXaction and its associated data.
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.