GnuCash 2.4.99
SchedXaction.h
Go to the documentation of this file.
00001 /********************************************************************\
00002  * This program is free software; you can redistribute it and/or    *
00003  * modify it under the terms of the GNU General Public License as   *
00004  * published by the Free Software Foundation; either version 2 of   *
00005  * the License, or (at your option) any later version.              *
00006  *                                                                  *
00007  * This program is distributed in the hope that it will be useful,  *
00008  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00009  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00010  * GNU General Public License for more details.                     *
00011  *                                                                  *
00012  * You should have received a copy of the GNU General Public License*
00013  * along with this program; if not, contact:                        *
00014  *                                                                  *
00015  * Free Software Foundation           Voice:  +1-617-542-5942       *
00016  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00017  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
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 /* --- type macros --- */
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     /* if end_date is invalid, then no end. */
00098     GDate           end_date;
00099 
00100     /* if num_occurances_total == 0, then no limit */
00101     gint            num_occurances_total;
00102     /* remaining occurrences are as-of the 'last_date'. */
00103     gint            num_occurances_remain;
00104 
00105     /* the current instance-count of the SX. */
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 /* <SXTmpStateData*> */ *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 /*@ dependent @*/
00153 GList* gnc_sx_get_schedule(const SchedXaction *sx);
00155 void gnc_sx_set_schedule(SchedXaction *sx, /*@ null @*//*@ only @*/ 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, /*@ null @*/ 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                                     /*@ out @*/ gboolean *outAutoCreate,
00220                                     /*@ out @*/ 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 
00250 void gnc_sx_destroy_temporal_state( SXTmpStateData *stateData );
00251 
00258 SXTmpStateData *gnc_sx_clone_temporal_state( SXTmpStateData *stateData );
00272 GDate xaccSchedXactionGetNextInstance(const SchedXaction *sx, SXTmpStateData *stateData );
00273 GDate xaccSchedXactionGetInstanceAfter(const SchedXaction *sx,
00274                                        GDate *date,
00275                                        SXTmpStateData *stateData );
00276 
00282 void xaccSchedXactionSetTemplateTrans( SchedXaction *sx,
00283                                        GList *t_t_list,
00284                                        QofBook *book );
00285 
00290 void gnc_sx_add_defer_instance( SchedXaction *sx, void *deferStateData );
00291 
00296 void gnc_sx_remove_defer_instance( SchedXaction *sx, void *deferStateData );
00297 
00304 GList *gnc_sx_get_defer_instances( SchedXaction *sx );
00305 
00306 /* #defines for KvpFrame strings and QOF */
00307 #define GNC_SX_ID                    "sched-xaction"
00308 #define GNC_SX_ACCOUNT               "account"
00309 #define GNC_SX_CREDIT_FORMULA        "credit-formula"
00310 #define GNC_SX_DEBIT_FORMULA         "debit-formula"
00311 #define GNC_SX_CREDIT_NUMERIC        "credit-numeric"
00312 #define GNC_SX_DEBIT_NUMERIC         "debit-numeric"
00313 #define GNC_SX_SHARES                "shares"
00314 #define GNC_SX_AMOUNT                "amnt"
00315 #define GNC_SX_FROM_SCHED_XACTION    "from-sched-xaction"
00316 #define GNC_SX_FREQ_SPEC             "scheduled-frequency"
00317 #define GNC_SX_NAME                  "sched-xname"
00318 #define GNC_SX_START_DATE            "sched-start-date"
00319 #define GNC_SX_LAST_DATE             "sched-last-date"
00320 #define GNC_SX_NUM_OCCUR             "sx-total-number"
00321 #define GNC_SX_REM_OCCUR             "sx-remaining-num"
00322 
00324 gboolean SXRegister (void);
00325 
00327 #define xaccSchedXactionIsDirty(X) qof_instance_is_dirty (QOF_INSTANCE(X))
00328 
00329 #define xaccSchedXactionGetGUID(X) qof_entity_get_guid(QOF_INSTANCE(X))
00330 
00331 #define xaccSchedXactionGetSlots(X) qof_instance_get_slots(QOF_INSTANCE(X))
00332 
00333 #endif /* XACC_SCHEDXACTION_H */
00334 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines