gboolean ap_validate_menu (GtkAssistant *assistant, gpointer user_data) { GDate date_now; AcctPeriodInfo *info = user_data; ENTER("info=%p", info); /* Pull info from widget, push into freq spec */ //gnc_frequency_save_state (info->period_menu, info->period, &info->closing_date); recurrenceListFree(&info->period); gnc_frequency_save_to_recurrence(info->period_menu, &info->period, &info->closing_date); if (0 <= g_date_compare(&info->prev_closing_date, &info->closing_date)) { /* Closing date must be greater than closing date of previous book */ return FALSE; } g_date_clear (&date_now, 1); gnc_gdate_set_today (&date_now); if (0 < g_date_compare(&info->closing_date, &date_now)) { /* Closing date must be in the future */ return FALSE; } return TRUE; }
static gboolean ap_validate_menu (GnomeDruidPage *druidpage, GtkWidget *druid, gpointer user_data) { GDate date_now; AcctPeriodInfo *info = user_data; ENTER("info=%p", info); /* Pull info from widget, push into freq spec */ //gnc_frequency_save_state (info->period_menu, info->period, &info->closing_date); recurrenceListFree(&info->period); gnc_frequency_save_to_recurrence(info->period_menu, &info->period, &info->closing_date); if (0 <= g_date_compare(&info->prev_closing_date, &info->closing_date)) { const char *msg = _("You must select closing date that " "is greater than the closing date " "of the previous book."); gnc_error_dialog (info->window, "%s", msg); return TRUE; } g_date_clear (&date_now, 1); g_date_set_time_t (&date_now, time(NULL)); if (0 < g_date_compare(&info->closing_date, &date_now)) { const char *msg = _("You must select closing date " "that is not in the future."); gnc_error_dialog (info->window, "%s", msg); return TRUE; } return FALSE; }
static void show_book_details (AcctPeriodInfo *info) { QofBook *currbook; char close_date_str[MAX_DATE_LENGTH]; char prev_close_date_str[MAX_DATE_LENGTH]; const char *period_text; char *str; const char *cstr; int ntrans, nacc; ENTER ("info=%p", info); /* Tell user about how the previous book closing went. */ cstr = get_close_status_str (info); gtk_label_set_text (info->close_results, cstr); info->close_status = -1; /* Pull info from widget, push into freq spec */ //gnc_frequency_save_state (info->period_menu, info->period, &info->closing_date); recurrenceListFree(&info->period); gnc_frequency_save_to_recurrence(info->period_menu, &info->period, &info->closing_date); qof_print_date_dmy_buff (close_date_str, MAX_DATE_LENGTH, g_date_get_day(&info->closing_date), g_date_get_month(&info->closing_date), g_date_get_year(&info->closing_date)); currbook = gnc_get_current_book(); ntrans = get_num_xactions_before_date(currbook, gnc_timet_get_day_end_gdate (&info->closing_date)); nacc = gnc_account_n_descendants (gnc_book_get_root_account (currbook)); /* Display the book info */ period_text = _("You have asked for a book to be created. This book " "will contain all transactions up to midnight %s " "(for a total of %d transactions spread over %d accounts). " "Click on 'Forward' to create this book. " "Click on 'Back' to adjust the dates."); str = g_strdup_printf (period_text, close_date_str, ntrans, nacc); gtk_label_set_text (info->book_details, str); g_free (str); /* Weird bug fix ! */ gtk_widget_show (GTK_WIDGET (info->book_details)); /* Create default settings for the title, notes fields */ qof_print_date_dmy_buff (prev_close_date_str, MAX_DATE_LENGTH, g_date_get_day(&info->prev_closing_date), g_date_get_month(&info->prev_closing_date), g_date_get_year(&info->prev_closing_date)); str = g_strdup_printf (_("Period %s - %s"), prev_close_date_str, close_date_str); gtk_entry_set_text (info->book_title, str); xxxgtk_textview_set_text (info->book_notes, str); g_free (str); }
static void prepare_remarks (AcctPeriodInfo *info) { int nperiods; GDate period_begin, period_end, date_now; const char *remarks_text; char * str; ENTER ("info=%p", info); /* Pull info from widget, push into freq spec */ //gnc_frequency_save_state (info->period_menu, info->period, &info->closing_date); recurrenceListFree(&info->period); gnc_frequency_save_to_recurrence(info->period_menu, &info->period, &info->closing_date); /* Count the number of periods that would be generated. */ g_date_clear (&period_begin, 1); g_date_clear (&period_end, 1); g_date_clear (&date_now, 1); nperiods = 0; period_end = info->closing_date; g_date_set_time_t (&date_now, time(NULL)); while (0 > g_date_compare(&period_end, &date_now )) { nperiods ++; PINFO ("period=%d end date=%d/%d/%d", nperiods, g_date_get_month(&period_end), g_date_get_day(&period_end), g_date_get_year(&period_end)); period_begin = period_end; recurrenceListNextInstance(info->period, &period_begin, &period_end); } /* Display the results */ remarks_text = _("The earliest transaction date found in this book is %s. " "Based on the selection made above, this book will be split " "into %d books. Click on 'Forward' to start closing the " "earliest book."); str = g_strdup_printf (remarks_text, info->earliest_str, nperiods); gtk_label_set_text (info->period_remarks, str); g_free (str); }
void ap_assistant_book_prepare (GtkAssistant *assistant, gpointer user_data) { QofBook *currbook; char close_date_str[MAX_DATE_LENGTH]; char prev_close_date_str[MAX_DATE_LENGTH]; const char *period_text; char *str; const char *cstr; int ntrans, nacc; GtkTextBuffer *buffer; AcctPeriodInfo *info = user_data; ENTER ("info=%p", info); /* Tell user about how the previous book closing went. */ cstr = get_close_status_str (info); gtk_label_set_text (GTK_LABEL(info->close_results), cstr); info->close_status = -1; /* Pull info from widget, push into freq spec */ //gnc_frequency_save_state (info->period_menu, info->period, &info->closing_date); recurrenceListFree(&info->period); gnc_frequency_save_to_recurrence(info->period_menu, &info->period, &info->closing_date); qof_print_date_dmy_buff (close_date_str, MAX_DATE_LENGTH, g_date_get_day(&info->closing_date), g_date_get_month(&info->closing_date), g_date_get_year(&info->closing_date)); currbook = gnc_get_current_book(); ntrans = get_num_xactions_before_date(currbook, gnc_time64_get_day_end_gdate (&info->closing_date)); nacc = gnc_account_n_descendants (gnc_book_get_root_account (currbook)); /* Display the book info */ period_text = /* Translators: Run the assistent in your language to see GTK's translation of the button labels. */ _("You have asked for a book to be created. This book " "will contain all transactions up to midnight %s " "(for a total of %d transactions spread over %d accounts).\n\n " "Amend the Title and Notes or Click on \"Next\" to proceed.\n " "Click on \"Back\" to adjust the dates or \"Cancel\"."); str = g_strdup_printf (period_text, close_date_str, ntrans, nacc); gtk_label_set_text (GTK_LABEL(info->book_details), str); g_free (str); gtk_widget_show (GTK_WIDGET (info->book_details)); /* Create default settings for the title, notes fields */ qof_print_date_dmy_buff (prev_close_date_str, MAX_DATE_LENGTH, g_date_get_day(&info->prev_closing_date), g_date_get_month(&info->prev_closing_date), g_date_get_year(&info->prev_closing_date)); str = g_strdup_printf (_("Period %s - %s"), prev_close_date_str, close_date_str); gtk_entry_set_text (GTK_ENTRY(info->book_title), str); buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(info->book_notes)); gtk_text_buffer_set_text(buffer, str, -1); g_free (str); }
void ap_assistant_menu_prepare (GtkAssistant *assistant, gpointer user_data) { int nperiods; GDate period_begin, period_end, date_now; char * str; AcctPeriodInfo *info = user_data; ENTER ("info=%p", info); /* Pull info from widget, push into freq spec */ //gnc_frequency_save_state (info->period_menu, info->period, &info->closing_date); recurrenceListFree(&info->period); gnc_frequency_save_to_recurrence(info->period_menu, &info->period, &info->closing_date); /* Count the number of periods that would be generated. */ g_date_clear (&period_begin, 1); g_date_clear (&period_end, 1); g_date_clear (&date_now, 1); nperiods = 0; period_end = info->closing_date; gnc_gdate_set_time64 (&date_now, gnc_time (NULL)); while (0 > g_date_compare(&period_end, &date_now )) { nperiods ++; PINFO ("Period = %d and End date is %d/%d/%d", nperiods, g_date_get_month(&period_end), g_date_get_day(&period_end), g_date_get_year(&period_end)); period_begin = period_end; recurrenceListNextInstance(info->period, &period_begin, &period_end); /* FIXME Check for valid period_end, not sure why it won't be!!! */ if (g_date_valid (&period_end) != TRUE) break; } /* Find the date of the earliest transaction in the current book. * Note that this could have changed since last time, since * we may have closed books since last time. */ info->earliest = get_earliest_in_book (gnc_get_current_book()); info->earliest_str = qof_print_date(info->earliest); PINFO ("Date of earliest transaction is %" G_GINT64_FORMAT " %s", info->earliest, gnc_ctime (&info->earliest)); /* Display the results */ str = g_strdup_printf ( /* Translators: %s is a date string. %d is the number of books * that will be created. This is a ngettext(3) message (but * only for the %d part). */ ngettext("The earliest transaction date found in this book is %s. " "Based on the selection made above, this book will be split " "into %d book.", "The earliest transaction date found in this book is %s. " "Based on the selection made above, this book will be split " "into %d books.", nperiods), info->earliest_str, nperiods); gtk_label_set_text (GTK_LABEL(info->period_remarks), str); g_free (str); }