00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00036 #ifndef XACC_SCHEDXACTION_H
00037 #define XACC_SCHEDXACTION_H
00038
00039 typedef struct _SchedXactionClass SchedXactionClass;
00040
00041 #include <time.h>
00042 #include <glib.h>
00043 #include "qof.h"
00044 #include "Recurrence.h"
00045 #include "gnc-engine.h"
00046
00047
00048 #define GNC_TYPE_SCHEDXACTION (gnc_schedxaction_get_type ())
00049 #define GNC_SCHEDXACTION(o) \
00050 (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SCHEDXACTION, SchedXaction))
00051 #define GNC_SCHEDXACTION_CLASS(k) \
00052 (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SCHEDXACTION, SchedXactionClass))
00053 #define GNC_IS_SCHEDXACTION(o) \
00054 (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SCHEDXACTION))
00055 #define GNC_IS_SCHEDXACTION_CLASS(k) \
00056 (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SCHEDXACTION))
00057 #define GNC_SCHEDXACTION_GET_CLASS(o) \
00058 (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SCHEDXACTION, SchedXactionClass))
00059 GType gnc_schedxaction_get_type(void);
00060
00061 #define GNC_IS_SX(obj) GNC_IS_SCHEDXACTION(obj)
00062 #define GNC_SX(obj) GNC_SCHEDXACTION(obj)
00063
00064 typedef struct _SchedXaction SchedXaction;
00065
00087 struct _SchedXaction
00088 {
00089 QofInstance inst;
00090 gchar *name;
00091
00092 GList *schedule;
00093
00094 GDate last_date;
00095
00096 GDate start_date;
00097
00098 GDate end_date;
00099
00100
00101 gint num_occurances_total;
00102
00103 gint num_occurances_remain;
00104
00105
00106 gint instance_num;
00107
00108 gboolean enabled;
00109 gboolean autoCreateOption;
00110 gboolean autoCreateNotify;
00111 gint advanceCreateDays;
00112 gint advanceRemindDays;
00113
00114 Account *template_acct;
00115
00118 GList *deferredList;
00119 };
00120
00121 struct _SchedXactionClass
00122 {
00123 QofInstanceClass parent_class;
00124 };
00125
00127 typedef struct _SXTmpStateData
00128 {
00129 GDate last_date;
00130 gint num_occur_rem;
00131 gint num_inst;
00132 } SXTmpStateData;
00133
00134 #define xaccSchedXactionSetGUID(X,G) qof_instance_set_guid(QOF_INSTANCE(X),(G))
00135
00139 SchedXaction *xaccSchedXactionMalloc(QofBook *book);
00140
00141 void sx_set_template_account (SchedXaction *sx, Account *account);
00142
00146 void xaccSchedXactionDestroy( SchedXaction *sx );
00147
00148 void gnc_sx_begin_edit (SchedXaction *sx);
00149 void gnc_sx_commit_edit (SchedXaction *sx);
00150
00152
00153 GList* gnc_sx_get_schedule(const SchedXaction *sx);
00155 void gnc_sx_set_schedule(SchedXaction *sx, GList *schedule);
00156
00157 gchar *xaccSchedXactionGetName( const SchedXaction *sx );
00161 void xaccSchedXactionSetName( SchedXaction *sx, const gchar *newName );
00162
00163 const GDate* xaccSchedXactionGetStartDate(const SchedXaction *sx );
00164 void xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart );
00165
00166 int xaccSchedXactionHasEndDate( const SchedXaction *sx );
00170 const GDate* xaccSchedXactionGetEndDate(const SchedXaction *sx );
00174 void xaccSchedXactionSetEndDate( SchedXaction *sx, const GDate* newEnd );
00175
00176 const GDate* xaccSchedXactionGetLastOccurDate(const SchedXaction *sx );
00177 void xaccSchedXactionSetLastOccurDate( SchedXaction *sx, const GDate* newLastOccur );
00178
00183 gboolean xaccSchedXactionHasOccurDef( const SchedXaction *sx );
00184 gint xaccSchedXactionGetNumOccur( const SchedXaction *sx );
00188 void xaccSchedXactionSetNumOccur( SchedXaction *sx, gint numNum );
00189 gint xaccSchedXactionGetRemOccur( const SchedXaction *sx );
00190 void xaccSchedXactionSetRemOccur( SchedXaction *sx, gint numRemain );
00191
00194 gint gnc_sx_get_num_occur_daterange(const SchedXaction *sx, const GDate* start_date, const GDate* end_date);
00195
00205 gint gnc_sx_get_instance_count( const SchedXaction *sx, SXTmpStateData *stateData );
00210 void gnc_sx_set_instance_count( SchedXaction *sx, gint instanceNum );
00211
00212 GList *xaccSchedXactionGetSplits( const SchedXaction *sx );
00213 void xaccSchedXactionSetSplits( SchedXaction *sx, GList *newSplits );
00214
00215 gboolean xaccSchedXactionGetEnabled( const SchedXaction *sx );
00216 void xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled );
00217
00218 void xaccSchedXactionGetAutoCreate( const SchedXaction *sx,
00219 gboolean *outAutoCreate,
00220 gboolean *outNotify );
00221 void xaccSchedXactionSetAutoCreate( SchedXaction *sx,
00222 gboolean newAutoCreate,
00223 gboolean newNotify );
00224
00225 gint xaccSchedXactionGetAdvanceCreation( const SchedXaction *sx );
00226 void xaccSchedXactionSetAdvanceCreation( SchedXaction *sx, gint createDays );
00227
00228 gint xaccSchedXactionGetAdvanceReminder( const SchedXaction *sx );
00229 void xaccSchedXactionSetAdvanceReminder( SchedXaction *sx, gint reminderDays );
00230
00243 SXTmpStateData *gnc_sx_create_temporal_state(const SchedXaction *sx );
00244
00247 void gnc_sx_incr_temporal_state(const SchedXaction *sx, SXTmpStateData *stateData );
00248
00253 void gnc_sx_revert_to_temporal_state( SchedXaction *sx,
00254 SXTmpStateData *stateData );
00255
00257 void gnc_sx_destroy_temporal_state( SXTmpStateData *stateData );
00258
00265 SXTmpStateData *gnc_sx_clone_temporal_state( SXTmpStateData *stateData );
00279 GDate xaccSchedXactionGetNextInstance(const SchedXaction *sx, SXTmpStateData *stateData );
00280 GDate xaccSchedXactionGetInstanceAfter(const SchedXaction *sx,
00281 GDate *date,
00282 SXTmpStateData *stateData );
00283
00289 void xaccSchedXactionSetTemplateTrans( SchedXaction *sx,
00290 GList *t_t_list,
00291 QofBook *book );
00292
00297 void gnc_sx_add_defer_instance( SchedXaction *sx, void *deferStateData );
00298
00303 void gnc_sx_remove_defer_instance( SchedXaction *sx, void *deferStateData );
00304
00311 GList *gnc_sx_get_defer_instances( SchedXaction *sx );
00312
00313
00314 #define GNC_SX_ID "sched-xaction"
00315 #define GNC_SX_ACCOUNT "account"
00316 #define GNC_SX_CREDIT_FORMULA "credit-formula"
00317 #define GNC_SX_DEBIT_FORMULA "debit-formula"
00318 #define GNC_SX_CREDIT_NUMERIC "credit-numeric"
00319 #define GNC_SX_DEBIT_NUMERIC "debit-numeric"
00320 #define GNC_SX_SHARES "shares"
00321 #define GNC_SX_AMOUNT "amnt"
00322 #define GNC_SX_FROM_SCHED_XACTION "from-sched-xaction"
00323 #define GNC_SX_FREQ_SPEC "scheduled-frequency"
00324 #define GNC_SX_NAME "sched-xname"
00325 #define GNC_SX_START_DATE "sched-start-date"
00326 #define GNC_SX_LAST_DATE "sched-last-date"
00327 #define GNC_SX_NUM_OCCUR "sx-total-number"
00328 #define GNC_SX_REM_OCCUR "sx-remaining-num"
00329
00331 gboolean SXRegister (void);
00332
00334 #define xaccSchedXactionIsDirty(X) qof_instance_is_dirty (QOF_INSTANCE(X))
00335
00336 #define xaccSchedXactionGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
00337
00338 #define xaccSchedXactionGetSlots(X) qof_instance_get_slots(QOF_INSTANCE(X))
00339
00341 KvpValue *xaccSchedXactionGetSlot( const SchedXaction *sx,
00342 const char *slot );
00344 void xaccSchedXactionSetSlot( SchedXaction *sx,
00345 const char *slot,
00346 const KvpValue *value );
00347
00348
00349 #endif
00350