GnuCash c935c2f+
Loading...
Searching...
No Matches
Files | Data Structures | Macros | Enumerations | Functions
Scheduled/Periodic/Recurring Transactions

Scheduled Transactions provide a framework for remembering information about a transactions that are set to occur in the future, either once or periodically. More...

Files

file  FreqSpec.h
 Period / Date Frequency Specification.
 
file  SchedXaction.h
 Scheduled Transactions public handling routines.
 
file  SX-book.h
 Anchor Scheduled Transaction info in a book.
 

Data Structures

struct  SchedXaction
 A single scheduled transaction. More...
 
struct  SchedXactionClass
 
struct  SXTmpStateData
 Just the variable temporal bits from the SX structure. More...
 
struct  SchedXactions
 
struct  SchedXactionsClass
 

Macros

#define ENUM_LIST_TYPE(_)
 
#define ENUM_LIST_UI(_)
 
#define GNC_TYPE_SCHEDXACTION   (gnc_schedxaction_get_type ())
 
#define GNC_SCHEDXACTION(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SCHEDXACTION, SchedXaction))
 
#define GNC_SCHEDXACTION_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SCHEDXACTION, SchedXactionClass))
 
#define GNC_IS_SCHEDXACTION(o)    (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SCHEDXACTION))
 
#define GNC_IS_SCHEDXACTION_CLASS(k)    (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SCHEDXACTION))
 
#define GNC_SCHEDXACTION_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SCHEDXACTION, SchedXactionClass))
 
#define GNC_IS_SX(obj)   GNC_IS_SCHEDXACTION(obj)
 
#define GNC_SX(obj)   GNC_SCHEDXACTION(obj)
 
#define xaccSchedXactionSetGUID(X, G)   qof_instance_set_guid(QOF_INSTANCE(X),(G))
 
#define GNC_SX_SHARES   "shares"
 
#define GNC_SX_FREQ_SPEC   "scheduled-frequency"
 
#define GNC_SX_NAME   "sched-xname"
 
#define GNC_SX_START_DATE   "sched-start-date"
 
#define GNC_SX_LAST_DATE   "sched-last-date"
 
#define GNC_SX_NUM_OCCUR   "sx-total-number"
 
#define GNC_SX_REM_OCCUR   "sx-remaining-num"
 
#define xaccSchedXactionIsDirty(X)   qof_instance_is_dirty (QOF_INSTANCE(X))
 
#define xaccSchedXactionGetGUID(X)   qof_entity_get_guid(QOF_INSTANCE(X))
 
#define GNC_TYPE_SCHEDXACTIONS   (gnc_schedxactions_get_type ())
 
#define GNC_SCHEDXACTIONS(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SCHEDXACTIONS, SchedXactions))
 
#define GNC_SCHEDXACTIONS_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SCHEDXACTIONS, SchedXactionsClass))
 
#define GNC_IS_SCHEDXACTIONS(o)    (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SCHEDXACTIONS))
 
#define GNC_IS_SCHEDXACTIONS_CLASS(k)    (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SCHEDXACTIONS))
 
#define GNC_SCHEDXACTIONS_GET_CLASS(o)    (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SCHEDXACTIONS, SchedXactionsClass))
 
#define GNC_IS_SXES(obj)   GNC_IS_SCHEDXACTIONS(obj)
 
#define GNC_SXES(obj)   GNC_SCHEDXACTIONS(obj)
 

Enumerations

enum  FreqType { ENUM_LIST_TYPE =(ENUM_BODY) }
 Frequency specification. More...
 
enum  UIFreqType { ENUM_LIST_UI =(ENUM_BODY) }
 The user's conception of the frequency. More...
 

Functions

GType gnc_schedxaction_get_type (void)
 
SchedXaction * xaccSchedXactionMalloc (QofBook *book)
 Creates and initializes a scheduled transaction.
 
void sx_set_template_account (SchedXaction *sx, Account *account)
 
void xaccSchedXactionDestroy (SchedXaction *sx)
 Cleans up and frees a SchedXaction and its associated data.
 
void gnc_sx_begin_edit (SchedXaction *sx)
 
void gnc_sx_commit_edit (SchedXaction *sx)
 
GList * gnc_sx_get_schedule (const SchedXaction *sx)
 
void gnc_sx_set_schedule (SchedXaction *sx, GList *schedule)
 
gchar * xaccSchedXactionGetName (const SchedXaction *sx)
 
void xaccSchedXactionSetName (SchedXaction *sx, const gchar *newName)
 A copy of the name is made.
 
const GDate * xaccSchedXactionGetStartDate (const SchedXaction *sx)
 
time64 xaccSchedXactionGetStartDateTT (const SchedXaction *sx)
 
void xaccSchedXactionSetStartDate (SchedXaction *sx, const GDate *newStart)
 
void xaccSchedXactionSetStartDateTT (SchedXaction *sx, const time64 newStart)
 
int xaccSchedXactionHasEndDate (const SchedXaction *sx)
 
const GDate * xaccSchedXactionGetEndDate (const SchedXaction *sx)
 Returns invalid date when there is no end-date specified.
 
void xaccSchedXactionSetEndDate (SchedXaction *sx, const GDate *newEnd)
 Set to an invalid GDate to turn off 'end-date' definition.
 
const GDate * xaccSchedXactionGetLastOccurDate (const SchedXaction *sx)
 
time64 xaccSchedXactionGetLastOccurDateTT (const SchedXaction *sx)
 
void xaccSchedXactionSetLastOccurDate (SchedXaction *sx, const GDate *newLastOccur)
 
void xaccSchedXactionSetLastOccurDateTT (SchedXaction *sx, const time64 newLastOccur)
 
gboolean xaccSchedXactionHasOccurDef (const SchedXaction *sx)
 Returns true if the scheduled transaction has a defined number of occurrences, false if not.
 
gint xaccSchedXactionGetNumOccur (const SchedXaction *sx)
 
void xaccSchedXactionSetNumOccur (SchedXaction *sx, gint numNum)
 Set to '0' to turn off number-of-occurrences definition.
 
gint xaccSchedXactionGetRemOccur (const SchedXaction *sx)
 
void xaccSchedXactionSetRemOccur (SchedXaction *sx, gint numRemain)
 
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).
 
gint gnc_sx_get_instance_count (const SchedXaction *sx, SXTmpStateData *stateData)
 Get the instance count.
 
void gnc_sx_set_instance_count (SchedXaction *sx, gint instanceNum)
 Sets the instance count to something other than the default.
 
GList * xaccSchedXactionGetSplits (const SchedXaction *sx)
 
void xaccSchedXactionSetSplits (SchedXaction *sx, GList *newSplits)
 
gboolean xaccSchedXactionGetEnabled (const SchedXaction *sx)
 
