/* ================================================================= */ static SchedXaction* load_single_sx (GncSqlBackend* sql_be, GncSqlRow& row) { const GncGUID* guid; SchedXaction* pSx; GList* schedule; GDate start_date; g_return_val_if_fail (sql_be != NULL, NULL); guid = gnc_sql_load_guid (sql_be, row); g_assert (guid != NULL); pSx = xaccSchedXactionMalloc (sql_be->book()); gnc_sx_begin_edit (pSx); gnc_sql_load_object (sql_be, row, GNC_SX_ID, pSx, col_table); schedule = gnc_sql_recurrence_load_list (sql_be, guid); gnc_sx_set_schedule (pSx, schedule); gnc_sx_commit_edit (pSx); gnc_sql_transaction_load_tx_for_account (sql_be, pSx->template_acct); g_object_get (pSx, "start-date", &start_date, NULL); return pSx; }
void xaccSchedXactionSetAdvanceReminder( SchedXaction *sx, gint reminderDays ) { gnc_sx_begin_edit(sx); sx->advanceRemindDays = reminderDays; qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); }
void xaccSchedXactionSetAdvanceCreation( SchedXaction *sx, gint createDays ) { gnc_sx_begin_edit(sx); sx->advanceCreateDays = createDays; qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); }
static void destroy_sx_on_book_close(QofInstance *ent, gpointer data) { SchedXaction* sx = GNC_SCHEDXACTION(ent); gnc_sx_begin_edit(sx); xaccSchedXactionDestroy(sx); }
void xaccSchedXactionSetEnabled( SchedXaction *sx, gboolean newEnabled) { gnc_sx_begin_edit(sx); sx->enabled = newEnabled; qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); }
void gnc_sx_set_schedule(SchedXaction *sx, GList *schedule) { g_return_if_fail(sx); gnc_sx_begin_edit(sx); sx->schedule = schedule; qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); }
void xaccSchedXactionSetNumOccur(SchedXaction *sx, gint new_num) { if (sx->num_occurances_total == new_num) return; gnc_sx_begin_edit(sx); sx->num_occurances_remain = sx->num_occurances_total = new_num; qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); }
void gnc_sx_set_instance_count(SchedXaction *sx, gint instance_num) { g_return_if_fail(sx); if (sx->instance_num == instance_num) return; gnc_sx_begin_edit(sx); sx->instance_num = instance_num; qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); }
static void _destroy_sx(gpointer data, gpointer user_data) { SchedXactions *sxes; SchedXaction *sx = (SchedXaction*)data; QofBook *book; book = gnc_get_current_book(); sxes = gnc_book_get_schedxactions(book); gnc_sxes_del_sx(sxes, sx); gnc_sx_begin_edit(sx); xaccSchedXactionDestroy(sx); }
void xaccSchedXactionSetLastOccurDate(SchedXaction *sx, const GDate* new_last_occur) { g_return_if_fail (new_last_occur != NULL); if (g_date_valid(&sx->last_date) && g_date_compare(&sx->last_date, new_last_occur) == 0) return; gnc_sx_begin_edit(sx); sx->last_date = *new_last_occur; qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); }
static void sxftd_close(SXFromTransInfo *sxfti, gboolean delete_sx) { if ( sxfti->sx && delete_sx ) { gnc_sx_begin_edit(sxfti->sx); xaccSchedXactionDestroy(sxfti->sx); } sxfti->sx = NULL; gtk_widget_destroy (GTK_WIDGET (sxfti->dialog)); }
void xaccSchedXactionSetAutoCreate( SchedXaction *sx, gboolean newAutoCreate, gboolean newNotify ) { gnc_sx_begin_edit(sx); sx->autoCreateOption = newAutoCreate; sx->autoCreateNotify = newNotify; qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); return; }
void xaccSchedXactionSetName( SchedXaction *sx, const gchar *newName ) { g_return_if_fail( newName != NULL ); gnc_sx_begin_edit(sx); if ( sx->name != NULL ) { g_free( sx->name ); sx->name = NULL; } sx->name = g_strdup( newName ); qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); }
static void sxftd_destroy( GtkWidget *w, gpointer user_data ) { SXFromTransInfo *sxfti = (SXFromTransInfo*)user_data; if ( sxfti->sx ) { gnc_sx_begin_edit(sxfti->sx); xaccSchedXactionDestroy(sxfti->sx); sxfti->sx = NULL; } g_object_unref(G_OBJECT(sxfti->dense_cal_model)); g_object_unref(G_OBJECT(sxfti->example_cal)); g_free(sxfti); }
void xaccSchedXactionSetStartDate( SchedXaction *sx, const GDate* newStart ) { if ( newStart == NULL || !g_date_valid( newStart )) { /* XXX: I reject the bad data - is this the right * thing to do <rgmerk>. * This warning is only human readable - the caller * doesn't know the call failed. This is bad */ g_critical("Invalid Start Date"); return; } gnc_sx_begin_edit(sx); sx->start_date = *newStart; qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); }
void xaccSchedXactionSetRemOccur(SchedXaction *sx, gint num_remain) { /* FIXME This condition can be tightened up */ if (num_remain > sx->num_occurances_total) { g_warning("number remaining [%d] > total occurrences [%d]", num_remain, sx->num_occurances_total); } else { if (num_remain == sx->num_occurances_remain) return; gnc_sx_begin_edit(sx); sx->num_occurances_remain = num_remain; qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); } }
void xaccSchedXactionSetEndDate( SchedXaction *sx, const GDate *newEnd ) { /* Note that an invalid GDate IS a permissable value: It means that * the SX is to run "forever". See gnc_sxed_save_sx() and * schedXact_editor_populate() in dialog-sx-editor.c. */ if (newEnd == NULL || (g_date_valid(newEnd) && g_date_compare( newEnd, &sx->start_date ) < 0 )) { /* XXX: I reject the bad data - is this the right * thing to do <rgmerk>. * This warning is only human readable - the caller * doesn't know the call failed. This is bad */ g_critical("Bad End Date: Invalid or before Start Date"); return; } gnc_sx_begin_edit(sx); sx->end_date = *newEnd; qof_instance_set_dirty(&sx->inst); gnc_sx_commit_edit(sx); }
static gboolean gnc_schedXaction_end_handler(gpointer data_for_children, GSList* data_from_children, GSList* sibling_data, gpointer parent_data, gpointer global_data, gpointer *result, const gchar *tag) { SchedXaction *sx; gboolean successful = FALSE; xmlNodePtr tree = (xmlNodePtr)data_for_children; gxpf_data *gdata = (gxpf_data*)global_data; struct sx_pdata sx_pdata; if ( parent_data ) { return TRUE; } if ( !tag ) { return TRUE; } g_return_val_if_fail( tree, FALSE ); sx = xaccSchedXactionMalloc( gdata->bookdata ); memset(&sx_pdata, 0, sizeof(sx_pdata)); sx_pdata.sx = sx; sx_pdata.book = gdata->bookdata; g_assert( sx_dom_handlers != NULL ); successful = dom_tree_generic_parse( tree, sx_dom_handlers, &sx_pdata ); if (!successful) { g_critical("failed to parse scheduled xaction"); xmlElemDump( stdout, NULL, tree ); gnc_sx_begin_edit( sx ); xaccSchedXactionDestroy( sx ); goto done; } if (tree->properties) { gchar *sx_name = xaccSchedXactionGetName(sx); xmlAttr *attr; for (attr = tree->properties; attr != NULL; attr = attr->next) { xmlChar *attr_value = attr->children->content; g_debug("sx attribute name[%s] value[%s]", attr->name, attr_value); if (strcmp((const char *)attr->name, "version") != 0) { g_warning("unknown sx attribute [%s]", attr->name); continue; } // if version == 1.0.0: ensure freqspec, no recurrence // if version == 2.0.0: ensure recurrence, no freqspec. if (strcmp((const char *)attr_value, schedxaction_version_string) == 0) { if (!sx_pdata.saw_freqspec) g_critical("did not see freqspec in version 1 sx [%s]", sx_name); if (sx_pdata.saw_recurrence) g_warning("saw recurrence in supposedly version 1 sx [%s]", sx_name); } if (strcmp((const char *)attr_value, schedxaction_version2_string) == 0) { if (sx_pdata.saw_freqspec) g_warning("saw freqspec in version 2 sx [%s]", sx_name); if (!sx_pdata.saw_recurrence) g_critical("did not find recurrence in version 2 sx [%s]", sx_name); } } } // generic_callback -> book_callback: insert the SX in the book gdata->cb( tag, gdata->parsedata, sx ); /* FIXME: this should be removed somewhere near 1.8 release time. */ if ( sx->template_acct == NULL ) { Account *ra = NULL; const char *id = NULL; Account *acct = NULL; sixtp_gdv2 *sixdata = gdata->parsedata; QofBook *book; book = sixdata->book; /* We're dealing with a pre-200107<near-end-of-month> rgmerk change re: storing template accounts. */ /* Fix: get account with name of our GncGUID from the template accounts. Make that our template_acct pointer. */ /* THREAD-UNSAFE */ id = guid_to_string( xaccSchedXactionGetGUID( sx ) ); ra = gnc_book_get_template_root(book); if ( ra == NULL ) { g_warning( "Error getting template root account from being-parsed Book." ); xmlFreeNode( tree ); return FALSE; } acct = gnc_account_lookup_by_name( ra, id ); if ( acct == NULL ) { g_warning("no template account with name [%s]", id); xmlFreeNode( tree ); return FALSE; } g_debug("template account name [%s] for SX with GncGUID [%s]", xaccAccountGetName( acct ), id ); /* FIXME: free existing template account. * HUH????? We only execute this if there isn't * currently an existing template account, don't we? * <rgmerk> */ sx->template_acct = acct; } done: xmlFreeNode( tree ); return successful; }