diff --git a/ChangeLog b/ChangeLog index 6488ba9666..c8366b966b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2000-05-18 Dave Peticolas + + * src/gnome/window-reconcile.c: make the finish button sensitivity + depend on whether the reconciliation is balanced. + + * src/register/gnome/gnucash-sheet.c + (gnucash_sheet_activate_cursor_cell): if the callback changes the + value, redraw. + +2000-05-17 Dave Peticolas + + * src/engine/Query.c: allow sorting by reconciled date and + reconcile status. + + * src/gnome/window-reconcile.c: add a 'statement date' to the + reconciliation date. This date is used to set all the reconcile + dates of the splits that get reconciled. + + * src/engine/Transaction.c (xaccSplitSetReconcile): don't change + the reconcile date when the reconcile status is changed. + 2000-05-18 Robert Graham Merkel * src/scm/report/transaction-report-2.scm: Fixed *some* of the diff --git a/src/engine/Account.c b/src/engine/Account.c index bee05e9324..ae807ffa7c 100644 --- a/src/engine/Account.c +++ b/src/engine/Account.c @@ -1186,7 +1186,7 @@ xaccAccountGetParentAccount (Account * acc) return xaccGroupGetParentAccount(acc->parent); } -int +GNCAccountType xaccAccountGetType (Account *acc) { if (!acc) return NO_TYPE; diff --git a/src/engine/Account.h b/src/engine/Account.h index d9c2c258d8..f6ef6ce67a 100644 --- a/src/engine/Account.h +++ b/src/engine/Account.h @@ -149,7 +149,7 @@ void xaccAccountSetNotes (Account *, const char *); void xaccAccountSetCurrency (Account *, const char *); void xaccAccountSetSecurity (Account *, const char *); -int xaccAccountGetType (Account *); +GNCAccountType xaccAccountGetType (Account *); char * xaccAccountGetName (Account *); char * xaccAccountGetFullName (Account *, const char separator); char * xaccAccountGetCode (Account *); diff --git a/src/engine/Query.c b/src/engine/Query.c index 722b320c08..62a1cdc037 100644 --- a/src/engine/Query.c +++ b/src/engine/Query.c @@ -418,6 +418,26 @@ acct_query_matches(QueryTerm * qt, Account * acct) { static Query * split_sort_query = NULL; +static int +date_cmp_func(Timespec *t1, Timespec *t2) { + /* check seconds */ + if (t1->tv_sec < t2->tv_sec) { + return -1; + } + else if (t1->tv_sec > t2->tv_sec) { + return +1; + } + + /* else, seconds match. check nanoseconds */ + if (t1->tv_nsec < t2->tv_nsec) { + return -1; + } + else if (t1->tv_nsec > t2->tv_nsec) { + return +1; + } + + return 0; +} static int split_cmp_func(sort_type_t how, gconstpointer ga, gconstpointer gb) { @@ -452,56 +472,25 @@ split_cmp_func(sort_type_t how, gconstpointer ga, gconstpointer gb) { break; case BY_DATE: - /* if dates differ, return */ - if ( (ta->date_posted.tv_sec) < - (tb->date_posted.tv_sec)) { - return -1; - } - else if ((ta->date_posted.tv_sec) > - (tb->date_posted.tv_sec)) { - return +1; - } - - /* else, seconds match. check nanoseconds */ - if ( (ta->date_posted.tv_nsec) < - (tb->date_posted.tv_nsec)) { - return -1; - } - else if ( (ta->date_posted.tv_nsec) > - (tb->date_posted.tv_nsec)) { - return +1; - } - return 0; + return date_cmp_func(&(ta->date_posted), &(tb->date_posted)); + break; case BY_DATE_ENTERED: - /* if dates differ, return */ - if ( (ta->date_entered.tv_sec) < - (tb->date_entered.tv_sec)) { - return -1; - } - else if ((ta->date_entered.tv_sec) > - (tb->date_entered.tv_sec)) { - return +1; - } + return date_cmp_func(&(ta->date_entered), &(tb->date_entered)); + + break; + + case BY_DATE_RECONCILED: + return date_cmp_func(&(sa->date_reconciled), &(sb->date_reconciled)); - /* else, seconds match. check nanoseconds */ - if ( (ta->date_entered.tv_nsec) < - (tb->date_entered.tv_nsec)) { - return -1; - } - else if ( (ta->date_entered.tv_nsec) > - (tb->date_entered.tv_nsec)) { - return +1; - } - return 0; break; case BY_NUM: /* sort on transaction number */ - da = ta->num; - db = tb->num; - if (gnc_strisnum(da)) { + da = ta->num; + db = tb->num; + if (gnc_strisnum(da)) { if (!gnc_strisnum(db)) { return -1; } @@ -583,7 +572,30 @@ split_cmp_func(sort_type_t how, gconstpointer ga, gconstpointer gb) { return 0; } break; - + + case BY_RECONCILE: + /* Reconcile flags are sorted as: FREC = YREC < CREC = NREC */ + switch (sa->reconciled) { + case YREC: + case FREC: + if (sb->reconciled == YREC) + return 0; + if (sb->reconciled == FREC) + return 0; + return -1; + break; + + case CREC: + case NREC: + if (sb->reconciled == CREC) + return 0; + if (sb->reconciled == NREC) + return 0; + return 1; + break; + } + break; + case BY_NONE: return 0; break; diff --git a/src/engine/Query.h b/src/engine/Query.h index 07aec8e967..dbc874463e 100644 --- a/src/engine/Query.h +++ b/src/engine/Query.h @@ -44,10 +44,12 @@ typedef enum { BY_STANDARD, BY_DATE, BY_DATE_ENTERED, + BY_DATE_RECONCILED, BY_NUM, BY_AMOUNT, BY_MEMO, BY_DESC, + BY_RECONCILE, BY_NONE } sort_type_t; diff --git a/src/engine/Transaction.c b/src/engine/Transaction.c index 060ae4bb45..9b4c84cfc6 100644 --- a/src/engine/Transaction.c +++ b/src/engine/Transaction.c @@ -1997,16 +1997,11 @@ xaccSplitSetDocref (Split *split, const char *docs) void xaccSplitSetReconcile (Split *split, char recn) { - struct timeval tv; - if (!split) return; + split->reconciled = recn; MARK_SPLIT (split); - gettimeofday (&tv, NULL); - split->date_reconciled.tv_sec = tv.tv_sec; - split->date_reconciled.tv_nsec = 1000 * tv.tv_usec; - xaccAccountRecomputeBalance (split->acc); } @@ -2026,7 +2021,7 @@ xaccSplitSetDateReconciledTS (Split *split, Timespec *ts) if (!split) return; MARK_SPLIT (split); - split->date_reconciled = *ts; + split->date_reconciled = *ts; } void diff --git a/src/gnome/reconcile-list.c b/src/gnome/reconcile-list.c index e2d780827e..2cc2ba6840 100644 --- a/src/gnome/reconcile-list.c +++ b/src/gnome/reconcile-list.c @@ -450,10 +450,11 @@ gnc_reconcile_list_reconciled_balance(GNCReconcileList *list) * commit the reconcile information in the list * * * * Args: list - list to commit * + * date - date to set as the reconcile date * * Returns: nothing * \********************************************************************/ void -gnc_reconcile_list_commit(GNCReconcileList *list) +gnc_reconcile_list_commit(GNCReconcileList *list, time_t date) { GtkCList *clist = GTK_CLIST(list); Split *split; @@ -470,7 +471,10 @@ gnc_reconcile_list_commit(GNCReconcileList *list) split = gtk_clist_get_row_data(clist, i); if (g_hash_table_lookup(list->reconciled, split) != NULL) + { xaccSplitSetReconcile(split, YREC); + xaccSplitSetDateReconciledSecs(split, date); + } } } diff --git a/src/gnome/reconcile-list.h b/src/gnome/reconcile-list.h index e77c2bca79..ff3b6d3bbc 100644 --- a/src/gnome/reconcile-list.h +++ b/src/gnome/reconcile-list.h @@ -94,7 +94,7 @@ void gnc_reconcile_list_refresh (GNCReconcileList *list); double gnc_reconcile_list_reconciled_balance(GNCReconcileList *list); -void gnc_reconcile_list_commit(GNCReconcileList *list); +void gnc_reconcile_list_commit(GNCReconcileList *list, time_t date); void gnc_reconcile_list_unselect_all(GNCReconcileList *list); diff --git a/src/gnome/window-reconcile.c b/src/gnome/window-reconcile.c index 99c9cc4b96..c73a34eff0 100644 --- a/src/gnome/window-reconcile.c +++ b/src/gnome/window-reconcile.c @@ -43,6 +43,7 @@ #include "dialog-utils.h" #include "reconcile-list.h" #include "global-options.h" +#include "gnc-dateedit.h" #include "Refresh.h" #include "query-user.h" #include "window-help.h" @@ -60,11 +61,12 @@ struct _RecnWindow { Account *account; /* The account that we are reconciling */ double new_ending; /* The new ending balance */ + time_t statement_date; /* The statement date */ GtkWidget *window; /* The reconcile window */ - GtkWidget *toolbar; - SCM toolbar_change_callback_id; + GtkWidget *toolbar; /* Toolbar widget */ + SCM toolbar_change_cb_id; /* id for toolbar preference change cb */ GtkWidget *starting; /* The starting balance */ GtkWidget *ending; /* The ending balance */ @@ -77,6 +79,11 @@ struct _RecnWindow GtkWidget *debit; /* Debit matrix show unreconciled debit */ GtkWidget *credit; /* Credit matrix, shows credits... */ + GtkWidget *debit_frame; /* Frame around debit matrix */ + GtkWidget *credit_frame; /* Frame around credit matrix */ + + SCM title_change_cb_id; /* id for label preference cb */ + GtkWidget *edit_item; /* Edit transaction menu item */ GtkWidget *delete_item; /* Delete transaction menu item */ @@ -85,8 +92,7 @@ struct _RecnWindow GtkWidget *edit_button; /* Edit transaction button */ GtkWidget *delete_button; /* Delete transaction button */ - - char * symbol; /* Currency symbol or 's' for shares */ + GtkWidget *finish_button; /* Finish reconciliation button */ gboolean delete_refresh; /* do a refresh upon a window deletion */ }; @@ -94,13 +100,13 @@ struct _RecnWindow /** PROTOTYPES ******************************************************/ static double recnRecalculateBalance( RecnWindow *recnData ); -static void recnClose(GtkWidget *w, gpointer data); -static void recnFinishCB(GtkWidget *w, gpointer data); -static void recnCancelCB(GtkWidget *w, gpointer data); +static void recnClose(GtkWidget *w, gpointer data); +static void recnFinishCB(GtkWidget *w, gpointer data); +static void recnCancelCB(GtkWidget *w, gpointer data); -static void gnc_reconcile_window_set_sensitivity(RecnWindow *recnData); -static char *gnc_recn_make_window_name(Account *account); -static void gnc_recn_set_window_name(RecnWindow *recnData); +static void gnc_reconcile_window_set_sensitivity(RecnWindow *recnData); +static char * gnc_recn_make_window_name(Account *account); +static void gnc_recn_set_window_name(RecnWindow *recnData); /** GLOBALS *********************************************************/ @@ -146,7 +152,8 @@ recnRefresh(Account *account) * refreshes the balances in the reconcile window * * * * Args: recnData -- the reconcile window to refresh * - * Return: the reconciled balance * + * Return: the difference between the nominal ending balance * + * and the 'effective' ending balance. * \********************************************************************/ static double recnRecalculateBalance(RecnWindow *recnData) @@ -227,6 +234,8 @@ recnRecalculateBalance(RecnWindow *recnData) if (reverse_balance) diff = -diff; + gtk_widget_set_sensitive(recnData->finish_button, DEQ(diff, 0.0)); + return diff; } @@ -271,30 +280,31 @@ gnc_start_recn_update_cb(GtkWidget *widget, GdkEventFocus *event, * opens up the window to prompt the user to enter the ending * * balance from bank statement * * * - * NOTE: This dialog does not return until the user presses "Ok" * + * NOTE: This function does not return until the user presses "Ok" * * or "Cancel" * * * - * Args: parent - the parent of this window * - * account - the account to reconcile * - * new_ending - returns the amount for ending balance * + * Args: parent - the parent of this window * + * account - the account to reconcile * + * new_ending - returns the amount for ending balance * + * statement_date - returns date of the statement :) * * Return: True, if the user presses "Ok", else False * \********************************************************************/ static gboolean -startRecnWindow(GtkWidget *parent, Account *account, double *new_ending) +startRecnWindow(GtkWidget *parent, Account *account, + double *new_ending, time_t *statement_date) { - GtkWidget *dialog, *end_value; + GtkWidget *dialog, *end_value, *date_value; char *amount, *title, *currency; + GNCAccountType account_type; GNCPrintAmountFlags flags; double dendBalance; - int account_type; int result; flags = PRTSYM | PRTSEP; /* Get the previous ending balance. Use the published * account interface for this, since the ending balance - * may have to be adjusted for stock price fluctuations. - */ + * may have to be adjusted for stock price fluctuations. */ dendBalance = xaccAccountGetReconciledBalance(account); if (gnc_reverse_balance(account)) { @@ -330,10 +340,13 @@ startRecnWindow(GtkWidget *parent, Account *account, double *new_ending) GtkWidget *main_area = gtk_hbox_new(FALSE, 5); GtkWidget *left_column = gtk_vbox_new(TRUE, 0); GtkWidget *right_column = gtk_vbox_new(TRUE, 0); + GtkWidget *date_title = gtk_label_new(STATEMENT_DATE_C_STR); GtkWidget *start_title = gtk_label_new(START_BALN_C_STR); GtkWidget *end_title = gtk_label_new(END_BALN_C_STR); GtkWidget *start_value = gtk_label_new(amount); GtkWidget *vbox = GNOME_DIALOG(dialog)->vbox; + + date_value = gnc_date_edit_new(*statement_date, GNC_F, GNC_F); end_value = gtk_entry_new(); amount = xaccPrintAmount(*new_ending, flags & ~PRTSYM, currency); @@ -346,6 +359,7 @@ startRecnWindow(GtkWidget *parent, Account *account, double *new_ending) gnome_dialog_editable_enters(GNOME_DIALOG(dialog), GTK_EDITABLE(end_value)); + gtk_misc_set_alignment(GTK_MISC(date_title), 1.0, 0.5); gtk_misc_set_alignment(GTK_MISC(start_title), 1.0, 0.5); gtk_misc_set_alignment(GTK_MISC(start_value), 0.0, 0.5); gtk_misc_set_alignment(GTK_MISC(end_title), 1.0, 0.5); @@ -359,8 +373,11 @@ startRecnWindow(GtkWidget *parent, Account *account, double *new_ending) gtk_box_pack_start(GTK_BOX(main_area), left_column, FALSE, FALSE, 0); gtk_box_pack_end(GTK_BOX(main_area), right_column, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(left_column), date_title, TRUE, TRUE, 3); gtk_box_pack_start(GTK_BOX(left_column), start_title, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(left_column), end_title, TRUE, TRUE, 0); + + gtk_box_pack_start(GTK_BOX(right_column), date_value, TRUE, TRUE, 3); gtk_box_pack_start(GTK_BOX(right_column), start_value, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(right_column), end_value, TRUE, TRUE, 0); @@ -380,6 +397,7 @@ startRecnWindow(GtkWidget *parent, Account *account, double *new_ending) string = gtk_entry_get_text(GTK_ENTRY(end_value)); *new_ending = xaccParseAmount(string, GNC_T); + *statement_date = gnc_date_edit_get_date(GNC_DATE_EDIT(date_value)); if (gnc_reverse_balance(account)) *new_ending = -(*new_ending); @@ -448,39 +466,57 @@ gnc_reconcile_window_focus_cb(GtkWidget *widget, GdkEventFocus *event, gnc_reconcile_list_unselect_all(other_list); } -static GtkWidget * -gnc_reconcile_window_create_list_frame(Account *account, - GNCReconcileListType type, - RecnWindow *recnData, - GtkWidget **list_save, - GtkWidget **total_save) +static void +gnc_reconcile_window_set_frame_titles(RecnWindow *recnData) { - GtkWidget *frame, *scrollWin, *list, *vbox, *label, *hbox; gboolean formal; - gchar * title; + gchar *title; formal = gnc_lookup_boolean_option("General", "Use accounting labels", GNC_F); - if (type == RECLIST_DEBIT) - { - if (formal) - title = DEBITS_STR; - else - title = gnc_get_debit_string(NO_TYPE); - } + if (formal) + title = DEBITS_STR; else - { - if (formal) - title = CREDITS_STR; - else - title = gnc_get_credit_string(NO_TYPE); - } + title = gnc_get_debit_string(NO_TYPE); - frame = gtk_frame_new(title); + gtk_frame_set_label(GTK_FRAME(recnData->debit_frame), title); if (!formal) - free(title); + g_free(title); + + if (formal) + title = CREDITS_STR; + else + title = gnc_get_credit_string(NO_TYPE); + + gtk_frame_set_label(GTK_FRAME(recnData->credit_frame), title); + + if (!formal) + g_free(title); +} + +static void +set_frame_titles_cb(void *data) +{ + gnc_reconcile_window_set_frame_titles(data); +} + +static GtkWidget * +gnc_reconcile_window_create_list_box(Account *account, + GNCReconcileListType type, + RecnWindow *recnData, + GtkWidget **list_save, + GtkWidget **total_save) +{ + GtkWidget *frame, *scrollWin, *list, *vbox, *label, *hbox; + + frame = gtk_frame_new(NULL); + + if (type == RECLIST_DEBIT) + recnData->debit_frame = frame; + else + recnData->credit_frame = frame; vbox = gtk_vbox_new(FALSE, 5); @@ -488,9 +524,11 @@ gnc_reconcile_window_create_list_frame(Account *account, *list_save = list; gtk_signal_connect(GTK_OBJECT(list), "toggle_reconciled", - GTK_SIGNAL_FUNC(gnc_reconcile_window_list_cb), recnData); + GTK_SIGNAL_FUNC(gnc_reconcile_window_list_cb), + recnData); gtk_signal_connect(GTK_OBJECT(list), "focus_in_event", - GTK_SIGNAL_FUNC(gnc_reconcile_window_focus_cb), recnData); + GTK_SIGNAL_FUNC(gnc_reconcile_window_focus_cb), + recnData); scrollWin = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (scrollWin), @@ -558,10 +596,13 @@ gnc_ui_reconcile_window_change_cb(GtkButton *button, gpointer data) { RecnWindow *recnData = (RecnWindow *) data; double new_ending = recnData->new_ending; + time_t statement_date = recnData->statement_date; - if (startRecnWindow(recnData->window, recnData->account, &new_ending)) + if (startRecnWindow(recnData->window, recnData->account, + &new_ending, &statement_date)) { recnData->new_ending = new_ending; + recnData->statement_date = statement_date; recnRecalculateBalance(recnData); } } @@ -751,7 +792,7 @@ gnc_recn_create_menu_bar(RecnWindow *recnData, GtkWidget *statusbar) { { GNOME_APP_UI_ITEM, - END_BALN_MENU_E_STR_N, TOOLTIP_ADJUST_END_N, + RECN_INFO_MENU_E_STR_N, TOOLTIP_RECN_INFO_N, gnc_ui_reconcile_window_change_cb, NULL, NULL, GNOME_APP_PIXMAP_NONE, NULL, 0, 0, NULL @@ -999,6 +1040,7 @@ gnc_recn_create_tool_bar(RecnWindow *recnData) recnData->edit_button = toolbar_info[1].widget; recnData->delete_button = toolbar_info[2].widget; + recnData->finish_button = toolbar_info[6].widget; return toolbar; } @@ -1020,6 +1062,7 @@ recnWindow(GtkWidget *parent, Account *account) GtkWidget *vbox; GtkWidget *dock; double new_ending; + time_t statement_date; if (account == NULL) return NULL; @@ -1027,10 +1070,11 @@ recnWindow(GtkWidget *parent, Account *account) FETCH_FROM_LIST(RecnWindow, recnList, account, account, recnData); new_ending = xaccAccountGetBalance(account); + statement_date = time(NULL); /* Popup a little window to prompt the user to enter the * ending balance for his/her bank statement */ - if (!startRecnWindow(parent, account, &new_ending)) + if (!startRecnWindow(parent, account, &new_ending, &statement_date)) { REMOVE_FROM_LIST(RecnWindow, recnList, account, account); free(recnData); @@ -1038,6 +1082,7 @@ recnWindow(GtkWidget *parent, Account *account) } recnData->new_ending = new_ending; + recnData->statement_date = statement_date; recnData->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); recnData->delete_refresh = FALSE; @@ -1052,12 +1097,8 @@ recnWindow(GtkWidget *parent, Account *account) statusbar = gnc_recn_create_status_bar(recnData); gtk_box_pack_start(GTK_BOX(vbox), statusbar, FALSE, FALSE, 0); - /* here we connect the "destroy" event to a signal handler. - * This event occurs when we call gtk_widget_destroy() on the window, - * or if we return 'FALSE' in the "delete_event" callback. - * Eventually executed by gnome_dialog_close() */ gtk_signal_connect (GTK_OBJECT (recnData->window), "destroy", - GTK_SIGNAL_FUNC(recnClose), (gpointer) recnData); + GTK_SIGNAL_FUNC(recnClose), recnData); /* The menu bar */ { @@ -1088,7 +1129,7 @@ recnWindow(GtkWidget *parent, Account *account) id = gnc_register_option_change_callback(gnc_toolbar_change_cb, recnData, "General", "Toolbar Buttons"); - recnData->toolbar_change_callback_id = id; + recnData->toolbar_change_cb_id = id; gnome_dock_add_item (GNOME_DOCK(dock), GNOME_DOCK_ITEM(dock_item), GNOME_DOCK_TOP, 1, 0, 0, TRUE); @@ -1099,8 +1140,8 @@ recnWindow(GtkWidget *parent, Account *account) GtkWidget *frame = gtk_frame_new(NULL); GtkWidget *main_area = gtk_vbox_new(FALSE, 10); GtkWidget *debcred_area = gtk_hbox_new(FALSE, 15); - GtkWidget *debits_frame; - GtkWidget *credits_frame; + GtkWidget *debits_box; + GtkWidget *credits_box; GtkWidget *popup; gnome_dock_set_client_area(GNOME_DOCK(dock), frame); @@ -1108,21 +1149,27 @@ recnWindow(GtkWidget *parent, Account *account) gtk_container_add(GTK_CONTAINER(frame), main_area); gtk_container_set_border_width(GTK_CONTAINER(main_area), 10); - debits_frame = gnc_reconcile_window_create_list_frame + debits_box = gnc_reconcile_window_create_list_box (account, RECLIST_DEBIT, recnData, &recnData->debit, &recnData->total_debit); - credits_frame = gnc_reconcile_window_create_list_frame + credits_box = gnc_reconcile_window_create_list_box (account, RECLIST_CREDIT, recnData, &recnData->credit, &recnData->total_credit); + gnc_reconcile_window_set_frame_titles(recnData); + + recnData->title_change_cb_id = + gnc_register_option_change_callback(set_frame_titles_cb, recnData, + "General", "Use accounting labels"); + popup = gnc_recn_create_popup_menu(recnData); gnome_popup_menu_attach(popup, recnData->debit, recnData); gnome_popup_menu_attach(popup, recnData->credit, recnData); gtk_box_pack_start(GTK_BOX(main_area), debcred_area, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(debcred_area), debits_frame, TRUE, FALSE, 0); - gtk_box_pack_end(GTK_BOX(debcred_area), credits_frame, TRUE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(debcred_area), debits_box, TRUE, FALSE, 0); + gtk_box_pack_end(GTK_BOX(debcred_area), credits_box, TRUE, FALSE, 0); { GtkWidget *hbox, *title_vbox, *value_vbox; @@ -1221,6 +1268,8 @@ recnWindow(GtkWidget *parent, Account *account) gtk_widget_show_all(recnData->window); + recnRecalculateBalance(recnData); + gnc_recn_refresh_toolbar(recnData); return recnData; @@ -1288,7 +1337,10 @@ recnClose(GtkWidget *w, gpointer data) REMOVE_FROM_LIST(RecnWindow, recnList, account, account); - id = recnData->toolbar_change_callback_id; + id = recnData->toolbar_change_cb_id; + gnc_unregister_option_change_callback_id(id); + + id = recnData->title_change_cb_id; gnc_unregister_option_change_callback_id(id); if (recnData->delete_refresh) @@ -1309,18 +1361,21 @@ recnClose(GtkWidget *w, gpointer data) static void recnFinishCB(GtkWidget *w, gpointer data) { - RecnWindow *recnData = data; + RecnWindow *recnData = data; + time_t date; if (!DEQ(recnRecalculateBalance(recnData), 0.0)) if (!gnc_verify_dialog_parented(GTK_WINDOW(recnData->window), RECN_BALN_WARN, GNC_F)) return; - gnc_reconcile_list_commit(GNC_RECONCILE_LIST(recnData->credit)); - gnc_reconcile_list_commit(GNC_RECONCILE_LIST(recnData->debit)); + date = recnData->statement_date; + + gnc_reconcile_list_commit(GNC_RECONCILE_LIST(recnData->credit), date); + gnc_reconcile_list_commit(GNC_RECONCILE_LIST(recnData->debit), date); recnData->delete_refresh = TRUE; - + gtk_widget_destroy(recnData->window); } diff --git a/src/gnome/window-register.c b/src/gnome/window-register.c index 0bb66b8e65..34f70e5b50 100644 --- a/src/gnome/window-register.c +++ b/src/gnome/window-register.c @@ -337,6 +337,10 @@ gnc_register_sort(RegWindow *regData, int sort_code) case BY_DATE_ENTERED: xaccQuerySetSortOrder(query, BY_DATE_ENTERED, BY_STANDARD, BY_NONE); break; + case BY_DATE_RECONCILED: + xaccQuerySetSortOrder(query, BY_RECONCILE, BY_DATE_RECONCILED, + BY_STANDARD); + break; case BY_NUM: xaccQuerySetSortOrder(query, BY_NUM, BY_DATE, BY_AMOUNT); break; @@ -381,6 +385,14 @@ gnc_register_sort_date_entered_cb(GtkWidget *w, gpointer data) gnc_register_sort(regData, BY_DATE_ENTERED); } +static void +gnc_register_sort_date_reconciled_cb(GtkWidget *w, gpointer data) +{ + RegWindow *regData = data; + + gnc_register_sort(regData, BY_DATE_RECONCILED); +} + static void gnc_register_sort_num_cb(GtkWidget *w, gpointer data) { @@ -497,7 +509,7 @@ gnc_register_set_date_range(RegWindow *regData) toggle = GTK_TOGGLE_BUTTON(regDateData->show_earliest); xaccQueryPurgeTerms(regData->ledger->query, PD_DATE); - + if (!gtk_toggle_button_get_active(toggle)) { time_t start; @@ -1070,7 +1082,12 @@ gnc_register_create_menu_bar(RegWindow *regData, GtkWidget *statusbar) gnc_register_sort_date_cb, NULL, NULL), GNOMEUIINFO_RADIOITEM_DATA(SORT_BY_ENTERED_STR_N, TOOLTIP_SORT_BY_ENTERED_N, - gnc_register_sort_date_entered_cb, NULL, NULL), + gnc_register_sort_date_entered_cb, + NULL, NULL), + GNOMEUIINFO_RADIOITEM_DATA(SORT_BY_STMT_STR_N, + TOOLTIP_SORT_BY_STMT_N, + gnc_register_sort_date_reconciled_cb, + NULL, NULL), GNOMEUIINFO_RADIOITEM_DATA(SORT_BY_NUM_STR_N, TOOLTIP_SORT_BY_NUM_N, gnc_register_sort_num_cb, NULL, NULL), GNOMEUIINFO_RADIOITEM_DATA(SORT_BY_AMNT_STR_N, TOOLTIP_SORT_BY_AMNT_N, diff --git a/src/messages_i18n.h b/src/messages_i18n.h index cd6f249d70..81c7bad57a 100644 --- a/src/messages_i18n.h +++ b/src/messages_i18n.h @@ -62,8 +62,8 @@ /** DIALOG BOX MESSAGES: ********************************************/ #define ABOUT_MSG _("The GnuCash personal finance manager.\n"\ "The GNU way to manage your money!") -#define ACC_ADJUST_MSG _("To adjust an account's balance, you must first\n"\ - "choose an account to adjust.\n") +#define ACC_ADJUST_MSG _("To adjust an account's balance, you must "\ + "first\nchoose an account to adjust.\n") #define ACC_BAD_PARENT_MSG _("You must choose a valid parent account.") #define ACC_NEW_MSG _("Do you want to create a new account?\n"\ "If not, then please select an account\n"\ @@ -82,8 +82,8 @@ "choose an account to reconcile.\n") #define AMOUNT_NUM_MSG _("The amount must be a number.") #define BALANCE_NUM_MSG _("The balance must be a number.") -#define CHANGE_RECN_MSG _("Do you really want to mark this transaction"\ - "not reconciled?\nDoing so might make future"\ +#define CHANGE_RECN_MSG _("Do you really want to mark this transaction "\ + "not reconciled?\nDoing so might make future "\ "reconciliation difficult!") #define DEL_SPLITS_MSG _("Delete all the splits") #define DEL_TRANS_MSG _("Delete the whole transaction") @@ -112,15 +112,15 @@ #define FILE_ECLOSE_MSG _("There was an error closing the file\n %s.") #define FILE_NOT_FOUND_MSG _("The file \n %s\n could not be found.") #define FILE_EMPTY_MSG _("The file \n %s\n is empty.") -#define FMB_SAVE_MSG _("Changes have been made since the last "\ +#define FMB_SAVE_MSG _("Changes have been made since the last " \ "Save. Save the data to file?") -#define FMB_EEXIST_MSG _("The file \n %s\n already exists.\n"\ +#define FMB_EEXIST_MSG _("The file \n %s\n already exists.\n" \ "Are you sure you want to overwrite it?") -#define FMB_INVALID_MSG _("The filepath \n %s\n"\ +#define FMB_INVALID_MSG _("The filepath \n %s\n" \ "is not a valid location in the filesystem.") -#define FMB_LOCKED_MSG _("The file \n %s\n"\ - "appears to be in use by another user.\n"\ - "If this is not right, remove the .LCK file "\ +#define FMB_LOCKED_MSG _("The file \n %s\n" \ + "appears to be in use by another user.\n" \ + "If this is not right, remove the .LCK file " \ "and try again.") #define GNOME_PRINT_MSG _("You need to install the gnome-print library.") #define QIF_LOAD_FAILED_FORMAT_MSG _("QIF file load failed. %s") @@ -130,12 +130,13 @@ #define QUOTE_SRC_MSG _("The source for price quotes") #define RECN_BALN_WARN _("The account is not balanced.\n" \ "Are you sure you want to finish?") -#define RECN_CANCEL_WARN _("You have made changes to this reconcile window.\n"\ - "Are you sure you want to cancel?") -#define RECN_TRANS_WARN _("Warning! This is a reconciled transaction. "\ +#define RECN_CANCEL_WARN _("You have made changes to this reconcile " \ + "window.\nAre you sure you want to cancel?") +#define RECN_TRANS_WARN _("Warning! This is a reconciled transaction. " \ "Do you want do continue?") -#define REG_CURR_MSG _("You cannot transfer funds from the %s account.\n"\ - "It does not have a matching currency.") +#define REG_CURR_MSG _("You cannot transfer funds from the %s " \ + "account.\nIt does not have a matching " \ + "currency.") #define REPORT_ERR_MSG _("Error executing scheme report.") #define REPORT_NOPARM_MSG _("This report has no parameters.") #define SHOW_CAT_MSG _("Show the income and expense accounts.") @@ -161,14 +162,16 @@ "They do not have a common currency.") #define XFER_DIFF_MSG _("The \"From\" and \"To\" accounts\n must be " \ "different!") -#define XFER_SAME_MSG _("You can't transfer from and to the same account!") +#define XFER_SAME_MSG _("You can't transfer from and to the same " \ + "account!") #define XFER_NO_ACC_MSG _("You must specify an account to transfer from,\n"\ "or to, or both, for this transaction.\n" \ "Otherwise, it will not be recorded.") /* Tooltip phrases */ -#define TOOLTIP_ADJUST_N N_("Adjust the balance of the selected account") +#define TOOLTIP_ADJUST_N N_("Adjust the balance of the selected " \ + "account") #define TOOLTIP_ADJUST _(TOOLTIP_ADJUST_N) #define TOOLTIP_ADJUST_AMOUNT _("Enter the new balance") #define TOOLTIP_ADJUST_DATE _("Enter the date you want the balance "\ @@ -259,6 +262,9 @@ #define TOOLTIP_RECN_CANCEL _(TOOLTIP_RECN_CANCEL_N) #define TOOLTIP_RECN_FINISH_N N_("Finish the reconciliation of this account") #define TOOLTIP_RECN_FINISH _(TOOLTIP_RECN_FINISH_N) +#define TOOLTIP_RECN_INFO_N N_("Change the reconcile information "\ + "including statement date and ending "\ + "balance.") #define TOOLTIP_RECN_REG_N N_("Reconcile the main account for this "\ "register") #define TOOLTIP_RECN_REG _(TOOLTIP_RECN_REG_N) @@ -275,8 +281,8 @@ #define TOOLTIP_SCRUB_SUB_N N_("Identify and fix problems in the account "\ "and its subaccounts") #define TOOLTIP_SCRUB_SUB _(TOOLTIP_SCRUB_SUB_N) -#define TOOLTIP_SCRUB_REG_N N_("Identify and fix problems in the accounts "\ - "of this register") +#define TOOLTIP_SCRUB_REG_N N_("Identify and fix problems in the "\ + "accounts of this register") #define TOOLTIP_SCRUB_REG _(TOOLTIP_SCRUB_REG_N) #define TOOLTIP_SET_DEFAULT _("Set the option to its default value") #define TOOLTIP_SHOW_ALL_N N_("Show all of the transactions in the "\ @@ -296,9 +302,13 @@ #define TOOLTIP_SORT_BY_MEMO _(TOOLTIP_SORT_BY_MEMO_N) #define TOOLTIP_SORT_BY_NUM_N N_("Sort by Num, then Date, then Amount") #define TOOLTIP_SORT_BY_NUM _(TOOLTIP_SORT_BY_NUM_N) +#define TOOLTIP_SORT_BY_STMT_N N_("Sort by the statement date "\ + "(unreconciled items last") +#define TOOLTIP_SORT_BY_STMT _(TOOLTIP_SORT_BY_STMT_N) #define TOOLTIP_STANDARD_ORD_N N_("Keep normal account order") #define TOOLTIP_STANDARD_ORD _(TOOLTIP_STANDARD_ORD_N) -#define TOOLTIP_TRANSFER_N N_("Transfer funds from one account to another") +#define TOOLTIP_TRANSFER_N N_("Transfer funds from one account to "\ + "another") #define TOOLTIP_TRANSFER _(TOOLTIP_TRANSFER_N) @@ -368,6 +378,7 @@ #define PREFERENCES_MENU_STR _("_Preferences") #define PREFERENCES_MENU_E_STR_N N_("_Preferences...") #define PRINT_CHECK_MENU_E_STR_N N_("_Print Check... (unfinished!)") +#define RECN_INFO_MENU_E_STR_N N_("_Reconcile Information...") #define RECONCILE_MENU_E_STR_N N_("_Reconcile...") #define RECONCILE_MENU_STR_N N_("_Reconcile") #define RECONCILE_MENU_STR _(RECONCILE_MENU_STR_N) @@ -482,11 +493,14 @@ #define SORT_BY_MEMO_STR _(SORT_BY_MEMO_STR_N) #define SORT_BY_NUM_STR_N N_("Sort by Num") #define SORT_BY_NUM_STR _(SORT_BY_NUM_STR_N) +#define SORT_BY_STMT_STR_N N_("Sort by statement date") +#define SORT_BY_STMT_STR _(SORT_BY_STMT_STR_N) #define SORT_ORDER_STR _("Sort Order") #define START_DATE_STR _("Start date") #define START_BALN_STR _("Starting Balance") #define STANDARD_ORDER_STR_N N_("Standard order") #define STANDARD_ORDER_STR _(STANDARD_ORDER_STR_N) +#define STATEMENT_DATE_C_STR _("Statement Date:") #define TOP_ACCT_STR _("Top level account") #define TOTAL_SHARES_STR _("Total Shares") #define VERIFY_CHANGES_STR _("Verify Changes") @@ -595,7 +609,7 @@ #define PARAMETERS_STR _("Parameters") #define PAYMENT_STR _("Payment") #define PORTFOLIO_STR _("Portfolio") -#define POS_STR _("POS") /* Point of Sale credit card machine */ +#define POS_STR _("POS") /* Point of Sale credit card machine */ #define PREFERENCES_STR _("Preferences") #define PRICE_STR _("Price") #define PRINT_STR _("Print") diff --git a/src/register/gnome/gnucash-sheet.c b/src/register/gnome/gnucash-sheet.c index 6610404562..d19967a014 100644 --- a/src/register/gnome/gnucash-sheet.c +++ b/src/register/gnome/gnucash-sheet.c @@ -279,8 +279,11 @@ gnucash_sheet_activate_cursor_cell (GnucashSheet *sheet, &cursor_pos, &start_sel, &end_sel); if (new_text != NULL) + { gnucash_sheet_cell_set_from_table (sheet, virt_row, virt_col, cell_row, cell_col); + gnucash_sheet_redraw_block (sheet, virt_row, virt_col); + } else { gnucash_sheet_start_editing_at_cursor (sheet); @@ -712,7 +715,8 @@ gnucash_sheet_redraw_block (GnucashSheet *sheet, gint row, gint col) y += canvas->layout.yoffset - canvas->zoom_yofs; h = style->dimensions->height; - w = MIN(style->dimensions->width, GTK_WIDGET(sheet)->allocation.width); + w = MIN(style->dimensions->width, + GTK_WIDGET(sheet)->allocation.width); gnome_canvas_request_redraw (canvas, x, y, x+w, y+h); } diff --git a/src/register/recncell.c b/src/register/recncell.c index 096bdfef13..a8175b9ff3 100644 --- a/src/register/recncell.c +++ b/src/register/recncell.c @@ -59,13 +59,13 @@ ToggleRecn (BasicCell *_cell, const char *cur_val, BasicCell *cell = (BasicCell *) _cell; char buff[2]; - /* throw up a popup if the user tries to undo a reconciled transcation + /* throw up a popup if the user tries to undo a reconciled transaction hack alert -- this sets a new precedent ... gnc_verify_dialog is - defined in both the motif and the gtk subdirs; I don't think I like - it that way. Now it's in ui-callbacks.h which is UI independent, + defined in both the motif and the gnome subdirs; I don't think I like + it that way. Now it's in ui-callbacks.h which is UI independent, but that's still perhaps not optimal... */ - if(cur_val[0] == YREC) { + if (cur_val[0] == YREC) { if(!gnc_verify_dialog(CHANGE_RECN_MSG, GNC_T)) { return strdup(cur_val); } @@ -77,7 +77,7 @@ ToggleRecn (BasicCell *_cell, const char *cur_val, buff[0] = NREC; } buff[1] = 0x0; - + xaccSetBasicCellValue (cell, buff); return strdup (buff); }