/* ================================================================= */ 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; }
static gboolean sx_recurrence_handler(xmlNodePtr node, gpointer _pdata) { struct sx_pdata *parsing_data = _pdata; GList *schedule = NULL; gchar* debug_str; g_return_val_if_fail(node, FALSE); if (!dom_tree_generic_parse(node, sx_recurrence_list_handlers, &schedule)) return FALSE; // g_return_val_if_fail(schedule, FALSE); debug_str = recurrenceListToString(schedule); g_debug("setting freshly-parsed schedule: [%s]", debug_str); g_free(debug_str); gnc_sx_set_schedule(parsing_data->sx, schedule); parsing_data->saw_recurrence = TRUE; return TRUE; }
static void gnc_plugin_page_sx_list_cmd_new(GtkAction *action, GncPluginPageSxList *page) { SchedXaction *new_sx; gboolean new_sx_flag = TRUE; new_sx = xaccSchedXactionMalloc(gnc_get_current_book()); { GDate now; Recurrence *r = new Recurrence;//g_new0(Recurrence, 1); g_date_clear(&now, 1); gnc_gdate_set_today (&now); recurrenceSet(r, 1, PERIOD_MONTH, &now, WEEKEND_ADJ_NONE); RecurrenceList_t schedule = gnc_sx_get_schedule(new_sx); schedule.push_back(r); gnc_sx_set_schedule(new_sx, schedule); } gnc_ui_scheduled_xaction_editor_dialog_create(new_sx, new_sx_flag); }
static gboolean sx_freqspec_handler( xmlNodePtr node, gpointer sx_pdata ) { struct sx_pdata *pdata = sx_pdata; SchedXaction *sx = pdata->sx; GList *schedule; gchar* debug_str; g_return_val_if_fail( node, FALSE ); schedule = dom_tree_freqSpec_to_recurrences(node, pdata->book); gnc_sx_set_schedule(sx, schedule); debug_str = recurrenceListToString(schedule); g_debug("parsed from freqspec [%s]", debug_str); g_free(debug_str); _fixup_recurrence_start_dates(xaccSchedXactionGetStartDate(sx), schedule); pdata->saw_freqspec = TRUE; return TRUE; }
static guint sxftd_compute_sx(SXFromTransInfo *sxfti) { gchar *name; GDate date; GList *schedule = NULL; getEndTuple end_info; guint sxftd_errno = 0; /* 0 == OK, > 0 means dialog needs to be run again */ SchedXaction *sx = sxfti->sx; /* get the name */ name = gtk_editable_get_chars(GTK_EDITABLE(sxfti->name), 0, -1); xaccSchedXactionSetName(sx, name); g_free(name); gnc_gdate_set_time64( &date, gnc_date_edit_get_date( sxfti->startDateGDE ) ); sxftd_update_schedule(sxfti, &date, &schedule); if (sxftd_errno == 0) { gnc_sx_set_schedule(sx, schedule); xaccSchedXactionSetStartDate( sx, &date ); } end_info = sxftd_get_end_info(sxfti); switch (end_info.type) { case NEVER_END: break; case END_ON_DATE: xaccSchedXactionSetEndDate(sx, &(end_info.end_date)); break; case END_AFTER_N_OCCS: xaccSchedXactionSetNumOccur(sx, end_info.n_occurrences); break; default: sxftd_errno = 2; break; } gnc_sx_set_instance_count( sx, 1 ); /* Set the autocreate, days-in-advance and remind-in-advance values from * options. */ { gboolean autoCreateState, notifyState; gint daysInAdvance; autoCreateState = gnc_prefs_get_bool (GNC_PREFS_GROUP_SXED, GNC_PREF_CREATE_AUTO); notifyState = gnc_prefs_get_bool (GNC_PREFS_GROUP_SXED, GNC_PREF_NOTIFY); xaccSchedXactionSetAutoCreate( sx, autoCreateState, (autoCreateState & notifyState) ); daysInAdvance = gnc_prefs_get_float (GNC_PREFS_GROUP_SXED, GNC_PREF_CREATE_DAYS); xaccSchedXactionSetAdvanceCreation( sx, daysInAdvance ); daysInAdvance = gnc_prefs_get_float (GNC_PREFS_GROUP_SXED, GNC_PREF_REMIND_DAYS); xaccSchedXactionSetAdvanceReminder( sx, daysInAdvance ); } if ( sxftd_add_template_trans( sxfti ) != 0 ) { sxftd_errno = SXFTD_ERRNO_UNBALANCED_XACTION; } return sxftd_errno; }