void xaccSchedXactionSetEnabled (SchedXaction *sx, gboolean newEnabled)
 
void xaccSchedXactionGetAutoCreate (const SchedXaction *sx, gboolean *outAutoCreate, gboolean *outNotify)
 
void xaccSchedXactionSetAutoCreate (SchedXaction *sx, gboolean newAutoCreate, gboolean newNotify)
 
gint xaccSchedXactionGetAdvanceCreation (const SchedXaction *sx)
 
void xaccSchedXactionSetAdvanceCreation (SchedXaction *sx, gint createDays)
 
gint xaccSchedXactionGetAdvanceReminder (const SchedXaction *sx)
 
void xaccSchedXactionSetAdvanceReminder (SchedXaction *sx, gint reminderDays)
 
GDate xaccSchedXactionGetNextInstance (const SchedXaction *sx, SXTmpStateData *stateData)
 Returns the next occurrence of a scheduled transaction.
 
void gnc_sx_add_defer_instance (SchedXaction *sx, void *deferStateData)
 Adds an instance to the deferred list of the SX.
 
void gnc_sx_remove_defer_instance (SchedXaction *sx, void *deferStateData)
 Removes an instance from the deferred list.
 
GList * gnc_sx_get_defer_instances (SchedXaction *sx)
 Returns the defer list from the SX.
 
gboolean SXRegister (void)
 QOF registration.
 
GType gnc_schedxactions_get_type (void)
 
SchedXactions * gnc_book_get_schedxactions (QofBook *book)
 
void gnc_sxes_add_sx (SchedXactions *sxes, SchedXaction *sx)
 
void gnc_sxes_del_sx (SchedXactions *sxes, SchedXaction *sx)
 
Accountgnc_book_get_template_root (const QofBook *book)
 Returns the template group from the book.
 
GList * gnc_sx_get_sxes_referencing_account (QofBook *book, Account *acct)
 

Temporal state data.

These functions allow us to opaquely save the entire temporal state of ScheduledTransactions.

This is used by the "since-last-run" dialog to store the initial state of SXes before modification ... if it later becomes necessary to revert an entire set of changes, we can 'revert' the SX without having to rollback all the individual state changes.

SXTmpStateDatagnc_sx_create_temporal_state (const SchedXaction *sx)
 Allocates a new SXTmpStateData object and fills it with the current state of the given sx.
 
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_destroy_temporal_state (SXTmpStateData *stateData)
 Frees the given stateDate object.
 
SXTmpStateDatagnc_sx_clone_temporal_state (SXTmpStateData *stateData)
 Allocates and returns a one-by-one copy of the given temporal state.
 

Detailed Description

Scheduled Transactions provide a framework for remembering information about a transactions that are set to occur in the future, either once or periodically.

Macro Definition Documentation

◆ ENUM_LIST_TYPE

#define ENUM_LIST_TYPE (   _)
Value:
_(INVALID,) \
_(ONCE,) \
_(DAILY,) \
_(WEEKLY,) \
_(MONTHLY,) \
_(MONTH_RELATIVE,) \
_(COMPOSITE,)

Definition at line 34 of file FreqSpec.h.

◆ ENUM_LIST_UI

#define ENUM_LIST_UI (   _)
Value:
_(UIFREQ_NONE,) \
_(UIFREQ_ONCE,) \
_(UIFREQ_DAILY,) \
_(UIFREQ_DAILY_MF,) \
_(UIFREQ_WEEKLY,) \
_(UIFREQ_BI_WEEKLY,) \
_(UIFREQ_SEMI_MONTHLY,) \
_(UIFREQ_MONTHLY,) \
_(UIFREQ_QUARTERLY,) \
_(UIFREQ_TRI_ANUALLY,) \
_(UIFREQ_SEMI_YEARLY,) \
_(UIFREQ_YEARLY,) \
_(UIFREQ_NUM_UI_FREQSPECS,)

Definition at line 53 of file FreqSpec.h.

◆ GNC_IS_SCHEDXACTION

#define GNC_IS_SCHEDXACTION (   o)     (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SCHEDXACTION))

