27 #include <glib/gi18n.h> 35 #include "SX-ttinfo.h" 39 #include "engine-helpers.h" 40 #include "qofinstance-p.h" 43 #define G_LOG_DOMAIN "gnc.engine.sx" 52 PROP_LAST_OCCURANCE_DATE,
56 PROP_AUTO_CREATE_NOTIFY,
57 PROP_ADVANCE_CREATION_DAYS,
58 PROP_ADVANCE_REMINDER_DAYS,
64 G_DEFINE_TYPE(SchedXaction, gnc_schedxaction, QOF_TYPE_INSTANCE);
67 gnc_schedxaction_init(SchedXaction* sx)
71 g_date_clear( &sx->last_date, 1 );
72 g_date_clear( &sx->start_date, 1 );
73 g_date_clear( &sx->end_date, 1 );
76 sx->num_occurances_total = 0;
77 sx->autoCreateOption = FALSE;
78 sx->autoCreateNotify = FALSE;
79 sx->advanceCreateDays = 0;
80 sx->advanceRemindDays = 0;
82 sx->deferredList = NULL;
86 gnc_schedxaction_dispose(GObject *sxp)
88 G_OBJECT_CLASS(gnc_schedxaction_parent_class)->dispose(sxp);
92 gnc_schedxaction_finalize(GObject* sxp)
94 G_OBJECT_CLASS(gnc_schedxaction_parent_class)->finalize(sxp);
104 gnc_schedxaction_get_property (GObject *
object,
111 g_return_if_fail(GNC_IS_SCHEDXACTION(
object));
113 sx = GNC_SCHEDXACTION(
object);
117 g_value_set_string(value, sx->name);
120 g_value_set_boolean(value, sx->enabled);
122 case PROP_NUM_OCCURANCE:
123 g_value_set_int(value, sx->num_occurances_total);
125 case PROP_REM_OCCURANCE:
126 g_value_set_int(value, sx->num_occurances_remain);
128 case PROP_AUTO_CREATE:
129 g_value_set_boolean(value, sx->autoCreateOption);
131 case PROP_AUTO_CREATE_NOTIFY:
132 g_value_set_boolean(value, sx->autoCreateNotify);
134 case PROP_ADVANCE_CREATION_DAYS:
135 g_value_set_int(value, sx->advanceCreateDays);
137 case PROP_ADVANCE_REMINDER_DAYS:
138 g_value_set_int(value, sx->advanceRemindDays);
140 case PROP_START_DATE:
141 g_value_set_boxed(value, &sx->start_date);
146 if (g_date_valid (&sx->end_date))
147 g_value_set_boxed(value, &sx->end_date);
149 case PROP_LAST_OCCURANCE_DATE:
152 if (g_date_valid (&sx->last_date))
153 g_value_set_boxed(value, &sx->last_date);
155 case PROP_INSTANCE_COUNT:
156 g_value_set_int(value, sx->instance_num);
158 case PROP_TEMPLATE_ACCOUNT:
159 g_value_take_object(value, sx->template_acct);
162 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
168 gnc_schedxaction_set_property (GObject *
object,
175 g_return_if_fail(GNC_IS_SCHEDXACTION(
object));
177 sx = GNC_SCHEDXACTION(
object);
178 g_assert (qof_instance_get_editlevel(sx));
186 xaccSchedXactionSetEnabled(sx, g_value_get_boolean(value));
188 case PROP_NUM_OCCURANCE:
191 case PROP_REM_OCCURANCE:
192 xaccSchedXactionSetRemOccur(sx, g_value_get_int(value));
194 case PROP_AUTO_CREATE:
195 xaccSchedXactionSetAutoCreate(sx, g_value_get_boolean(value), sx->autoCreateNotify);
197 case PROP_AUTO_CREATE_NOTIFY:
198 xaccSchedXactionSetAutoCreate(sx, sx->autoCreateOption, g_value_get_boolean(value));
200 case PROP_ADVANCE_CREATION_DAYS:
201 xaccSchedXactionSetAdvanceCreation(sx, g_value_get_int(value));
203 case PROP_ADVANCE_REMINDER_DAYS:
204 xaccSchedXactionSetAdvanceReminder(sx, g_value_get_int(value));
206 case PROP_START_DATE:
210 xaccSchedXactionSetStartDate(sx, g_value_get_boxed(value));
218 case PROP_LAST_OCCURANCE_DATE:
222 xaccSchedXactionSetLastOccurDate(sx, g_value_get_boxed(value));
224 case PROP_INSTANCE_COUNT:
227 case PROP_TEMPLATE_ACCOUNT:
228 sx_set_template_account(sx, g_value_get_object(value));
231 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
237 gnc_schedxaction_class_init (SchedXactionClass *klass)
239 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
241 gobject_class->dispose = gnc_schedxaction_dispose;
242 gobject_class->finalize = gnc_schedxaction_finalize;
243 gobject_class->set_property = gnc_schedxaction_set_property;
244 gobject_class->get_property = gnc_schedxaction_get_property;
246 g_object_class_install_property
249 g_param_spec_string (
"name",
250 "Scheduled Transaction Name",
251 "The name is an arbitrary string " 252 "assigned by the user. It is intended to " 253 "a short, 5 to 30 character long string " 254 "that is displayed by the GUI.",
258 g_object_class_install_property
261 g_param_spec_boolean (
"enabled",
263 "TRUE if the scheduled transaction is enabled.",
267 g_object_class_install_property
270 g_param_spec_int (
"num-occurance",
271 "Number of occurrences",
272 "Total number of occurrences for this scheduled transaction.",
278 g_object_class_install_property
281 g_param_spec_int (
"rem-occurance",
282 "Number of occurrences remaining",
283 "Remaining number of occurrences for this scheduled transaction.",
289 g_object_class_install_property
292 g_param_spec_boolean (
"auto-create",
294 "TRUE if the transaction will be automatically " 295 "created when its time comes.",
299 g_object_class_install_property
301 PROP_AUTO_CREATE_NOTIFY,
302 g_param_spec_boolean (
"auto-create-notify",
303 "Auto-create-notify",
304 "TRUE if the the user will be notified when the transaction " 305 "is automatically created.",
309 g_object_class_install_property
311 PROP_ADVANCE_CREATION_DAYS,
312 g_param_spec_int (
"advance-creation-days",
313 "Days in advance to create",
314 "Number of days in advance to create this scheduled transaction.",
320 g_object_class_install_property
322 PROP_ADVANCE_REMINDER_DAYS,
323 g_param_spec_int (
"advance-reminder-days",
324 "Days in advance to remind",
325 "Number of days in advance to remind about this scheduled transaction.",
331 g_object_class_install_property
334 g_param_spec_boxed(
"start-date",
336 "Date for the first occurrence for the scheduled transaction.",
340 g_object_class_install_property
343 g_param_spec_boxed(
"end-date",
345 "Date for the scheduled transaction to end.",
349 g_object_class_install_property
351 PROP_LAST_OCCURANCE_DATE,
352 g_param_spec_boxed(
"last-occurance-date",
353 "Last Occurrence Date",
354 "Date for the last occurrence of the scheduled transaction.",
358 g_object_class_install_property
361 g_param_spec_int (
"instance-count",
363 "Number of instances of this scheduled transaction.",
369 g_object_class_install_property
371 PROP_TEMPLATE_ACCOUNT,
372 g_param_spec_object(
"template-account",
374 "Account which holds the template transactions.",
380 xaccSchedXactionInit(SchedXaction *sx, QofBook *book)
397 GNC_COMMODITY_NS_TEMPLATE,
"template") );
409 g_return_val_if_fail (book, NULL);
411 sx = g_object_new(GNC_TYPE_SCHEDXACTION, NULL);
412 xaccSchedXactionInit( sx, book );
419 sxprivTransMapDelete( gpointer data, gpointer user_data )
421 Transaction *t = (Transaction *) data;
429 delete_template_trans(SchedXaction *sx)
431 GList *templ_acct_splits, *curr_split_listref;
433 Transaction *split_trans;
434 GList *templ_acct_transactions = NULL;
439 for (curr_split_listref = templ_acct_splits;
441 curr_split_listref = curr_split_listref->next)
443 curr_split = (Split *) curr_split_listref->data;
445 if (! (g_list_find(templ_acct_transactions, split_trans)))
447 templ_acct_transactions
448 = g_list_prepend(templ_acct_transactions, split_trans);
452 g_list_foreach(templ_acct_transactions,
453 sxprivTransMapDelete,
456 g_list_free (templ_acct_transactions);
461 sx_set_template_account (SchedXaction *sx,
Account *account)
465 old = sx->template_acct;
466 sx->template_acct = account;
477 qof_instance_set_destroying( QOF_INSTANCE(sx), TRUE );
478 gnc_sx_commit_edit( sx );
482 xaccSchedXactionFree( SchedXaction *sx )
486 if ( sx == NULL )
return;
498 delete_template_trans( sx );
512 for ( l = sx->deferredList; l; l = l->next )
517 if ( sx->deferredList )
519 g_list_free( sx->deferredList );
520 sx->deferredList = NULL;
524 g_object_unref( sx );
530 gnc_sx_begin_edit (SchedXaction *sx)
537 xaccSchedXactionFree( GNC_SX(inst) );
542 g_critical(
"Failed to commit: %d", errcode);
543 gnc_engine_signal_commit_error( errcode );
552 gnc_sx_commit_edit (SchedXaction *sx)
569 g_return_if_fail(sx);
570 gnc_sx_begin_edit(sx);
571 sx->schedule = schedule;
572 qof_instance_set_dirty(&sx->inst);
573 gnc_sx_commit_edit(sx);
577 xaccSchedXactionGetName(
const SchedXaction *sx )
585 g_return_if_fail( newName != NULL );
586 gnc_sx_begin_edit(sx);
587 if ( sx->name != NULL )
592 sx->name = g_strdup( newName );
593 qof_instance_set_dirty(&sx->inst);
594 gnc_sx_commit_edit(sx);
598 xaccSchedXactionGetStartDate(
const SchedXaction *sx )
601 return &sx->start_date;
605 xaccSchedXactionGetStartDateTT(
const SchedXaction *sx )
612 xaccSchedXactionSetStartDate( SchedXaction *sx,
const GDate* newStart )
614 if ( newStart == NULL || !g_date_valid( newStart ))
621 g_critical(
"Invalid Start Date");
624 gnc_sx_begin_edit(sx);
625 sx->start_date = *newStart;
626 qof_instance_set_dirty(&sx->inst);
627 gnc_sx_commit_edit(sx);
631 xaccSchedXactionSetStartDateTT( SchedXaction *sx,
const time64 newStart )
633 if ( newStart == INT64_MAX )
640 g_critical(
"Invalid Start Date");
643 gnc_sx_begin_edit(sx);
645 qof_instance_set_dirty(&sx->inst);
646 gnc_sx_commit_edit(sx);
650 xaccSchedXactionHasEndDate(
const SchedXaction *sx )
652 return sx != NULL && g_date_valid( &sx->end_date );
659 return &sx->end_date;
669 if (newEnd == NULL ||
670 (g_date_valid(newEnd) && g_date_compare( newEnd, &sx->start_date ) < 0 ))
677 g_critical(
"Bad End Date: Invalid or before Start Date");
681 gnc_sx_begin_edit(sx);
682 sx->end_date = *newEnd;
683 qof_instance_set_dirty(&sx->inst);
684 gnc_sx_commit_edit(sx);
688 xaccSchedXactionGetLastOccurDate(
const SchedXaction *sx )
690 return &sx->last_date;
694 xaccSchedXactionGetLastOccurDateTT(
const SchedXaction *sx )
700 xaccSchedXactionSetLastOccurDate(SchedXaction *sx,
const GDate* new_last_occur)
702 g_return_if_fail (new_last_occur != NULL);
703 if (g_date_valid(&sx->last_date)
704 && g_date_compare(&sx->last_date, new_last_occur) == 0)
706 gnc_sx_begin_edit(sx);
707 sx->last_date = *new_last_occur;
708 qof_instance_set_dirty(&sx->inst);
709 gnc_sx_commit_edit(sx);
713 xaccSchedXactionSetLastOccurDateTT(SchedXaction *sx,
time64 new_last_occur)
716 g_return_if_fail (new_last_occur != INT64_MAX);
718 if (g_date_valid(&sx->last_date)
719 && g_date_compare(&sx->last_date, &last_occur) == 0)
721 gnc_sx_begin_edit(sx);
722 sx->last_date = last_occur;
723 qof_instance_set_dirty(&sx->inst);
724 gnc_sx_commit_edit(sx);
730 return ( xaccSchedXactionGetNumOccur( sx ) != 0 );
734 xaccSchedXactionGetNumOccur(
const SchedXaction *sx )
736 return sx->num_occurances_total;
742 if (sx->num_occurances_total == new_num)
744 gnc_sx_begin_edit(sx);
745 sx->num_occurances_remain = sx->num_occurances_total = new_num;
746 qof_instance_set_dirty(&sx->inst);
747 gnc_sx_commit_edit(sx);
751 xaccSchedXactionGetRemOccur(
const SchedXaction *sx )
753 return sx->num_occurances_remain;
757 xaccSchedXactionSetRemOccur(SchedXaction *sx, gint num_remain)
760 if (num_remain > sx->num_occurances_total)
762 g_warning(
"number remaining [%d] > total occurrences [%d]",
763 num_remain, sx->num_occurances_total);
767 if (num_remain == sx->num_occurances_remain)
769 gnc_sx_begin_edit(sx);
770 sx->num_occurances_remain = num_remain;
771 qof_instance_set_dirty(&sx->inst);
772 gnc_sx_commit_edit(sx);
780 gboolean countFirstDate;
784 && xaccSchedXactionGetRemOccur(sx) <= 0)
785 || (xaccSchedXactionHasEndDate(sx)
796 countFirstDate = !g_date_valid(&tmpState->last_date)
797 || (g_date_compare(&tmpState->last_date, start_date) < 0);
800 if (!g_date_valid(&tmpState->last_date))
814 while (g_date_compare(&tmpState->last_date, start_date) < 0)
828 while (g_date_valid(&tmpState->last_date)
829 && (g_date_compare(&tmpState->last_date, end_date) <= 0)
830 && (!xaccSchedXactionHasEndDate(sx)
836 || tmpState->num_occur_rem >= 0))
844 if (!countFirstDate && result > 0)
852 xaccSchedXactionGetEnabled(
const SchedXaction *sx )
858 xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled)
860 gnc_sx_begin_edit(sx);
861 sx->enabled = newEnabled;
862 qof_instance_set_dirty(&sx->inst);
863 gnc_sx_commit_edit(sx);
867 xaccSchedXactionGetAutoCreate(
const SchedXaction *sx,
868 gboolean *outAutoCreate,
869 gboolean *outNotify )
871 if (outAutoCreate != NULL)
872 *outAutoCreate = sx->autoCreateOption;
873 if (outNotify != NULL)
874 *outNotify = sx->autoCreateNotify;
879 xaccSchedXactionSetAutoCreate( SchedXaction *sx,
880 gboolean newAutoCreate,
884 gnc_sx_begin_edit(sx);
885 sx->autoCreateOption = newAutoCreate;
886 sx->autoCreateNotify = newNotify;
887 qof_instance_set_dirty(&sx->inst);
888 gnc_sx_commit_edit(sx);
893 xaccSchedXactionGetAdvanceCreation(
const SchedXaction *sx )
895 return sx->advanceCreateDays;
899 xaccSchedXactionSetAdvanceCreation( SchedXaction *sx, gint createDays )
901 gnc_sx_begin_edit(sx);
902 sx->advanceCreateDays = createDays;
903 qof_instance_set_dirty(&sx->inst);
904 gnc_sx_commit_edit(sx);
908 xaccSchedXactionGetAdvanceReminder(
const SchedXaction *sx )
910 return sx->advanceRemindDays;
914 xaccSchedXactionSetAdvanceReminder( SchedXaction *sx, gint reminderDays )
916 gnc_sx_begin_edit(sx);
917 sx->advanceRemindDays = reminderDays;
918 qof_instance_set_dirty(&sx->inst);
919 gnc_sx_commit_edit(sx);
925 GDate prev_occur, next_occur;
927 g_date_clear( &prev_occur, 1 );
929 prev_occur = tsd->last_date;
937 if (g_date_valid (&sx->start_date) && (!g_date_valid ( &prev_occur ) || g_date_compare (&prev_occur, &sx->start_date)<0))
940 prev_occur = sx->start_date;
941 g_date_subtract_days (&prev_occur, 1 );
944 recurrenceListNextInstance(sx->schedule, &prev_occur, &next_occur);
946 if ( xaccSchedXactionHasEndDate( sx ) )
949 if ( g_date_compare( &next_occur, end_date ) > 0 )
951 g_date_clear( &next_occur, 1 );
956 if ((tsd && tsd->num_occur_rem == 0) ||
957 (!tsd && sx->num_occurances_remain == 0 ))
959 g_date_clear( &next_occur, 1 );
974 toRet = tsd->num_inst;
978 toRet = sx->instance_num;
987 g_return_if_fail(sx);
988 if (sx->instance_num == instance_num)
990 gnc_sx_begin_edit(sx);
991 sx->instance_num = instance_num;
992 qof_instance_set_dirty(&sx->inst);
993 gnc_sx_commit_edit(sx);
997 xaccSchedXactionGetSplits(
const SchedXaction *sx )
999 g_return_val_if_fail( sx, NULL );
1004 pack_split_info (TTSplitInfo *s_info,
Account *parent_acct,
1005 Transaction *parent_trans, QofBook *book)
1008 const gchar *credit_formula;
1009 const gchar *debit_formula;
1015 gnc_ttsplitinfo_get_memo(s_info));
1019 gnc_set_num_action(NULL, split, NULL,
1020 gnc_ttsplitinfo_get_action(s_info));
1025 credit_formula = gnc_ttsplitinfo_get_credit_formula(s_info);
1026 debit_formula = gnc_ttsplitinfo_get_debit_formula(s_info);
1029 "sx-credit-formula", credit_formula,
1030 "sx-debit-formula", debit_formula,
1031 "sx-account", acc_guid,
1042 Transaction *new_trans;
1044 TTSplitInfo *s_info;
1048 g_return_if_fail (book);
1051 delete_template_trans( sx );
1053 for (; t_t_list != NULL; t_t_list = t_t_list->next)
1055 tti = t_t_list->data;
1062 gnc_ttinfo_get_description(tti));
1068 gnc_set_num_action(new_trans, NULL,
1069 gnc_ttinfo_get_num(tti), NULL);
1072 gnc_ttinfo_get_currency(tti) );
1074 for (split_list = gnc_ttinfo_get_template_splits(tti);
1076 split_list = split_list->next)
1078 s_info = split_list->data;
1079 new_split = pack_split_info(s_info, sx->template_acct,
1092 if (g_date_valid (&(sx->last_date)))
1093 toRet->last_date = sx->last_date;
1095 g_date_set_dmy (&(toRet->last_date), 1, 1, 1970);
1096 toRet->num_occur_rem = sx->num_occurances_remain;
1097 toRet->num_inst = sx->instance_num;
1104 g_return_if_fail(tsd != NULL);
1108 --tsd->num_occur_rem;
1134 _temporal_state_data_cmp( gconstpointer a, gconstpointer b )
1139 if ( !tsd_a && !tsd_b )
1147 return g_date_compare( &tsd_a->last_date,
1148 &tsd_b->last_date );
1158 sx->deferredList = g_list_insert_sorted( sx->deferredList,
1160 _temporal_state_data_cmp );
1170 GList *found_by_value;
1172 found_by_value = g_list_find_custom(
1173 sx->deferredList, deferStateData, _temporal_state_data_cmp);
1174 if (found_by_value == NULL)
1176 g_warning(
"unable to find deferred instance");
1181 sx->deferredList = g_list_delete_link(sx->deferredList, found_by_value);
1196 return sx->deferredList;
1200 destroy_sx_on_book_close(
QofInstance *ent, gpointer data)
1202 SchedXaction* sx = GNC_SCHEDXACTION(ent);
1204 gnc_sx_begin_edit(sx);
1214 gnc_sx_book_end(QofBook* book)
1229 static QofObject SXDesc =
1232 DI(.e_type = ) GNC_SX_ID,
1233 DI(.type_label = ) "Scheduled Transaction",
1235 DI(.book_begin = ) NULL,
1236 DI(.book_end = ) gnc_sx_book_end,
1240 DI(.printable = ) NULL,
1247 static QofParam params[] =
1250 GNC_SX_NAME, QOF_TYPE_STRING, (
QofAccessFunc)xaccSchedXactionGetName,
1254 GNC_SX_START_DATE, QOF_TYPE_DATE, (
QofAccessFunc)xaccSchedXactionGetStartDateTT,
1258 GNC_SX_LAST_DATE, QOF_TYPE_DATE, (
QofAccessFunc)xaccSchedXactionGetLastOccurDateTT,
1262 GNC_SX_NUM_OCCUR, QOF_TYPE_INT64, (
QofAccessFunc)xaccSchedXactionGetNumOccur,
1266 GNC_SX_REM_OCCUR, QOF_TYPE_INT64, (
QofAccessFunc)xaccSchedXactionGetRemOccur,
const GDate * xaccSchedXactionGetEndDate(const SchedXaction *sx)
Returns invalid date when there is no end-date specified.
void xaccAccountSetType(Account *acc, GNCAccountType tip)
Set the account's type.
int qof_instance_version_cmp(const QofInstance *left, const QofInstance *right)
Compare two instances, based on their last update times.
#define xaccTransAppendSplit(t, s)
Add a split to the transaction.
void gnc_sx_set_schedule(SchedXaction *sx, GList *schedule)
gnc_commodity_table * gnc_commodity_table_get_table(QofBook *book)
Returns the commodity table associated with a book.
Transaction * xaccMallocTransaction(QofBook *book)
The xaccMallocTransaction() will malloc memory and initialize it.
void gnc_sx_set_instance_count(SchedXaction *sx, gint instance_num)
Sets the instance count to something other than the default.
void xaccTransSetDatePostedSecsNormalized(Transaction *trans, time64 time)
This function sets the posted date of the transaction, specified by a time64 (see ctime(3))...
GList * gnc_sx_get_schedule(const SchedXaction *sx)
void gnc_account_append_child(Account *new_parent, Account *child)
This function will remove from the child account any pre-existing parent relationship, and will then add the account as a child of the new parent.
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
SplitList * xaccAccountGetSplitList(const Account *acc)
The xaccAccountGetSplitList() routine returns a pointer to a GList of the splits in the account...
void gnc_sx_destroy_temporal_state(SXTmpStateData *tsd)
Frees the given stateDate object.
QofBook * qof_instance_get_book(gconstpointer inst)
Return the book pointer.
gboolean qof_collection_is_dirty(const QofCollection *col)
Return value of 'dirty' flag on collection.
void xaccSchedXactionSetNumOccur(SchedXaction *sx, gint new_num)
Set to '0' to turn off number-of-occurrences definition.
QofBackendError
The errors that can be reported to the GUI & other front-end users.
void xaccTransSetNotes(Transaction *trans, const char *notes)
Sets the transaction Notes.
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 qof_instance_set(QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_set Group setting multiple parameters in a single begin/commit/rollback.
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.
void xaccTransSetDescription(Transaction *trans, const char *desc)
Sets the transaction Description.
Account * gnc_book_get_template_root(const QofBook *book)
Returns the template group from the book.
Transaction * xaccSplitGetParent(const Split *split)
Returns the parent transaction of the split.
gchar * guid_to_string_buff(const GncGUID *guid, gchar *str)
The guid_to_string_buff() routine puts a null-terminated string encoding of the id into the memory po...
Just the variable temporal bits from the SX structure.
#define QOF_OBJECT_VERSION
Defines the version of the core object object registration interface.
gboolean qof_commit_edit(QofInstance *inst)
commit_edit helpers
#define QOF_PARAM_BOOK
"Known" Object Parameters – all objects must support these
void qof_collection_foreach(const QofCollection *col, QofInstanceForeachCB cb_func, gpointer user_data)
Call the callback for each entity in the collection.
GDate xaccSchedXactionGetNextInstance(const SchedXaction *sx, SXTmpStateData *tsd)
Returns the next occurrence of a scheduled transaction.
void(* QofSetterFunc)(gpointer, gpointer)
The QofSetterFunc defines an function pointer for parameter setters.
void xaccTransSetCurrency(Transaction *trans, gnc_commodity *curr)
Set a new currency on a transaction.
void xaccTransDestroy(Transaction *trans)
Destroys a transaction.
gboolean SXRegister(void)
QOF registration.
void xaccAccountDestroy(Account *acc)
The xaccAccountDestroy() routine can be used to get rid of an account.
void qof_instance_init_data(QofInstance *inst, QofIdType type, QofBook *book)
Initialise the settings associated with an instance.
gboolean qof_begin_edit(QofInstance *inst)
begin_edit
void gnc_sx_incr_temporal_state(const SchedXaction *sx, SXTmpStateData *tsd)
Calculates the next occurrence of the given SX and stores that occurrence in the remporalStateDate.
Account handling public routines.
void xaccSplitSetMemo(Split *split, const char *memo)
The memo is an arbitrary string associated with a split.
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
void gnc_sx_add_defer_instance(SchedXaction *sx, void *deferStateData)
Adds an instance to the deferred list of the SX.
Anchor Scheduled Transaction info in a book.
The bank account type denotes a savings or checking account held at a bank.
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)...
time64 gdate_to_time64(GDate d)
Turns a GDate into a time64, returning the first second of the day.
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
gpointer(* QofAccessFunc)(gpointer object, const QofParam *param)
The QofAccessFunc defines an arbitrary function pointer for access functions.
SXTmpStateData * gnc_sx_clone_temporal_state(SXTmpStateData *tsd)
Allocates and returns a one-by-one copy of the given temporal state.
void qof_collection_mark_clean(QofCollection *)
reset value of dirty flag
void xaccTransCommitEdit(Transaction *trans)
The xaccTransCommitEdit() method indicates that the changes to the transaction and its splits are com...
void xaccSchedXactionSetTemplateTrans(SchedXaction *sx, GList *t_t_list, QofBook *book)
Set the schedxaction's template transaction.
void xaccTransBeginEdit(Transaction *trans)
The xaccTransBeginEdit() method must be called before any changes are made to a transaction or any of...
All type declarations for the whole Gnucash engine.
const GncGUID * qof_entity_get_guid(gconstpointer ent)
Split * xaccMallocSplit(QofBook *book)
Constructor.
void xaccSchedXactionSetName(SchedXaction *sx, const gchar *newName)
A copy of the name is made.
void gnc_gdate_set_time64(GDate *gd, time64 time)
Set a GDate to a time64.
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
#define xaccAccountInsertSplit(acc, s)
The xaccAccountInsertSplit() method will insert the indicated split into the indicated account...
void gnc_sx_remove_defer_instance(SchedXaction *sx, void *deferStateData)
Removes an instance from the deferred list.
Account * xaccMallocAccount(QofBook *book)
Constructor.
time64 gnc_time(time64 *tbuf)
get the current local time
SchedXaction * xaccSchedXactionMalloc(QofBook *book)
Creates and initializes a scheduled transaction.
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
gint64 time64
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
gboolean qof_object_register(const QofObject *object)
Register new types of object objects.
gboolean qof_book_shutting_down(const QofBook *book)
Is the book shutting down?
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
gboolean xaccSchedXactionHasOccurDef(const SchedXaction *sx)
Returns true if the scheduled transaction has a defined number of occurrences, false if not...
Scheduled Transactions public handling routines.
void xaccSchedXactionSetEndDate(SchedXaction *sx, const GDate *newEnd)
Set to an invalid GDate to turn off 'end-date' definition.
API for Transactions and Splits (journal entries)
The type used to store guids in C.
void xaccAccountCommitEdit(Account *acc)
ThexaccAccountCommitEdit() subroutine is the second phase of a two-phase-commit wrapper for account u...
void xaccAccountSetName(Account *acc, const char *str)
Set the account's name.
void xaccSchedXactionDestroy(SchedXaction *sx)
Cleans up and frees a SchedXaction and its associated data.
void xaccAccountSetCommodity(Account *acc, gnc_commodity *com)
Set the account's commodity.
GList * gnc_sx_get_defer_instances(SchedXaction *sx)
Returns the defer list from the SX; this is a (date-)sorted temporal-state-data instance list...
gint gnc_sx_get_instance_count(const SchedXaction *sx, SXTmpStateData *stateData)
Get the instance count.