Skip to content

Commit

Permalink
Bug #635439: Patch to autoset owner in the payment dialog
Browse files Browse the repository at this point in the history
Patch by Matthijs Kooijman <matthijs@stdin.nl>

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19861 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
EvansMike committed Nov 22, 2010
1 parent bc3f366 commit 5c7784a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/business/business-gnome/business-gnome-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ GncInvoice * gnc_invoice_get_invoice (GtkWidget *widget)
void gnc_invoice_set_invoice (GtkWidget *widget, GncInvoice *invoice)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (invoice != NULL);

gnc_general_search_set_selected (GNC_GENERAL_SEARCH (widget), invoice);
}
Expand All @@ -310,7 +309,6 @@ void gnc_invoice_set_owner (GtkWidget *widget, GncOwner *owner)

gncOwnerCopy(owner, &isi->owner);
isi->have_owner = TRUE;
gnc_general_search_set_selected(GNC_GENERAL_SEARCH(widget), NULL);

/* Reset the label */
gnc_invoice_select_search_set_label(isi);
Expand Down
27 changes: 20 additions & 7 deletions src/business/business-gnome/dialog-payment.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,29 @@ gnc_payment_window_close_handler (gpointer data)
gtk_widget_destroy (pw->dialog);
}

/* Forward declaration */
static void gnc_payment_set_owner (PaymentWindow *pw, GncOwner *owner);

static void
gnc_payment_dialog_invoice_changed(PaymentWindow *pw)
{
GNCLot *lot;
gnc_numeric val;
GncOwner *owner;

/* Set the payment amount in the dialog */
if (pw->invoice)
{
lot = gncInvoiceGetPostedLot (pw->invoice);
val = gnc_numeric_abs (gnc_lot_get_balance (lot));
/* If a invoice is selected without selecting an owner first, or
* if the owner for the selected invoice is different from the
* previously selected owner, make sure the right owner is
* selected. */
owner = gncOwnerGetEndOwner (gncInvoiceGetOwner (pw->invoice));
if (pw->owner.owner.undefined == NULL || pw->owner.owner.undefined != owner->owner.undefined) {
gnc_payment_set_owner (pw, owner);
}
}
else
{
Expand All @@ -124,18 +136,19 @@ gnc_payment_dialog_owner_changed(PaymentWindow *pw)
KvpValue* value;
KvpFrame* slots;

/* If the owner changed, the invoice selection is invalid */
pw->invoice = NULL;
/* The selected invoice has a different owner than the newly
* selected owner, reset it */
if (pw->invoice != NULL && !gncOwnerEqual(gncOwnerGetEndOwner(gncInvoiceGetOwner(pw->invoice)), &pw->owner)) {
pw->invoice = NULL;
gnc_invoice_set_invoice(pw->invoice_choice, NULL);
}

/* Limit the invoice selection to this owner */
gnc_invoice_set_owner(pw->invoice_choice, &pw->owner);
/* note that set_owner implies ...set_invoice(...,NULL); */

/* in case we don't get the callback */
gnc_payment_dialog_invoice_changed(pw);

/* XXX: We should set the sensitive flag on the invoice_choice
* based on whether 'owner' is NULL or not...
*/

/* Now handle the account tree */
slots = gncOwnerGetSlots(&pw->owner);
if (slots)
Expand Down

0 comments on commit 5c7784a

Please sign in to comment.