Definition at line 57 of file SchedXaction.h.

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
131typedef 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
143SchedXaction *xaccSchedXactionMalloc(QofBook *book);
144
145void sx_set_template_account (SchedXaction *sx, Account *account);
146
150void xaccSchedXactionDestroy( SchedXaction *sx );
151
152void gnc_sx_begin_edit (SchedXaction *sx);
153void gnc_sx_commit_edit (SchedXaction *sx);
154
156/*@ dependent @*/
157GList* gnc_sx_get_schedule(const SchedXaction *sx);
159void gnc_sx_set_schedule(SchedXaction *sx, /*@ null @*//*@ only @*/ GList *schedule);
160
161gchar *xaccSchedXactionGetName( const SchedXaction *sx );
165void xaccSchedXactionSetName( SchedXaction *sx, const gchar *newName );
166
167const GDate* xaccSchedXactionGetStartDate(const SchedXaction *sx );
168time64 xaccSchedXactionGetStartDateTT(const SchedXaction *sx );
169void xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart );
170void xaccSchedXactionSetStartDateTT( SchedXaction *sx, const time64 newStart );
171
172int xaccSchedXactionHasEndDate( const SchedXaction *sx );
176const GDate* xaccSchedXactionGetEndDate(const SchedXaction *sx );
180void xaccSchedXactionSetEndDate( SchedXaction *sx, const GDate* newEnd );
181
182const GDate* xaccSchedXactionGetLastOccurDate(const SchedXaction *sx );
183time64 xaccSchedXactionGetLastOccurDateTT(const SchedXaction *sx );
184void xaccSchedXactionSetLastOccurDate( SchedXaction *sx, const GDate* newLastOccur );
185void xaccSchedXactionSetLastOccurDateTT( SchedXaction *sx, const time64 newLastOccur );
186
191gboolean xaccSchedXactionHasOccurDef( const SchedXaction *sx );
192gint xaccSchedXactionGetNumOccur( const SchedXaction *sx );
196void xaccSchedXactionSetNumOccur( SchedXaction *sx, gint numNum );
197gint xaccSchedXactionGetRemOccur( const SchedXaction *sx );
198void xaccSchedXactionSetRemOccur( SchedXaction *sx, gint numRemain );
199
202gint gnc_sx_get_num_occur_daterange(const SchedXaction *sx, const GDate* start_date, const GDate* end_date);
203
213gint gnc_sx_get_instance_count( const SchedXaction *sx, /*@ null @*/ SXTmpStateData *stateData );
218void gnc_sx_set_instance_count( SchedXaction *sx, gint instanceNum );
219
220/* must be g_list_freed */
221GList *xaccSchedXactionGetSplits( const SchedXaction *sx );
222void xaccSchedXactionSetSplits( SchedXaction *sx, GList *newSplits );
223
224gboolean xaccSchedXactionGetEnabled( const SchedXaction *sx );
225void xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled );
226
227void xaccSchedXactionGetAutoCreate( const SchedXaction *sx,
228 /*@ out @*/ gboolean *outAutoCreate,
229 /*@ out @*/ gboolean *outNotify );
230void xaccSchedXactionSetAutoCreate( SchedXaction *sx,
231 gboolean newAutoCreate,
232 gboolean newNotify );
233
234gint xaccSchedXactionGetAdvanceCreation( const SchedXaction *sx );
235void xaccSchedXactionSetAdvanceCreation( SchedXaction *sx, gint createDays );
236
237gint xaccSchedXactionGetAdvanceReminder( const SchedXaction *sx );
238void xaccSchedXactionSetAdvanceReminder( SchedXaction *sx, gint reminderDays );
239
252SXTmpStateData *gnc_sx_create_temporal_state(const SchedXaction *sx );
253
256void gnc_sx_incr_temporal_state(const SchedXaction *sx, SXTmpStateData *stateData );
257
260
281GDate xaccSchedXactionGetNextInstance(const SchedXaction *sx,
282 SXTmpStateData *stateData);
283
288void gnc_sx_add_defer_instance( SchedXaction *sx, void *deferStateData );
289
294void gnc_sx_remove_defer_instance( SchedXaction *sx, void *deferStateData );
295
302GList *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
314gboolean SXRegister (void);
315
317#define xaccSchedXactionIsDirty(X) qof_instance_is_dirty (QOF_INSTANCE(X))
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
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition gnc-date.h:87
SXTmpStateData * gnc_sx_clone_temporal_state(SXTmpStateData *stateData)
Allocates and returns a one-by-one copy of the given temporal state.
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.
void gnc_sx_set_schedule(SchedXaction *sx, GList *schedule)
GDate xaccSchedXactionGetNextInstance(const SchedXaction *sx, SXTmpStateData *stateData)
Returns the next occurrence of a scheduled transaction.
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).
void gnc_sx_remove_defer_instance(SchedXaction *sx, void *deferStateData)
Removes an instance from the deferred list.
void gnc_sx_add_defer_instance(SchedXaction *sx, void *deferStateData)
Adds an instance to the deferred list of the SX.
gboolean xaccSchedXactionHasOccurDef(const SchedXaction *sx)
Returns true if the scheduled transaction has a defined number of occurrences, false if not.
const GDate * xaccSchedXactionGetEndDate(const SchedXaction *sx)
Returns invalid date when there is no end-date specified.
SchedXaction * xaccSchedXactionMalloc(QofBook *book)
Creates and initializes a scheduled transaction.
GList * gnc_sx_get_schedule(const SchedXaction *sx)
gboolean SXRegister(void)
QOF registration.
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.
void xaccSchedXactionSetName(SchedXaction *sx, const gchar *newName)
A copy of the name is made.
void xaccSchedXactionSetEndDate(SchedXaction *sx, const GDate *newEnd)
Set to an invalid GDate to turn off 'end-date' definition.
void gnc_sx_destroy_temporal_state(SXTmpStateData *stateData)
Frees the given stateDate object.
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 xaccSchedXactionDestroy(SchedXaction *sx)
Cleans up and frees a SchedXaction and its associated data.
void xaccSchedXactionSetNumOccur(SchedXaction *sx, gint numNum)
Set to '0' to turn off number-of-occurrences definition.
void gnc_sx_set_instance_count(SchedXaction *sx, gint instanceNum)
Sets the instance count to something other than the default.
STRUCTS.
QofBook reference.
Definition qofbook-p.hpp:47
Just the variable temporal bits from the SX structure.

◆ GNC_IS_SCHEDXACTION_CLASS

#define GNC_IS_SCHEDXACTION_CLASS (   k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SCHEDXACTION))

Definition at line 59 of file SchedXaction.h.

◆ GNC_IS_SCHEDXACTIONS

#define GNC_IS_SCHEDXACTIONS (   o)     (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_SCHEDXACTIONS))

Definition at line 72 of file SX-book.h.

◆ GNC_IS_SCHEDXACTIONS_CLASS

#define GNC_IS_SCHEDXACTIONS_CLASS (   k)     (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_SCHEDXACTIONS))

Definition at line 74 of file SX-book.h.

◆ GNC_IS_SX

#define GNC_IS_SX (   obj)    GNC_IS_SCHEDXACTION(obj)

Definition at line 65 of file SchedXaction.h.

◆ GNC_IS_SXES

#define GNC_IS_SXES (   obj)    GNC_IS_SCHEDXACTIONS(obj)

Definition at line 80 of file SX-book.h.

◆ GNC_SCHEDXACTION

#define GNC_SCHEDXACTION (   o)     (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SCHEDXACTION, SchedXaction))

Definition at line 53 of file SchedXaction.h.

◆ GNC_SCHEDXACTION_CLASS

#define GNC_SCHEDXACTION_CLASS (   k)     (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SCHEDXACTION, SchedXactionClass))

Definition at line 55 of file SchedXaction.h.

◆ GNC_SCHEDXACTION_GET_CLASS

#define GNC_SCHEDXACTION_GET_CLASS (   o)     (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SCHEDXACTION, SchedXactionClass))

Definition at line 61 of file SchedXaction.h.

◆ GNC_SCHEDXACTIONS

#define GNC_SCHEDXACTIONS (   o)     (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_SCHEDXACTIONS, SchedXactions))

Definition at line 68 of file SX-book.h.

◆ GNC_SCHEDXACTIONS_CLASS

#define GNC_SCHEDXACTIONS_CLASS (   k)     (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_SCHEDXACTIONS, SchedXactionsClass))

Definition at line 70 of file SX-book.h.

◆ GNC_SCHEDXACTIONS_GET_CLASS

#define GNC_SCHEDXACTIONS_GET_CLASS (   o)     (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_SCHEDXACTIONS, SchedXactionsClass))

Definition at line 76 of file SX-book.h.

◆ GNC_SX

#define GNC_SX (   obj)    GNC_SCHEDXACTION(obj)

Definition at line 66 of file SchedXaction.h.

◆ GNC_SX_FREQ_SPEC

#define GNC_SX_FREQ_SPEC   "scheduled-frequency"

Definition at line 306 of file SchedXaction.h.

◆ GNC_SX_LAST_DATE

#define GNC_SX_LAST_DATE   "sched-last-date"

Definition at line 309 of file SchedXaction.h.

◆ GNC_SX_NAME

#define GNC_SX_NAME   "sched-xname"

Definition at line 307 of file SchedXaction.h.

◆ GNC_SX_NUM_OCCUR

