mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Save last used account for posting of invoices in kvp slots of effective owners.
The slot is named "last_posted_to_acct". Before showing the post-to dialog, try to read that slot and pre-select the account appropriately. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16854 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
34e13c18d3
commit
8e9bbd8033
@ -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");
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user