27 #include <glib/gi18n.h> 36 #include "SX-book-p.h" 37 #include "SX-ttinfo.hpp" 39 #include "SchedXaction.hpp" 42 #include "engine-helpers.h" 43 #include "qofinstance-p.h" 45 #include <unordered_set> 48 #define G_LOG_DOMAIN "gnc.engine.sx" 57 PROP_LAST_OCCURANCE_DATE,
61 PROP_AUTO_CREATE_NOTIFY,
62 PROP_ADVANCE_CREATION_DAYS,
63 PROP_ADVANCE_REMINDER_DAYS,
69 G_DEFINE_TYPE(SchedXaction, gnc_schedxaction, QOF_TYPE_INSTANCE)
72 gnc_schedxaction_init(SchedXaction* sx)
76 g_date_clear( &sx->last_date, 1 );
77 g_date_clear( &sx->start_date, 1 );
78 g_date_clear( &sx->end_date, 1 );
81 sx->num_occurances_total = 0;
82 sx->autoCreateOption = FALSE;
83 sx->autoCreateNotify = FALSE;
84 sx->advanceCreateDays = 0;
85 sx->advanceRemindDays = 0;
87 sx->deferredList = NULL;
91 gnc_schedxaction_dispose(GObject *sxp)
93 G_OBJECT_CLASS(gnc_schedxaction_parent_class)->dispose(sxp);
97 gnc_schedxaction_finalize(GObject* sxp)
99 G_OBJECT_CLASS(gnc_schedxaction_parent_class)->finalize(sxp);
109 gnc_schedxaction_get_property (GObject *
object,
116 g_return_if_fail(GNC_IS_SCHEDXACTION(
object));
118 sx = GNC_SCHEDXACTION(
object);
122 g_value_set_string(value, sx->name);
125 g_value_set_boolean(value, sx->enabled);
127 case PROP_NUM_OCCURANCE:
128 g_value_set_int(value, sx->num_occurances_total);
130 case PROP_REM_OCCURANCE:
131 g_value_set_int(value, sx->num_occurances_remain);
133 case PROP_AUTO_CREATE:
134 g_value_set_boolean(value, sx->autoCreateOption);
136 case PROP_AUTO_CREATE_NOTIFY:
137 g_value_set_boolean(value, sx->autoCreateNotify);
139 case PROP_ADVANCE_CREATION_DAYS:
140 g_value_set_int(value, sx->advanceCreateDays);
142 case PROP_ADVANCE_REMINDER_DAYS:
143 g_value_set_int(value, sx->advanceRemindDays);
145 case PROP_START_DATE:
146 g_value_set_boxed(value, &sx->start_date);
151 if (g_date_valid (&sx->end_date))
152 g_value_set_boxed(value, &sx->end_date);
154 case PROP_LAST_OCCURANCE_DATE:
157 if (g_date_valid (&sx->last_date))
158 g_value_set_boxed(value, &sx->last_date);
160 case PROP_INSTANCE_COUNT:
161 g_value_set_int(value, sx->instance_num);
163 case PROP_TEMPLATE_ACCOUNT:
164 g_value_take_object(value, sx->template_acct);
167 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
173 gnc_schedxaction_set_property (GObject *
object,
180 g_return_if_fail(GNC_IS_SCHEDXACTION(
object));
182 sx = GNC_SCHEDXACTION(
object);
183 g_assert (qof_instance_get_editlevel(sx));
191 xaccSchedXactionSetEnabled(sx, g_value_get_boolean(value));
193 case PROP_NUM_OCCURANCE:
196 case PROP_REM_OCCURANCE:
197 xaccSchedXactionSetRemOccur(sx, g_value_get_int(value));
199 case PROP_AUTO_CREATE:
200 xaccSchedXactionSetAutoCreate(sx, g_value_get_boolean(value), sx->autoCreateNotify);
202 case PROP_AUTO_CREATE_NOTIFY:
203 xaccSchedXactionSetAutoCreate(sx, sx->autoCreateOption, g_value_get_boolean(value));
205 case PROP_ADVANCE_CREATION_DAYS:
206 xaccSchedXactionSetAdvanceCreation(sx, g_value_get_int(value));
208 case PROP_ADVANCE_REMINDER_DAYS:
209 xaccSchedXactionSetAdvanceReminder(sx, g_value_get_int(value));
211 case PROP_START_DATE:
215 xaccSchedXactionSetStartDate(sx, static_cast<const GDate*>(g_value_get_boxed(value)));
223 case PROP_LAST_OCCURANCE_DATE:
227 xaccSchedXactionSetLastOccurDate(sx, static_cast<const GDate*>(g_value_get_boxed(value)));
229 case PROP_INSTANCE_COUNT:
232 case PROP_TEMPLATE_ACCOUNT:
233 sx_set_template_account(sx, GNC_ACCOUNT(g_value_get_object(value)));
236 G_OBJECT_WARN_INVALID_PROPERTY_ID(
object, prop_id, pspec);
242 gnc_schedxaction_class_init (SchedXactionClass *klass)
244 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
246 gobject_class->dispose = gnc_schedxaction_dispose;
247 gobject_class->finalize = gnc_schedxaction_finalize;
248 gobject_class->set_property = gnc_schedxaction_set_property;
249 gobject_class->get_property = gnc_schedxaction_get_property;
251 g_object_class_install_property
254 g_param_spec_string (
"name",
255 "Scheduled Transaction Name",
256 "The name is an arbitrary string " 257 "assigned by the user. It is intended to " 258 "a short, 5 to 30 character long string " 259 "that is displayed by the GUI.",
263 g_object_class_install_property
266 g_param_spec_boolean (
"enabled",
268 "TRUE if the scheduled transaction is enabled.",
272 g_object_class_install_property
275 g_param_spec_int (
"num-occurance",
276 "Number of occurrences",
277 "Total number of occurrences for this scheduled transaction.",
283 g_object_class_install_property
286 g_param_spec_int (
"rem-occurance",
287 "Number of occurrences remaining",
288 "Remaining number of occurrences for this scheduled transaction.",
294 g_object_class_install_property
297 g_param_spec_boolean (
"auto-create",
299 "TRUE if the transaction will be automatically " 300 "created when its time comes.",
304 g_object_class_install_property
306 PROP_AUTO_CREATE_NOTIFY,
307 g_param_spec_boolean (
"auto-create-notify",
308 "Auto-create-notify",
309 "TRUE if the the user will be notified when the transaction " 310 "is automatically created.",
314 g_object_class_install_property
316 PROP_ADVANCE_CREATION_DAYS,
317 g_param_spec_int (
"advance-creation-days",
318 "Days in advance to create",
319 "Number of days in advance to create this scheduled transaction.",
325 g_object_class_install_property
327 PROP_ADVANCE_REMINDER_DAYS,
328 g_param_spec_int (
"advance-reminder-days",
329 "Days in advance to remind",
330 "Number of days in advance to remind about this scheduled transaction.",
336 g_object_class_install_property
339 g_param_spec_boxed(
"start-date",
341 "Date for the first occurrence for the scheduled transaction.",
345 g_object_class_install_property
348 g_param_spec_boxed(
"end-date",
350 "Date for the scheduled transaction to end.",
354 g_object_class_install_property
356 PROP_LAST_OCCURANCE_DATE,
357 g_param_spec_boxed(
"last-occurance-date",
358 "Last Occurrence Date",
359 "Date for the last occurrence of the scheduled transaction.",
363 g_object_class_install_property
366 g_param_spec_int (
"instance-count",
368 "Number of instances of this scheduled transaction.",
374 g_object_class_install_property
376 PROP_TEMPLATE_ACCOUNT,
377 g_param_spec_object(
"template-account",
379 "Account which holds the template transactions.",
385 xaccSchedXactionInit(SchedXaction *sx, QofBook *book)
402 GNC_COMMODITY_NS_TEMPLATE,
"template") );
414 g_return_val_if_fail (book, NULL);
416 sx = GNC_SX(g_object_new(GNC_TYPE_SCHEDXACTION, NULL));
417 xaccSchedXactionInit( sx, book );
424 delete_template_trans(SchedXaction *sx)
426 std::unordered_set<Transaction*> txns;
427 auto& splits{xaccAccountGetSplits (sx->template_acct)};
428 std::for_each (splits.begin(), splits.end(),
430 std::for_each (txns.begin(), txns.end(),
441 sx_set_template_account (SchedXaction *sx,
Account *account)
445 old = sx->template_acct;
446 sx->template_acct = account;
457 qof_instance_set_destroying( QOF_INSTANCE(sx), TRUE );
458 gnc_sx_commit_edit( sx );
462 xaccSchedXactionFree( SchedXaction *sx )
464 if ( sx == NULL )
return;
476 delete_template_trans( sx );
481 g_list_free_full (sx->deferredList, g_free);
484 g_list_free_full (sx->schedule, g_free);
487 g_object_unref( sx );
493 gnc_sx_begin_edit (SchedXaction *sx)
500 xaccSchedXactionFree( GNC_SX(inst) );
505 g_critical(
"Failed to commit: %d", errcode);
506 gnc_engine_signal_commit_error( errcode );
515 gnc_sx_commit_edit (SchedXaction *sx)
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);
540 xaccSchedXactionGetName(
const SchedXaction *sx )
548 g_return_if_fail( newName != NULL );
549 gnc_sx_begin_edit(sx);
550 if ( sx->name != NULL )
555 sx->name = g_strdup( newName );
556 qof_instance_set_dirty(&sx->inst);
557 gnc_sx_commit_edit(sx);
561 xaccSchedXactionGetStartDate(
const SchedXaction *sx )
564 return &sx->start_date;
568 xaccSchedXactionGetStartDateTT(
const SchedXaction *sx )
575 xaccSchedXactionSetStartDate( SchedXaction *sx,
const GDate* newStart )
577 if ( newStart == NULL || !g_date_valid( newStart ))
584 g_critical(
"Invalid Start Date");
587 gnc_sx_begin_edit(sx);
588 sx->start_date = *newStart;
589 qof_instance_set_dirty(&sx->inst);
590 gnc_sx_commit_edit(sx);
594 xaccSchedXactionSetStartDateTT( SchedXaction *sx,
const time64 newStart )
596 if ( newStart == INT64_MAX )
603 g_critical(
"Invalid Start Date");
606 gnc_sx_begin_edit(sx);
608 qof_instance_set_dirty(&sx->inst);
609 gnc_sx_commit_edit(sx);
613 xaccSchedXactionHasEndDate(
const SchedXaction *sx )
615 return sx != NULL && g_date_valid( &sx->end_date );
622 return &sx->end_date;
632 if (newEnd == NULL ||
633 (g_date_valid(newEnd) && g_date_compare( newEnd, &sx->start_date ) < 0 ))
640 g_critical(
"Bad End Date: Invalid or before Start Date");
644 gnc_sx_begin_edit(sx);
645 sx->end_date = *newEnd;
646 qof_instance_set_dirty(&sx->inst);
647 gnc_sx_commit_edit(sx);
651 xaccSchedXactionGetLastOccurDate(
const SchedXaction *sx )
653 return &sx->last_date;
657 xaccSchedXactionGetLastOccurDateTT(
const SchedXaction *sx )
663 xaccSchedXactionSetLastOccurDate(SchedXaction *sx,
const GDate* new_last_occur)
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)
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);
676 xaccSchedXactionSetLastOccurDateTT(SchedXaction *sx,
time64 new_last_occur)
679 g_return_if_fail (new_last_occur != INT64_MAX);
681 if (g_date_valid(&sx->last_date)
682 && g_date_compare(&sx->last_date, &last_occur) == 0)
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);
693 return ( xaccSchedXactionGetNumOccur( sx ) != 0 );
697 xaccSchedXactionGetNumOccur(
const SchedXaction *sx )
699 return sx->num_occurances_total;
705 if (sx->num_occurances_total == new_num)
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);
714 xaccSchedXactionGetRemOccur(
const SchedXaction *sx )
716 return sx->num_occurances_remain;
720 xaccSchedXactionSetRemOccur(SchedXaction *sx, gint num_remain)
723 if (num_remain > sx->num_occurances_total)
725 g_warning(
"number remaining [%d] > total occurrences [%d]",
726 num_remain, sx->num_occurances_total);
730 if (num_remain == sx->num_occurances_remain)
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);
743 gboolean countFirstDate;
747 && xaccSchedXactionGetRemOccur(sx) <= 0)
748 || (xaccSchedXactionHasEndDate(sx)
759 countFirstDate = !g_date_valid(&tmpState->last_date)
760 || (g_date_compare(&tmpState->last_date, start_date) < 0);
763 if (!g_date_valid(&tmpState->last_date))
777 while (g_date_compare(&tmpState->last_date, start_date) < 0)
791 while (g_date_valid(&tmpState->last_date)
792 && (g_date_compare(&tmpState->last_date, end_date) <= 0)
793 && (!xaccSchedXactionHasEndDate(sx)
799 || tmpState->num_occur_rem >= 0))
807 if (!countFirstDate && result > 0)
815 xaccSchedXactionGetEnabled(
const SchedXaction *sx )
821 xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled)
823 gnc_sx_begin_edit(sx);
824 sx->enabled = newEnabled;
825 qof_instance_set_dirty(&sx->inst);
826 gnc_sx_commit_edit(sx);
830 xaccSchedXactionGetAutoCreate(
const SchedXaction *sx,
831 gboolean *outAutoCreate,
832 gboolean *outNotify )
834 if (outAutoCreate != NULL)
835 *outAutoCreate = sx->autoCreateOption;
836 if (outNotify != NULL)
837 *outNotify = sx->autoCreateNotify;
842 xaccSchedXactionSetAutoCreate( SchedXaction *sx,
843 gboolean newAutoCreate,
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);
856 xaccSchedXactionGetAdvanceCreation(
const SchedXaction *sx )
858 return sx->advanceCreateDays;
862 xaccSchedXactionSetAdvanceCreation( SchedXaction *sx, gint createDays )
864 gnc_sx_begin_edit(sx);
865 sx->advanceCreateDays = createDays;
866 qof_instance_set_dirty(&sx->inst);
867 gnc_sx_commit_edit(sx);
871 xaccSchedXactionGetAdvanceReminder(
const SchedXaction *sx )
873 return sx->advanceRemindDays;
877 xaccSchedXactionSetAdvanceReminder( SchedXaction *sx, gint reminderDays )
879 gnc_sx_begin_edit(sx);
880 sx->advanceRemindDays = reminderDays;
881 qof_instance_set_dirty(&sx->inst);
882 gnc_sx_commit_edit(sx);
888 GDate prev_occur, next_occur;
890 g_date_clear( &prev_occur, 1 );
892 prev_occur = tsd->last_date;
900 if (g_date_valid (&sx->start_date) && (!g_date_valid ( &prev_occur ) || g_date_compare (&prev_occur, &sx->start_date)<0))
903 prev_occur = sx->start_date;
904 g_date_subtract_days (&prev_occur, 1 );
907 recurrenceListNextInstance(sx->schedule, &prev_occur, &next_occur);
909 if ( xaccSchedXactionHasEndDate( sx ) )
912 if ( g_date_compare( &next_occur, end_date ) > 0 )
914 g_date_clear( &next_occur, 1 );
919 if ((tsd && tsd->num_occur_rem == 0) ||
920 (!tsd && sx->num_occurances_remain == 0 ))
922 g_date_clear( &next_occur, 1 );
937 toRet = tsd->num_inst;
941 toRet = sx->instance_num;
950 g_return_if_fail(sx);
951 if (sx->instance_num == instance_num)
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);
960 xaccSchedXactionGetSplits(
const SchedXaction *sx )
962 g_return_val_if_fail( sx, NULL );
967 pack_split_info (TTSplitInfoPtr s_info,
Account *parent_acct,
968 Transaction *parent_trans, QofBook *book)
971 const gchar *credit_formula;
972 const gchar *debit_formula;
981 gnc_set_num_action(NULL, split, NULL, s_info->get_action());
986 credit_formula = s_info->get_credit_formula ();
987 debit_formula = s_info->get_debit_formula ();
990 "sx-credit-formula", credit_formula,
991 "sx-debit-formula", debit_formula,
992 "sx-account", acc_guid,
1000 xaccSchedXactionSetTemplateTrans (SchedXaction *sx,
const TTInfoVec& tt_vec, QofBook *book)
1002 Transaction *new_trans;
1004 g_return_if_fail (book);
1007 delete_template_trans( sx );
1009 for (
auto tti : tt_vec)
1018 gnc_set_num_action (new_trans, NULL, tti->get_num(), NULL);
1022 for (
auto s_info : tti->get_template_splits())
1024 auto new_split = pack_split_info(s_info, sx->template_acct, new_trans, book);
1035 if (g_date_valid (&(sx->last_date)))
1036 toRet->last_date = sx->last_date;
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;
1047 g_return_if_fail(tsd != NULL);
1051 --tsd->num_occur_rem;
1077 _temporal_state_data_cmp( gconstpointer a, gconstpointer b )
1082 if ( !tsd_a && !tsd_b )
1090 return g_date_compare( &tsd_a->last_date,
1091 &tsd_b->last_date );
1101 sx->deferredList = g_list_insert_sorted( sx->deferredList,
1103 _temporal_state_data_cmp );
1113 GList *found_by_value;
1115 found_by_value = g_list_find_custom(
1116 sx->deferredList, deferStateData, _temporal_state_data_cmp);
1117 if (found_by_value == NULL)
1119 g_warning(
"unable to find deferred instance");
1123 g_free (found_by_value->data);
1124 sx->deferredList = g_list_delete_link(sx->deferredList, found_by_value);
1139 return sx->deferredList;
1143 destroy_sx_on_book_close(
QofInstance *ent, gpointer data)
1145 SchedXaction* sx = GNC_SCHEDXACTION(ent);
1147 gnc_sx_begin_edit(sx);
1157 gnc_sx_book_end(QofBook* book)
1162 qof_collection_foreach(col, destroy_sx_on_book_close, NULL);
1165 gnc_book_set_template_root (book, NULL);
1175 static QofObject SXDesc =
1178 DI(.e_type = ) GNC_SX_ID,
1179 DI(.type_label = ) "Scheduled Transaction",
1181 DI(.book_begin = ) NULL,
1182 DI(.book_end = ) gnc_sx_book_end,
1185 DI(.foreach = ) qof_collection_foreach,
1186 DI(.printable = ) NULL,
1193 static QofParam params[] =
1196 GNC_SX_NAME, QOF_TYPE_STRING, (
QofAccessFunc)xaccSchedXactionGetName,
1200 GNC_SX_START_DATE, QOF_TYPE_DATE, (
QofAccessFunc)xaccSchedXactionGetStartDateTT,
1204 GNC_SX_LAST_DATE, QOF_TYPE_DATE, (
QofAccessFunc)xaccSchedXactionGetLastOccurDateTT,
1208 GNC_SX_NUM_OCCUR, QOF_TYPE_INT64, (
QofAccessFunc)xaccSchedXactionGetNumOccur,
1212 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
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.
Account public routines (C++ api)
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 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 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
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
gboolean qof_object_register(const QofObject *object)
Register new types of object objects.
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.