#define GNC_SX_NUM_OCCUR   "sx-total-number"

Definition at line 310 of file SchedXaction.h.

◆ GNC_SX_REM_OCCUR

#define GNC_SX_REM_OCCUR   "sx-remaining-num"

Definition at line 311 of file SchedXaction.h.

◆ GNC_SX_SHARES

#define GNC_SX_SHARES   "shares"

Definition at line 305 of file SchedXaction.h.

◆ GNC_SX_START_DATE

#define GNC_SX_START_DATE   "sched-start-date"

Definition at line 308 of file SchedXaction.h.

◆ GNC_SXES

#define GNC_SXES (   obj)    GNC_SCHEDXACTIONS(obj)

Definition at line 81 of file SX-book.h.

◆ GNC_TYPE_SCHEDXACTION

#define GNC_TYPE_SCHEDXACTION   (gnc_schedxaction_get_type ())

Definition at line 52 of file SchedXaction.h.

◆ GNC_TYPE_SCHEDXACTIONS

#define GNC_TYPE_SCHEDXACTIONS   (gnc_schedxactions_get_type ())

Definition at line 67 of file SX-book.h.

◆ xaccSchedXactionGetGUID

#define xaccSchedXactionGetGUID (   X)    qof_entity_get_guid(QOF_INSTANCE(X))
Deprecated:

Definition at line 319 of file SchedXaction.h.

◆ xaccSchedXactionIsDirty

#define xaccSchedXactionIsDirty (   X)    qof_instance_is_dirty (QOF_INSTANCE(X))
Deprecated:

Definition at line 317 of file SchedXaction.h.

◆ xaccSchedXactionSetGUID

#define xaccSchedXactionSetGUID (   X,
 
)    qof_instance_set_guid(QOF_INSTANCE(X),(G))

Definition at line 138 of file SchedXaction.h.

Enumeration Type Documentation

◆ FreqType

enum FreqType

Frequency specification.

For BI_WEEKLY, use weekly[2] SEMI_MONTHLY, use composite YEARLY, monthly[12]

Definition at line 43 of file FreqSpec.h.

◆ UIFreqType

enum UIFreqType

The user's conception of the frequency.

It is expected that this list will grow, while the former FreqType will not.

Definition at line 68 of file FreqSpec.h.

Function Documentation

◆ gnc_book_get_schedxactions()

SchedXactions * gnc_book_get_schedxactions ( QofBook book)

Definition at line 204 of file SX-book.cpp.

205{
206 QofCollection *col;
207 col = qof_book_get_collection(book, GNC_ID_SCHEDXACTION);
208 return gnc_collection_get_schedxactions(col);
209}
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
Definition qofbook.cpp:521

◆ gnc_book_get_template_root()

Account * gnc_book_get_template_root ( const QofBook book)

Returns the template group from the book.

Definition at line 65 of file SX-book.cpp.

66{
67 QofCollection *col;
68 if (!book) return NULL;
69 col = qof_book_get_collection (book, GNC_ID_SXTG);
70 return gnc_collection_get_template_root (col);
71}

◆ gnc_sx_add_defer_instance()

void gnc_sx_add_defer_instance ( SchedXaction *  sx,
void *  deferStateData 
)

Adds an instance to the deferred list of the SX.

Added instances are added in date-sorted order.

Added instances are added in (date-)sorted order.

Definition at line 1099 of file SchedXaction.cpp.

1100{
1101 sx->deferredList = g_list_insert_sorted( sx->deferredList,
1102 deferStateData,
1103 _temporal_state_data_cmp );
1104}

◆ gnc_sx_begin_edit()

void gnc_sx_begin_edit ( SchedXaction *  sx)

Definition at line 493 of file SchedXaction.cpp.

494{
495 qof_begin_edit (&sx->inst);
496}
gboolean qof_begin_edit(QofInstance *inst)
begin_edit

◆ gnc_sx_clone_temporal_state()

SXTmpStateData * gnc_sx_clone_temporal_state ( SXTmpStateData stateData)

Allocates and returns a one-by-one copy of the given temporal state.

The caller must destroy the returned object with gnc_sx_destroy_temporal_state() after usage.

Definition at line 1063 of file SchedXaction.cpp.

1064{
1065 SXTmpStateData *toRet = NULL;
1066
1067 if(tsd)
1068 {
1069 toRet = g_new(SXTmpStateData, 1);
1070 *toRet = *tsd;
1071 }
1072
1073 return toRet;
1074}

◆ gnc_sx_commit_edit()

void gnc_sx_commit_edit ( SchedXaction *  sx)

Definition at line 515 of file SchedXaction.cpp.

516{
517 if (!qof_commit_edit (QOF_INSTANCE(sx))) return;
518 qof_commit_edit_part2 (&sx->inst, commit_err, commit_done, sx_free);
519}
gboolean qof_commit_edit_part2(QofInstance *inst, void(*on_error)(QofInstance *, QofBackendError), void(*on_done)(QofInstance *), void(*on_free)(QofInstance *))
part2 – deal with the backend
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers

◆ gnc_sx_create_temporal_state()

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.

Definition at line 1032 of file SchedXaction.cpp.

1033{
1034 auto toRet = g_new0 (SXTmpStateData, 1);
1035 if (g_date_valid (&(sx->last_date)))
1036 toRet->last_date = sx->last_date;
1037 else
1038 g_date_set_dmy (&toRet->last_date, 1, static_cast<GDateMonth>(1), 1970);
1039 toRet->num_occur_rem = sx->num_occurances_remain;
1040 toRet->num_inst = sx->instance_num;
1041 return toRet;
1042}

◆ gnc_sx_destroy_temporal_state()

void gnc_sx_destroy_temporal_state ( SXTmpStateData stateData)

Frees the given stateDate object.

Definition at line 1057 of file SchedXaction.cpp.

1058{
1059 g_free(tsd);
1060}

◆ gnc_sx_get_defer_instances()

GList * gnc_sx_get_defer_instances ( SchedXaction *  sx)

Returns the defer list from the SX.

This is a date-sorted state-data instance list. The list should not be modified by the caller; use the gnc_sx_{add,remove}_defer_instance() functions to modify the list.

Returns the defer list from the SX.

The list should not be modified by the caller; use the gnc_sx_{add,remove}_defer_instance() functions to modify the list.

Parameters
sxScheduled transaction
Returns
Defer list which must not be modified by the caller

Definition at line 1137 of file SchedXaction.cpp.

1138{
1139 return sx->deferredList;
1140}

◆ gnc_sx_get_instance_count()

gint gnc_sx_get_instance_count ( const SchedXaction *  sx,
SXTmpStateData stateData 
)

Get the instance count.

This is incremented by one for every created instance of the SX. Returns the instance num of the SX unless stateData is non-null, in which case it returns the instance num from the state data.

