46 #include "SX-book-p.h" 48 #include <qofinstance-p.h> 51 #define G_LOG_DOMAIN "gnc.engine.sx" 59 gnc_collection_get_template_root(
const QofCollection *col )
68 if (!book)
return NULL;
70 return gnc_collection_get_template_root (col);
74 gnc_collection_set_template_root (QofCollection *col,
80 old_root = gnc_collection_get_template_root (col);
81 if (old_root == templateRoot)
return;
83 qof_collection_set_data (col, templateRoot);
94 gnc_book_set_template_root (QofBook *book,
Account *templateRoot)
99 if (templateRoot && gnc_account_get_book(templateRoot) != book)
101 g_critical(
"cannot mix and match books freely!");
106 gnc_collection_set_template_root (col, templateRoot);
114 sxtg_book_begin (QofBook *book)
122 qof_instance_set_dirty (QOF_INSTANCE (root));
124 gnc_book_set_template_root (book, root);
128 sxtg_book_end (QofBook *book)
130 gnc_book_set_template_root (book, NULL);
134 sxtg_is_dirty(
const QofCollection *col)
137 GList *descendants, *node;
138 gboolean dirty = FALSE;
140 root = gnc_collection_get_template_root(col);
142 for (node = descendants; node; node = g_list_next(node))
150 g_list_free(descendants);
156 extern void qof_instance_mark_clean (
QofInstance *);
159 sxtg_mark_clean(QofCollection *col)
164 root = gnc_collection_get_template_root(col);
168 g_list_foreach(descendants, (GFunc)qof_instance_mark_clean, NULL);
169 g_list_free(descendants);
179 static QofObject sxtg_object_def =
182 DI(.e_type = ) GNC_ID_SXTG,
183 DI(.type_label = ) "Scheduled Transaction Group",
185 DI(.book_begin = ) sxtg_book_begin,
186 DI(.book_end = ) sxtg_book_end,
187 DI(.is_dirty = ) sxtg_is_dirty,
188 DI(.mark_clean = ) sxtg_mark_clean,
189 DI(.foreach = ) NULL,
190 DI(.printable = ) NULL,
196 gnc_collection_get_schedxactions(const QofCollection *col)
204 gnc_book_get_schedxactions(QofBook *book)
208 return gnc_collection_get_schedxactions(col);
212 gnc_sxes_add_sx(SchedXactions *sxes, SchedXaction *sx)
214 if (g_list_find(sxes->sx_list, sx) != NULL)
216 sxes->sx_list = g_list_append(sxes->sx_list, sx);
221 gnc_sxes_del_sx(SchedXactions *sxes, SchedXaction *sx)
224 to_remove = g_list_find(sxes->sx_list, sx);
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);
235 QOF_GOBJECT_IMPL(gnc_schedxactions, SchedXactions, QOF_TYPE_INSTANCE)
238 gnc_schedxactions_init(SchedXactions* sxs)
243 gnc_schedxactions_dispose_real (GObject *sxsp)
248 gnc_schedxactions_finalize_real(GObject* sxsp)
253 mark_sx_clean(gpointer data, gpointer user_data)
255 SchedXaction *sx = (SchedXaction *) data;
256 qof_instance_mark_clean (QOF_INSTANCE(sx));
260 book_sxes_setup(QofBook *book)
265 auto sxes = GNC_SCHEDXACTIONS (g_object_new (GNC_TYPE_SCHEDXACTIONS, NULL));
268 sxes->sx_list = NULL;
269 sxes->sx_notsaved = TRUE;
270 qof_collection_set_data(col, sxes);
274 book_sxes_end(QofBook* book)
282 g_list_free(sxes->sx_list);
283 g_object_unref(sxes);
284 qof_collection_set_data(col, NULL);
289 book_sxns_mark_saved(QofCollection *col)
292 sxl = gnc_collection_get_schedxactions(col);
295 sxl->sx_notsaved = FALSE;
296 g_list_foreach(sxl->sx_list,
302 book_sxlist_notsaved(
const QofCollection *col)
307 sxl = gnc_collection_get_schedxactions(col);
308 if (!sxl)
return FALSE;
309 if (sxl->sx_notsaved)
return TRUE;
311 for (sxlist = sxl->sx_list;
313 sxlist = g_list_next(sxlist))
316 sx = (SchedXaction *) (sxlist->data);
324 static QofObject sxes_object_def =
327 DI(.e_type = ) GNC_ID_SXES,
328 DI(.type_label = ) "Scheduled Transactions List",
330 DI(.book_begin = ) book_sxes_setup,
331 DI(.book_end = ) book_sxes_end,
332 DI(.is_dirty = ) book_sxlist_notsaved,
333 DI(.mark_clean = ) book_sxns_mark_saved,
334 DI(.foreach = ) NULL,
335 DI(.printable = ) NULL,
336 DI(.version_cmp = ) NULL
339 static QofObject sxtt_object_def =
342 DI(.e_type = ) GNC_ID_SXTT,
343 DI(.type_label = ) "Scheduled Transaction Templates",
345 DI(.book_begin = ) NULL,
346 DI(.book_end = ) NULL,
347 DI(.is_dirty = ) NULL,
348 DI(.mark_clean = ) NULL,
349 DI(.foreach = ) NULL,
350 DI(.printable = ) NULL,
351 DI(.version_cmp = ) NULL,
355 gnc_sxtt_register (
void)
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)
374 SchedXaction *sx = (SchedXaction*)sx_list->data;
375 GList *splits = xaccSchedXactionGetSplits(sx);
376 for (GList *node = splits; node; node = node->next)
378 Split *s = (Split*)node->data;
382 rtn = g_list_prepend (rtn, sx);
386 g_list_free (splits);
388 return g_list_reverse (rtn);
void xaccAccountSetType(Account *acc, GNCAccountType tip)
Set the account's type.
void qof_instance_get(const QofInstance *inst, const gchar *first_prop,...)
Wrapper for g_object_get.
#define qof_instance_is_dirty
Return value of is_dirty flag.
Account * gnc_book_get_template_root(const QofBook *book)
Returns the template group from the book.
API for Transactions and Splits (journal entries)
#define QOF_OBJECT_VERSION
Defines the version of the core object object registration interface.
GList * gnc_sx_get_sxes_referencing_account(QofBook *book, Account *acct)
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.
Account handling public routines.
gboolean guid_equal(const GncGUID *guid_1, const GncGUID *guid_2)
Given two GUIDs, return TRUE if they are non-NULL and equal.
Anchor Scheduled Transaction info in a book.
#define xaccSchedXactionIsDirty(X)
void qof_collection_mark_clean(QofCollection *)
reset value of dirty flag
Additional event handling code.
All type declarations for the whole Gnucash engine.
const GncGUID * qof_entity_get_guid(gconstpointer ent)
GList * gnc_account_get_descendants(const Account *account)
This routine returns a flat list of all of the accounts that are descendants of the specified account...
void xaccAccountBeginEdit(Account *acc)
The xaccAccountBeginEdit() subroutine is the first phase of a two-phase-commit wrapper for account up...
Account * xaccMallocAccount(QofBook *book)
Constructor.
QofCollection * qof_book_get_collection(const QofBook *book, QofIdType entity_type)
Return The table of entities of the given type.
gboolean qof_object_register(const QofObject *object)
Register new types of object objects.
gpointer qof_collection_get_data(const QofCollection *col)
Store and retrieve arbitrary object-defined data.
void qof_event_gen(QofInstance *entity, QofEventId event_id, gpointer event_data)
Invoke all registered event handlers using the given arguments.
Scheduled Transactions public handling routines.
#define GNC_EVENT_ITEM_ADDED
These events are used when a split is added to an account.
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.
The hidden root account of an account tree.