diff --git a/src/business/business-gnome/dialog-date-close.c b/src/business/business-gnome/dialog-date-close.c index 6af987ccac..b62fab78e0 100644 --- a/src/business/business-gnome/dialog-date-close.c +++ b/src/business/business-gnome/dialog-date-close.c @@ -103,9 +103,7 @@ fill_in_acct_info (DialogDateClose *ddc) gnc_account_sel_set_acct_filters( gas, ddc->acct_types ); gnc_account_sel_set_new_account_ability( gas, TRUE ); gnc_account_sel_set_new_account_modal( gas, TRUE ); - - /* XXX: Some way to remember the last selection? */ - gnc_account_sel_set_account( gas, NULL ); + gnc_account_sel_set_account( gas, ddc->acct ); } static void @@ -248,6 +246,7 @@ gnc_dialog_dates_acct_question_parented (GtkWidget *parent, const char *message, ddc->ts2 = post; ddc->book = book; ddc->acct_types = acct_types; + ddc->acct = *acct; ddc->memo = memo; ddc->terms = terms; @@ -357,6 +356,7 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message, ddc->ts = date; ddc->book = book; ddc->acct_types = acct_types; + ddc->acct = *acct; xml = gnc_glade_xml_new ("date-close.glade", "Date Account Dialog"); ddc->dialog = glade_xml_get_widget (xml, "Date Account Dialog"); @@ -364,6 +364,8 @@ gnc_dialog_date_acct_parented (GtkWidget *parent, const char *message, acct_box = glade_xml_get_widget (xml, "acct_hbox"); ddc->acct_combo = gnc_account_sel_new(); + if (*acct) + gnc_account_sel_set_account (GNC_ACCOUNT_SEL(ddc->acct_combo), *acct); gtk_box_pack_start (GTK_BOX(acct_box), ddc->acct_combo, TRUE, TRUE, 0); date_box = glade_xml_get_widget (xml, "date_box"); diff --git a/src/business/business-gnome/dialog-date-close.h b/src/business/business-gnome/dialog-date-close.h index a9c830970b..267c7304ab 100644 --- a/src/business/business-gnome/dialog-date-close.h +++ b/src/business/business-gnome/dialog-date-close.h @@ -41,6 +41,8 @@ gnc_dialog_date_close_parented (GtkWidget *parent, const char *message, * Note that the dialog will "own" (and free) the acct_types list. * it should be a list of GNCAccountTypes. If memo is non-NULL, * it will g_malloc() a string. The caller should g_free() it. + * The value of *acct will be used as preselection of the account + * selection widget. */ gboolean diff --git a/src/business/business-gnome/dialog-invoice.c b/src/business/business-gnome/dialog-invoice.c index 39f722680d..2b7eab4f11 100644 --- a/src/business/business-gnome/dialog-invoice.c +++ b/src/business/business-gnome/dialog-invoice.c @@ -85,6 +85,8 @@ #define GCONF_SECTION_SEARCH "dialogs/business/invoice_search" +#define LAST_POSTED_TO_ACCT "last-posted-to-acct" + void gnc_invoice_window_ok_cb (GtkWidget *widget, gpointer data); void gnc_invoice_window_cancel_cb (GtkWidget *widget, gpointer data); void gnc_invoice_window_help_cb (GtkWidget *widget, gpointer data); @@ -602,6 +604,9 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data) GList * acct_types = NULL; Timespec ddue, postdate; gboolean accumulate; + QofInstance *owner_inst; + KvpFrame *kvpf; + KvpValue *kvp_val; /* Make sure the invoice is ok */ if (!gnc_invoice_window_verify_ok (iw)) @@ -650,6 +655,11 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data) ddue = postdate; memo = NULL; + owner_inst = qofOwnerGetOwner (gncOwnerGetEndOwner (&(iw->owner))); + kvpf = qof_instance_get_slots (owner_inst); + acc = xaccAccountLookup (kvp_frame_get_guid (kvpf, LAST_POSTED_TO_ACCT), + iw->book); + /* Get the default for the accumulate option */ accumulate = gnc_gconf_get_bool(GCONF_SECTION_INVOICE, "accumulate_splits", NULL); @@ -667,6 +677,13 @@ gnc_invoice_window_postCB (GtkWidget *widget, gpointer data) gncInvoiceBeginEdit (invoice); gnc_invoice_window_ok_save (iw); + /* Save acc as last used account in the kvp frame of the invoice owner */ + kvp_val = kvp_value_new_guid (qof_instance_get_guid (QOF_INSTANCE (acc)));; + qof_begin_edit (owner_inst); + kvp_frame_set_slot_nc (kvpf, LAST_POSTED_TO_ACCT, kvp_val); + qof_instance_set_dirty (owner_inst); + qof_commit_edit (owner_inst); + /* ... post it; post date is set to now ... */ gncInvoicePostToAccount (invoice, acc, &postdate, &ddue, memo, accumulate); gncInvoiceCommitEdit (invoice);