Parameters
sxThe instance whose state should be retrieved.
stateDatamay be NULL.

Definition at line 929 of file SchedXaction.cpp.

930{
931 gint toRet = -1;
932 SXTmpStateData *tsd;
933
934 if ( stateData )
935 {
936 tsd = (SXTmpStateData*)stateData;
937 toRet = tsd->num_inst;
938 }
939 else
940 {
941 toRet = sx->instance_num;
942 }
943
944 return toRet;
945}

◆ gnc_sx_get_num_occur_daterange()

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).

Definition at line 739 of file SchedXaction.cpp.

740{
741 gint result = 0;
742 SXTmpStateData *tmpState;
743 gboolean countFirstDate;
744
745 /* SX still active? If not, return now. */
747 && xaccSchedXactionGetRemOccur(sx) <= 0)
748 || (xaccSchedXactionHasEndDate(sx)
749 && g_date_compare(xaccSchedXactionGetEndDate(sx), start_date) < 0))
750 {
751 return result;
752 }
753
754 tmpState = gnc_sx_create_temporal_state (sx);
755
756 /* Should we count the first valid date we encounter? Only if the
757 * SX has not yet occurred so far, or if its last valid date was
758 * before the start date. */
759 countFirstDate = !g_date_valid(&tmpState->last_date)
760 || (g_date_compare(&tmpState->last_date, start_date) < 0);
761
762 /* No valid date? SX has never occurred so far. */
763 if (!g_date_valid(&tmpState->last_date))
764 {
765 /* SX has never occurred so far */
766 gnc_sx_incr_temporal_state (sx, tmpState);
767 if (xaccSchedXactionHasOccurDef(sx) && tmpState->num_occur_rem < 0)
768 {
769 g_free (tmpState);
770 return result;
771 }
772 }
773
774 /* Increase the tmpState until we are in our interval of
775 * interest. Only calculate anything if the sx hasn't already
776 * ended. */
777 while (g_date_compare(&tmpState->last_date, start_date) < 0)
778 {
779 gnc_sx_incr_temporal_state (sx, tmpState);
780 if (xaccSchedXactionHasOccurDef(sx) && tmpState->num_occur_rem < 0)
781 {
782 g_free (tmpState);
783 return result;
784 }
785 }
786
787 /* Now we are in our interval of interest. Increment the
788 * occurrence date until we are beyond the end of our
789 * interval. Make sure to check for invalid dates here: It means
790 * the SX has ended. */
791 while (g_date_valid(&tmpState->last_date)
792 && (g_date_compare(&tmpState->last_date, end_date) <= 0)
793 && (!xaccSchedXactionHasEndDate(sx)
794 || g_date_compare(&tmpState->last_date, xaccSchedXactionGetEndDate(sx)) <= 0)
796 /* The >=0 (i.e. the ==) is important here, otherwise
797 * we miss the last valid occurrence of a SX which is
798 * limited by num_occur */
799 || tmpState->num_occur_rem >= 0))
800 {
801 ++result;
802 gnc_sx_incr_temporal_state (sx, tmpState);
803 }
804
805 /* If the first valid date shouldn't be counted, decrease the
806 * result number by one. */
807 if (!countFirstDate && result > 0)
808 --result;
809
810 g_free (tmpState);
811 return result;
812}

◆ gnc_sx_get_schedule()

GList * gnc_sx_get_schedule ( const SchedXaction *  sx)
Returns
GList<Recurrence*>

Definition at line 524 of file SchedXaction.cpp.

525{
526 return sx->schedule;
527}

◆ gnc_sx_get_sxes_referencing_account()

GList * gnc_sx_get_sxes_referencing_account ( QofBook book,
Account acct 
)
Returns
The list of SXes which reference the given Account. Caller should free this list.

Definition at line 365 of file SX-book.cpp.

366{
367 GList *rtn = NULL;
368 const GncGUID *acct_guid = qof_entity_get_guid(QOF_INSTANCE(acct));
369 GList *sx_list;
370 SchedXactions *sxactions = gnc_book_get_schedxactions(book);
371 g_return_val_if_fail( sxactions != NULL, rtn);
372 for (sx_list = sxactions->sx_list; sx_list != NULL; sx_list = sx_list->next)
373 {
374 SchedXaction *sx = (SchedXaction*)sx_list->data;
375 GList *splits = xaccSchedXactionGetSplits(sx);
376 for (GList *node = splits; node; node = node->next)
377 {
378 Split *s = (Split*)node->data;
379 GncGUID *guid = NULL;
380 qof_instance_get (QOF_INSTANCE (s), "sx-account", &guid, NULL);
381 if (guid_equal(acct_guid, guid))
382 rtn = g_list_prepend (rtn, sx);
383
384 guid_free (guid);
385 }
386 g_list_free (splits);
387 }
388 return g_list_reverse (rtn);
389}
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Given two GUIDs, return TRUE if they are non-NULL and equal.
Definition guid.cpp:237
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
const GncGUID * qof_entity_get_guid(gconstpointer ent)
The type used to store guids in C.
Definition guid.h:75

◆ gnc_sx_incr_temporal_state()

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.

The SX is unchanged.

Definition at line 1045 of file SchedXaction.cpp.

1046{
1047 g_return_if_fail(tsd != NULL);
1048 tsd->last_date = xaccSchedXactionGetNextInstance (sx, tsd);
1050 {
1051 --tsd->num_occur_rem;
1052 }
1053 ++tsd->num_inst;
1054}

◆ gnc_sx_remove_defer_instance()

void gnc_sx_remove_defer_instance ( SchedXaction *  sx,
void *  deferStateData 
)

Removes an instance from the deferred list.

If the instance is no longer useful; gnc_sx_destroy_temporal_state() it.

The saved SXTmpStateData existed for comparison only, so destroy it.

Definition at line 1111 of file SchedXaction.cpp.

1112{
1113 GList *found_by_value;
1114
1115 found_by_value = g_list_find_custom(
1116 sx->deferredList, deferStateData, _temporal_state_data_cmp);
1117 if (found_by_value == NULL)
1118 {
1119 g_warning("unable to find deferred instance");
1120 return;
1121 }
1122
1123 g_free (found_by_value->data);
1124 sx->deferredList = g_list_delete_link(sx->deferredList, found_by_value);
1125}

◆ gnc_sx_set_instance_count()

void gnc_sx_set_instance_count ( SchedXaction *  sx,
gint  instanceNum 
)

Sets the instance count to something other than the default.

As the default is the incorrect value '0', callers should DTRT here.

Definition at line 948 of file SchedXaction.cpp.

949{
950 g_return_if_fail(sx);
951 if (sx->instance_num == instance_num)
952 return;
953 gnc_sx_begin_edit(sx);
954 sx->instance_num = instance_num;
955 qof_instance_set_dirty(&sx->inst);
956 gnc_sx_commit_edit(sx);
957}

◆ gnc_sx_set_schedule()

void gnc_sx_set_schedule ( SchedXaction *  sx,
GList *  schedule 
)
Parameters
[in]scheduleA GList<Recurrence*>

Definition at line 530 of file SchedXaction.cpp.

531{
532 g_return_if_fail(sx);
533 gnc_sx_begin_edit(sx);
534 sx->schedule = schedule;
535 qof_instance_set_dirty(&sx->inst);
536 gnc_sx_commit_edit(sx);
537}

◆ gnc_sxes_add_sx()

void gnc_sxes_add_sx ( SchedXactions *  sxes,
SchedXaction *  sx 
)

Definition at line 212 of file SX-book.cpp.

213{
214 if (g_list_find(sxes->sx_list, sx) != NULL)
215 return;
216 sxes->sx_list = g_list_append(sxes->sx_list, sx);
217 qof_event_gen(&sxes->inst, GNC_EVENT_ITEM_ADDED, (gpointer)sx);
218}
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Definition qofevent.cpp:231
#define GNC_EVENT_ITEM_ADDED
These events are used when a split is added to an account.
Definition gnc-event.h:45

◆ gnc_sxes_del_sx()

void gnc_sxes_del_sx ( SchedXactions *  sxes,
SchedXaction *  sx 
)

Definition at line 221 of file SX-book.cpp.

222{
223 GList *to_remove;
224 to_remove = g_list_find(sxes->sx_list, sx);
225 if (to_remove == NULL)
226 return;
227 sxes->sx_list = g_list_delete_link(sxes->sx_list, to_remove);
228 qof_event_gen(&sxes->inst, GNC_EVENT_ITEM_REMOVED, (gpointer)sx);
229}

◆ sx_set_template_account()

void sx_set_template_account ( SchedXaction *  sx,
Account account 
)

Definition at line 441 of file SchedXaction.cpp.

442{
443 Account *old;
444
445 old = sx->template_acct;
446 sx->template_acct = account;
447 if (old)
448 {
451 }
452}
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Definition Account.cpp:1475
void xaccAccountDestroy(Account *acc)
The xaccAccountDestroy() routine can be used to get rid of an account.
Definition Account.cpp:1590

◆ SXRegister()

gboolean SXRegister ( void  )

QOF registration.

Definition at line 1191 of file SchedXaction.cpp.

1192{
1193 static QofParam params[] =
1194 {
1195 {
1196 GNC_SX_NAME, QOF_TYPE_STRING, (QofAccessFunc)xaccSchedXactionGetName,
1198 },
1199 {
1200 GNC_SX_START_DATE, QOF_TYPE_DATE, (QofAccessFunc)xaccSchedXactionGetStartDateTT,
1201 (QofSetterFunc)xaccSchedXactionSetStartDateTT
1202 },
1203 {
1204 GNC_SX_LAST_DATE, QOF_TYPE_DATE, (QofAccessFunc)xaccSchedXactionGetLastOccurDateTT,
1205 (QofSetterFunc)xaccSchedXactionSetLastOccurDateTT
1206 },
1207 {
1208 GNC_SX_NUM_OCCUR, QOF_TYPE_INT64, (QofAccessFunc)xaccSchedXactionGetNumOccur,
1210 },
1211 {
1212 GNC_SX_REM_OCCUR, QOF_TYPE_INT64, (QofAccessFunc)xaccSchedXactionGetRemOccur,
1213 (QofSetterFunc)xaccSchedXactionSetRemOccur
1214 },
1215 { QOF_PARAM_BOOK, QOF_ID_BOOK, (QofAccessFunc)qof_instance_get_book, NULL },
1216 { QOF_PARAM_GUID, QOF_TYPE_GUID, (QofAccessFunc)qof_instance_get_guid, NULL },
1217 { NULL },
1218 };
1219 qof_class_register(GNC_SX_ID, NULL, params);
1220 return qof_object_register(&SXDesc);
1221}
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
The QofAccessFunc defines an arbitrary function pointer for access functions.
Definition qofclass.h:123
void(* QofSetterFunc)(gpointer, gpointer)
The QofSetterFunc defines an function pointer for parameter setters.
Definition qofclass.h:130
void qof_class_register(QofIdTypeConst obj_name, QofSortFunc default_sort_function, const QofParam *params)
This function registers a new object class with the Qof subsystem.
Definition qofclass.cpp:86
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
gboolean qof_object_register(const QofObject *object)
Register new types of object objects.
#define QOF_PARAM_BOOK
"Known" Object Parameters – all objects must support these
Definition qofquery.h:108

◆ xaccSchedXactionDestroy()

void xaccSchedXactionDestroy ( SchedXaction *  sx)

Cleans up and frees a SchedXaction and its associated data.

Definition at line 455 of file SchedXaction.cpp.

456{
457 qof_instance_set_destroying( QOF_INSTANCE(sx), TRUE );
458 gnc_sx_commit_edit( sx );
459}

◆ xaccSchedXactionGetAdvanceCreation()

gint xaccSchedXactionGetAdvanceCreation ( const SchedXaction *  sx)

Definition at line 856 of file SchedXaction.cpp.

857{
858 return sx->advanceCreateDays;
859}

◆ xaccSchedXactionGetAdvanceReminder()

gint xaccSchedXactionGetAdvanceReminder ( const SchedXaction *  sx)

Definition at line 871 of file SchedXaction.cpp.

872{
873 return sx->advanceRemindDays;
874}

◆ xaccSchedXactionGetAutoCreate()

void xaccSchedXactionGetAutoCreate ( const SchedXaction *  sx,
gboolean *  outAutoCreate,
gboolean *  outNotify 
)

Definition at line 830 of file SchedXaction.cpp.

833{
834 if (outAutoCreate != NULL)
835 *outAutoCreate = sx->autoCreateOption;
836 if (outNotify != NULL)
837 *outNotify = sx->autoCreateNotify;
838 return;
839}

◆ xaccSchedXactionGetEnabled()

gboolean xaccSchedXactionGetEnabled ( const SchedXaction *  sx)

Definition at line 815 of file SchedXaction.cpp.

816{
817 return sx->enabled;
818}

◆ xaccSchedXactionGetEndDate()

const GDate * xaccSchedXactionGetEndDate ( const SchedXaction *  sx)

Returns invalid date when there is no end-date specified.

Definition at line 619 of file SchedXaction.cpp.

620{
621 g_assert (sx);
622 return &sx->end_date;
623}

◆ xaccSchedXactionGetLastOccurDate()

const GDate * xaccSchedXactionGetLastOccurDate ( const SchedXaction *  sx)

Definition at line 651 of file SchedXaction.cpp.

652{
653 return &sx->last_date;
654}

◆ xaccSchedXactionGetLastOccurDateTT()

time64 xaccSchedXactionGetLastOccurDateTT ( const SchedXaction *  sx)

Definition at line 657 of file SchedXaction.cpp.

658{
659 return gdate_to_time64(sx->last_date);
660}
time64 gdate_to_time64(GDate d)
Turns a GDate into a time64, returning the first second of the day.

◆ xaccSchedXactionGetName()

gchar * xaccSchedXactionGetName ( const SchedXaction *  sx)

Definition at line 540 of file SchedXaction.cpp.

541{
542 return sx->name;
543}

◆ xaccSchedXactionGetNextInstance()

GDate xaccSchedXactionGetNextInstance ( const SchedXaction *  sx,
SXTmpStateData stateData 
)

Returns the next occurrence of a scheduled transaction.

If the transaction hasn't occurred, then it's based off the start date. Otherwise, it's based off the last-occurrence date.

If state data is NULL, the current value of the SX is used for computation. Otherwise, the values in the state data are used. This allows the caller to correctly create a set of instances into the future for possible action without modifying the SX state until action is actually taken.

Definition at line 886 of file SchedXaction.cpp.

887{
888 GDate prev_occur, next_occur;
889
890 g_date_clear( &prev_occur, 1 );
891 if ( tsd != NULL )
892 prev_occur = tsd->last_date;
893
894 /* If prev_occur is in the "cleared" state and sx->start_date isn't, then
895 * we're at the beginning. We want to pretend prev_occur is the day before
896 * the start_date in case the start_date is today so that the SX will fire
897 * today. If start_date isn't valid either then the SX will fire anyway, no
898 * harm done. prev_occur cannot be before start_date either.
899 */
900 if (g_date_valid (&sx->start_date) && (!g_date_valid ( &prev_occur ) || g_date_compare (&prev_occur, &sx->start_date)<0))
901 {
902 /* We must be at the beginning. */
903 prev_occur = sx->start_date;
904 g_date_subtract_days (&prev_occur, 1 );
905 }
906
907 recurrenceListNextInstance(sx->schedule, &prev_occur, &next_occur);
908
909 if ( xaccSchedXactionHasEndDate( sx ) )
910 {
911 const GDate *end_date = xaccSchedXactionGetEndDate( sx );
912 if ( g_date_compare( &next_occur, end_date ) > 0 )
913 {
914 g_date_clear( &next_occur, 1 );
915 }
916 }
917 else if ( xaccSchedXactionHasOccurDef( sx ) )
918 {
919 if ((tsd && tsd->num_occur_rem == 0) ||
920 (!tsd && sx->num_occurances_remain == 0 ))
921 {
922 g_date_clear( &next_occur, 1 );
923 }
924 }
925 return next_occur;
926}

◆ xaccSchedXactionGetNumOccur()

gint xaccSchedXactionGetNumOccur ( const SchedXaction *  sx)

Definition at line 697 of file SchedXaction.cpp.

698{
699 return sx->num_occurances_total;
700}

◆ xaccSchedXactionGetRemOccur()

gint xaccSchedXactionGetRemOccur ( const SchedXaction *  sx)

Definition at line 714 of file SchedXaction.cpp.

715{
716 return sx->num_occurances_remain;
717}

◆ xaccSchedXactionGetSplits()

GList * xaccSchedXactionGetSplits ( const SchedXaction *  sx)

Definition at line 960 of file SchedXaction.cpp.

961{
962 g_return_val_if_fail( sx, NULL );
963 return xaccAccountGetSplitList(sx->template_acct);
964}
SplitList * xaccAccountGetSplitList(const Account *acc)
The xaccAccountGetSplitList() routine returns a pointer to a GList of the splits in the account.
Definition Account.cpp:3949

◆ xaccSchedXactionGetStartDate()

const GDate * xaccSchedXactionGetStartDate ( const SchedXaction *  sx)

Definition at line 561 of file SchedXaction.cpp.

562{
563 g_assert (sx);
564 return &sx->start_date;
565}

◆ xaccSchedXactionGetStartDateTT()

time64 xaccSchedXactionGetStartDateTT ( const SchedXaction *  sx)

Definition at line 568 of file SchedXaction.cpp.

569{
570 g_assert (sx);
571 return gdate_to_time64(sx->start_date);
572}

◆ xaccSchedXactionHasEndDate()

int xaccSchedXactionHasEndDate ( const SchedXaction *  sx)

Definition at line 613 of file SchedXaction.cpp.

614{
615 return sx != NULL && g_date_valid( &sx->end_date );
616}

◆ xaccSchedXactionHasOccurDef()

gboolean xaccSchedXactionHasOccurDef ( const SchedXaction *  sx)

Returns true if the scheduled transaction has a defined number of occurrences, false if not.

Definition at line 691 of file SchedXaction.cpp.

692{
693 return ( xaccSchedXactionGetNumOccur( sx ) != 0 );
694}

◆ xaccSchedXactionMalloc()

SchedXaction * xaccSchedXactionMalloc ( QofBook book)

Creates and initializes a scheduled transaction.

Definition at line 410 of file SchedXaction.cpp.

411{
412 SchedXaction *sx;
413
414 g_return_val_if_fail (book, NULL);
415
416 sx = GNC_SX(g_object_new(GNC_TYPE_SCHEDXACTION, NULL));
417 xaccSchedXactionInit( sx, book );
418 qof_event_gen( &sx->inst, QOF_EVENT_CREATE , NULL);
419
420 return sx;
421}

◆ xaccSchedXactionSetAdvanceCreation()

void xaccSchedXactionSetAdvanceCreation ( SchedXaction *  sx,
gint  createDays 
)

Definition at line 862 of file SchedXaction.cpp.

863{
864 gnc_sx_begin_edit(sx);
865 sx->advanceCreateDays = createDays;
866 qof_instance_set_dirty(&sx->inst);
867 gnc_sx_commit_edit(sx);
868}

◆ xaccSchedXactionSetAdvanceReminder()

void xaccSchedXactionSetAdvanceReminder ( SchedXaction *  sx,
gint  reminderDays 
)

Definition at line 877 of file SchedXaction.cpp.

878{
879 gnc_sx_begin_edit(sx);
880 sx->advanceRemindDays = reminderDays;
881 qof_instance_set_dirty(&sx->inst);
882 gnc_sx_commit_edit(sx);
883}

◆ xaccSchedXactionSetAutoCreate()

void xaccSchedXactionSetAutoCreate ( SchedXaction *  sx,
gboolean  newAutoCreate,
gboolean  newNotify 
)

Definition at line 842 of file SchedXaction.cpp.

845{
846
847 gnc_sx_begin_edit(sx);
848 sx->autoCreateOption = newAutoCreate;
849 sx->autoCreateNotify = newNotify;
850 qof_instance_set_dirty(&sx->inst);
851 gnc_sx_commit_edit(sx);
852 return;
853}

◆ xaccSchedXactionSetEnabled()

void xaccSchedXactionSetEnabled ( SchedXaction *  sx,
gboolean  newEnabled 
)

Definition at line 821 of file SchedXaction.cpp.

822{
823 gnc_sx_begin_edit(sx);
824 sx->enabled = newEnabled;
825 qof_instance_set_dirty(&sx->inst);
826 gnc_sx_commit_edit(sx);
827}

◆ xaccSchedXactionSetEndDate()

void xaccSchedXactionSetEndDate ( SchedXaction *  sx,
const GDate *  newEnd 
)

Set to an invalid GDate to turn off 'end-date' definition.

Definition at line 626 of file SchedXaction.cpp.

627{
628/* Note that an invalid GDate IS a permissible value: It means that
629 * the SX is to run "forever". See gnc_sxed_save_sx() and
630 * schedXact_editor_populate() in dialog-sx-editor.c.
631 */
632 if (newEnd == NULL ||
633 (g_date_valid(newEnd) && g_date_compare( newEnd, &sx->start_date ) < 0 ))
634 {
635 /* XXX: I reject the bad data - is this the right
636 * thing to do <rgmerk>.
637 * This warning is only human readable - the caller
638 * doesn't know the call failed. This is bad
639 */
640 g_critical("Bad End Date: Invalid or before Start Date");
641 return;
642 }
643
644 gnc_sx_begin_edit(sx);
645 sx->end_date = *newEnd;
646 qof_instance_set_dirty(&sx->inst);
647 gnc_sx_commit_edit(sx);
648}

◆ xaccSchedXactionSetLastOccurDate()

void xaccSchedXactionSetLastOccurDate ( SchedXaction *  sx,
const GDate *  newLastOccur 
)

Definition at line 663 of file SchedXaction.cpp.

664{
665 g_return_if_fail (new_last_occur != NULL);
666 if (g_date_valid(&sx->last_date)
667 && g_date_compare(&sx->last_date, new_last_occur) == 0)
668 return;
669 gnc_sx_begin_edit(sx);
670 sx->last_date = *new_last_occur;
671 qof_instance_set_dirty(&sx->inst);
672 gnc_sx_commit_edit(sx);
673}

◆ xaccSchedXactionSetLastOccurDateTT()

void xaccSchedXactionSetLastOccurDateTT ( SchedXaction *  sx,
const time64  newLastOccur 
)

Definition at line 676 of file SchedXaction.cpp.

677{
678 GDate last_occur;
679 g_return_if_fail (new_last_occur != INT64_MAX);
680 gnc_gdate_set_time64(&last_occur, new_last_occur);
681 if (g_date_valid(&sx->last_date)
682 && g_date_compare(&sx->last_date, &last_occur) == 0)
683 return;
684 gnc_sx_begin_edit(sx);
685 sx->last_date = last_occur;
686 qof_instance_set_dirty(&sx->inst);
687 gnc_sx_commit_edit(sx);
688}
void gnc_gdate_set_time64(GDate *gd, time64 time)
Set a GDate to a time64.

◆ xaccSchedXactionSetName()

void xaccSchedXactionSetName ( SchedXaction *  sx,
const gchar *  newName 
)

A copy of the name is made.

Definition at line 546 of file SchedXaction.cpp.

547{
548 g_return_if_fail( newName != NULL );
549 gnc_sx_begin_edit(sx);
550 if ( sx->name != NULL )
551 {
552 g_free( sx->name );
553 sx->name = NULL;
554 }
555 sx->name = g_strdup( newName );
556 qof_instance_set_dirty(&sx->inst);
557 gnc_sx_commit_edit(sx);
558}

◆ xaccSchedXactionSetNumOccur()

void xaccSchedXactionSetNumOccur ( SchedXaction *  sx,
gint  numNum 
)

Set to '0' to turn off number-of-occurrences definition.

Definition at line 703 of file SchedXaction.cpp.

704{
705 if (sx->num_occurances_total == new_num)
706 return;
707 gnc_sx_begin_edit(sx);
708 sx->num_occurances_remain = sx->num_occurances_total = new_num;
709 qof_instance_set_dirty(&sx->inst);
710 gnc_sx_commit_edit(sx);
711}

◆ xaccSchedXactionSetRemOccur()

void xaccSchedXactionSetRemOccur ( SchedXaction *  sx,
gint  numRemain 
)

Definition at line 720 of file SchedXaction.cpp.

721{
722 /* FIXME This condition can be tightened up */
723 if (num_remain > sx->num_occurances_total)
724 {
725 g_warning("number remaining [%d] > total occurrences [%d]",
726 num_remain, sx->num_occurances_total);
727 }
728 else
729 {
730 if (num_remain == sx->num_occurances_remain)
731 return;
732 gnc_sx_begin_edit(sx);
733 sx->num_occurances_remain = num_remain;
734 qof_instance_set_dirty(&sx->inst);
735 gnc_sx_commit_edit(sx);
736 }
737}

◆ xaccSchedXactionSetStartDate()

void xaccSchedXactionSetStartDate ( SchedXaction *  sx,
const GDate *  newStart 
)

Definition at line 575 of file SchedXaction.cpp.

576{
577 if ( newStart == NULL || !g_date_valid( newStart ))
578 {
579 /* XXX: I reject the bad data - is this the right
580 * thing to do <rgmerk>.
581 * This warning is only human readable - the caller
582 * doesn't know the call failed. This is bad
583 */
584 g_critical("Invalid Start Date");
585 return;
586 }
587 gnc_sx_begin_edit(sx);
588 sx->start_date = *newStart;
589 qof_instance_set_dirty(&sx->inst);
590 gnc_sx_commit_edit(sx);
591}

◆ xaccSchedXactionSetStartDateTT()

void xaccSchedXactionSetStartDateTT ( SchedXaction *  sx,
const time64  newStart 
)

Definition at line 594 of file SchedXaction.cpp.

595{
596 if ( newStart == INT64_MAX )
597 {
598 /* XXX: I reject the bad data - is this the right
599 * thing to do <rgmerk>.
600 * This warning is only human readable - the caller
601 * doesn't know the call failed. This is bad
602 */
603 g_critical("Invalid Start Date");
604 return;
605 }
606 gnc_sx_begin_edit(sx);
607 gnc_gdate_set_time64(&sx->start_date, newStart);
608 qof_instance_set_dirty(&sx->inst);
609 gnc_sx_commit_edit(sx);
610}