[Gnucash-changes] r13411 - gnucash/trunk - Rework of Titi
Ala'ilima's patch to apply payments directly to invoices. (#121420)
Derek Atkins
warlord at cvs.gnucash.org
Mon Feb 27 00:42:47 EST 2006
Author: warlord
Date: 2006-02-27 00:42:45 -0500 (Mon, 27 Feb 2006)
New Revision: 13411
Trac: http://svn.gnucash.org/trac/changeset/13411
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/src/business/business-core/gncInvoice.c
gnucash/trunk/src/business/business-core/gncInvoice.h
gnucash/trunk/src/business/business-gnome/business-gnome-utils.c
gnucash/trunk/src/business/business-gnome/business-gnome-utils.h
gnucash/trunk/src/business/business-gnome/business-options-gnome.c
gnucash/trunk/src/business/business-gnome/dialog-invoice.c
gnucash/trunk/src/business/business-gnome/dialog-payment.c
gnucash/trunk/src/business/business-gnome/dialog-payment.h
gnucash/trunk/src/business/business-gnome/glade/payment.glade
Log:
Rework of Titi Ala'ilima's patch to apply payments directly to invoices. (#121420)
Apply a re-work of Titi Ala'ilima's patch to apply payments
directly to invoices. This fixes bug #121420.
* src/business/business-core/gncInvoice.[ch]:
Add argument to the ProcessPayment API to allow the caller
to specify an invoice to post to first.
* src/business/business-gnome/business-gnome-utils.[ch]:
Create an invoice-select API that lets you select an invoice
based on an owner (or not). I.e., you can limit the invoice
search based on a selected owner. If you change the owner
it invalidates the invoice search.
* src/business/business-gnome/dialog-payment.[ch]:
Change the API from ..new_with_value() to ..new_with_invoice().
Pull the default amount from the invoice (if one exists).
Allow the user to select an invoice and apply payments there.
If the user changes the owner, invalidate the invoice.
* src/business/business-gnome/business-options-gnome.c:
use the new invoice-select API instead of calling general_search
API directly.
* src/business/business-gnome/dialog-invoice.c:
call the new dialog-payment API. No need to compute the initial
value here; the payment dialog will compute it from the invoice
(instead of computing it from the invoice here).
* src/business/business-gnome/glade/payment.glade:
Add invoice-selector label and box.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-02-26 22:19:18 UTC (rev 13410)
+++ gnucash/trunk/ChangeLog 2006-02-27 05:42:45 UTC (rev 13411)
@@ -1,3 +1,30 @@
+2006-02-26 Derek Atkins <derek at ihtfp.com>
+
+ Apply a re-work of Titi Ala'ilima's patch to apply payments
+ directly to invoices. This fixes bug #121420.
+ * src/business/business-core/gncInvoice.[ch]:
+ Add argument to the ProcessPayment API to allow the caller
+ to specify an invoice to post to first.
+ * src/business/business-gnome/business-gnome-utils.[ch]:
+ Create an invoice-select API that lets you select an invoice
+ based on an owner (or not). I.e., you can limit the invoice
+ search based on a selected owner. If you change the owner
+ it invalidates the invoice search.
+ * src/business/business-gnome/dialog-payment.[ch]:
+ Change the API from ..new_with_value() to ..new_with_invoice().
+ Pull the default amount from the invoice (if one exists).
+ Allow the user to select an invoice and apply payments there.
+ If the user changes the owner, invalidate the invoice.
+ * src/business/business-gnome/business-options-gnome.c:
+ use the new invoice-select API instead of calling general_search
+ API directly.
+ * src/business/business-gnome/dialog-invoice.c:
+ call the new dialog-payment API. No need to compute the initial
+ value here; the payment dialog will compute it from the invoice
+ (instead of computing it from the invoice here).
+ * src/business/business-gnome/glade/payment.glade:
+ Add invoice-selector label and box.
+
2006-02-26 David Hampton <hampton at employees.org>
* packaging: Create a consolidated directory for distribution
Modified: gnucash/trunk/src/business/business-core/gncInvoice.c
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoice.c 2006-02-26 22:19:18 UTC (rev 13410)
+++ gnucash/trunk/src/business/business-core/gncInvoice.c 2006-02-27 05:42:45 UTC (rev 13411)
@@ -21,7 +21,7 @@
\********************************************************************/
/*
- * Copyright (C) 2001,2002 Derek Atkins
+ * Copyright (C) 2001,2002,2006 Derek Atkins
* Copyright (C) 2003 Linas Vepstas <linas at linas.org>
* Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
* Author: Derek Atkins <warlord at MIT.EDU>
@@ -1236,20 +1236,22 @@
* in gncInvoice...
*/
Transaction *
-gncOwnerApplyPayment (GncOwner *owner, Account *posted_acc, Account *xfer_acc,
+gncOwnerApplyPayment (GncOwner *owner, GncInvoice* invoice,
+ Account *posted_acc, Account *xfer_acc,
gnc_numeric amount, Timespec date,
const char *memo, const char *num)
{
QofBook *book;
+ Account *inv_posted_acc;
Transaction *txn;
Split *split;
GList *lot_list, *fifo = NULL;
- GNCLot *lot, *prepay_lot = NULL;
- GncInvoice *invoice;
+ GNCLot *lot, *inv_posted_lot = NULL, *prepay_lot = NULL;
+ GncInvoice *this_invoice;
const char *name;
gnc_commodity *commodity;
gnc_numeric split_amt;
- gboolean reverse;
+ gboolean reverse, inv_passed = TRUE;
/* Verify our arguments */
if (!owner || !posted_acc || !xfer_acc) return NULL;
@@ -1292,6 +1294,23 @@
owner,
(GCompareFunc)gnc_lot_sort_func);
+ /* Check if an invoice was passed in, and if so, does it match the
+ * account, and is it an open lot? If so, put it at the beginning
+ * of the lot list fifo so we post to this invoice's lot first.
+ */
+ if (invoice) {
+ inv_posted_acc = gncInvoiceGetPostedAcc(invoice);
+ inv_posted_lot = gncInvoiceGetPostedLot(invoice);
+ if (inv_posted_acc && inv_posted_lot &&
+ guid_equal(xaccAccountGetGUID(inv_posted_acc),
+ xaccAccountGetGUID(posted_acc)) &&
+ !gnc_lot_is_closed(inv_posted_lot)) {
+ /* Put this invoice at the beginning of the FIFO */
+ fifo = g_list_prepend (fifo, inv_posted_lot);
+ inv_passed = FALSE;
+ }
+ }
+
xaccAccountBeginEdit (posted_acc);
/* Now iterate over the fifo until the payment is fully applied
@@ -1301,6 +1320,21 @@
gnc_numeric balance;
lot = lot_list->data;
+
+ /* Skip this lot if it matches the invoice that was passed in and
+ * we've seen it already. This way we post to it the first time
+ * (from the beginning of the lot-list) but not when we reach it
+ * the second time.
+ */
+ if (inv_posted_lot &&
+ guid_equal(qof_instance_get_guid(QOF_INSTANCE(lot)),
+ qof_instance_get_guid(QOF_INSTANCE(inv_posted_lot)))) {
+ if (inv_passed)
+ continue;
+ else
+ inv_passed = TRUE;
+ }
+
balance = gnc_lot_get_balance (lot);
if (!reverse)
@@ -1345,9 +1379,9 @@
gnc_lot_add_split (lot, split);
/* Now send an event for the invoice so it gets updated as paid */
- invoice = gncInvoiceGetInvoiceFromLot(lot);
- if (invoice)
- gnc_engine_gen_event (&invoice->inst.entity, GNC_EVENT_MODIFY);
+ this_invoice = gncInvoiceGetInvoiceFromLot(lot);
+ if (this_invoice)
+ gnc_engine_gen_event (&this_invoice->inst.entity, GNC_EVENT_MODIFY);
if (gnc_numeric_zero_p (amount))
break;
Modified: gnucash/trunk/src/business/business-core/gncInvoice.h
===================================================================
--- gnucash/trunk/src/business/business-core/gncInvoice.h 2006-02-26 22:19:18 UTC (rev 13410)
+++ gnucash/trunk/src/business/business-core/gncInvoice.h 2006-02-27 05:42:45 UTC (rev 13411)
@@ -29,7 +29,7 @@
@{ */
/** @file gncInvoice.h
@brief Business Invoice Interface
- @author Copyright (C) 2001 Derek Atkins <warlord at MIT.EDU>
+ @author Copyright (C) 2001,2006 Derek Atkins <warlord at MIT.EDU>
@author Copyright (c) 2005 Neil Williams <linux at codehelp.co.uk>
*/
@@ -135,13 +135,16 @@
/**
* Apply a payment of "amount" for the owner, between the xfer_account
- * (bank or other asset) and the posted_account (A/R or A/P).
+ * (bank or other asset) and the posted_account (A/R or A/P). If the
+ * caller supplies an (optional) invoice argument, then apply the
+ * payment to that invoice first before any other invoice.
*
* XXX: yes, this should be in gncOwner, but all the other logic is
* in gncInvoice...
*/
Transaction *
-gncOwnerApplyPayment (GncOwner *owner, Account *posted_acc, Account *xfer_acc,
+gncOwnerApplyPayment (GncOwner *owner, GncInvoice *invoice,
+ Account *posted_acc, Account *xfer_acc,
gnc_numeric amount, Timespec date,
const char *memo, const char *num);
Modified: gnucash/trunk/src/business/business-gnome/business-gnome-utils.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/business-gnome-utils.c 2006-02-26 22:19:18 UTC (rev 13410)
+++ gnucash/trunk/src/business/business-gnome/business-gnome-utils.c 2006-02-27 05:42:45 UTC (rev 13411)
@@ -2,7 +2,7 @@
* business-gnome-utils.c -- General GUI Utilities for GNC Business Objects
*
* Written By: Derek Atkins <warlord at MIT.EDU>
- * Copyright (C) 2001, 2002 Derek Atkins
+ * Copyright (C) 2001,2002,2006 Derek Atkins
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -37,6 +37,7 @@
#include "gncJob.h"
#include "gncVendor.h"
#include "gncOwner.h"
+#include "gncInvoice.h"
#include "gnc-general-search.h"
#include "gncObject.h"
@@ -45,6 +46,7 @@
#include "dialog-job.h"
#include "dialog-vendor.h"
#include "dialog-employee.h"
+#include "dialog-invoice.h"
typedef enum {
GNCSEARCH_TYPE_SELECT,
@@ -168,7 +170,136 @@
owner->owner.undefined);
}
+typedef struct _invoice_select_info {
+ GtkWidget *label;
+ GNCBook *book;
+ GncOwner owner;
+ gboolean have_owner;
+} GncISI;
+static GNCSearchWindow *
+gnc_invoice_select_search_cb (gpointer start, gpointer isip)
+{
+ GncISI *isi = isip;
+
+ if (!isi) return NULL;
+ g_assert(isi->book);
+
+ return gnc_invoice_search (start,
+ isi->have_owner ? &isi->owner : NULL,
+ isi->book);
+}
+
+static void
+gnc_invoice_select_search_set_label(GncISI* isi)
+{
+ GncOwnerType owner_type;
+ GncOwner *tmp;
+ char *label;
+
+ g_assert(isi);
+ if (!isi->label) return;
+
+ tmp = &isi->owner;
+ owner_type = gncOwnerGetType(tmp);
+ while (owner_type == GNC_OWNER_JOB) {
+ tmp = gncOwnerGetEndOwner(tmp);
+ owner_type = gncOwnerGetType(tmp);
+ }
+
+ /* Translators: See comments in dialog-invoice.c:gnc_invoice_search() */
+ switch (owner_type) {
+ case GNC_OWNER_VENDOR:
+ label = _("Bill");
+ break;
+ case GNC_OWNER_EMPLOYEE:
+ label = _("Voucher");
+ break;
+ default:
+ label = _("Invoice");
+ }
+
+ gtk_label_set_text(GTK_LABEL(isi->label), label);
+}
+
+GtkWidget * gnc_invoice_select_create (GtkWidget *hbox, GNCBook *book,
+ const GncOwner *owner,
+ GncInvoice *invoice,
+ GtkWidget *label)
+{
+ GtkWidget *edit;
+ GncISI *isi;
+
+ g_return_val_if_fail (hbox != NULL, NULL);
+ g_return_val_if_fail (book != NULL, NULL);
+ /* Note: it is legal to have no owner or invoice */
+
+ isi = g_new0(GncISI, 1);
+ if (!isi)
+ return NULL;
+
+ if (owner) {
+ gncOwnerCopy(owner, &isi->owner);
+ isi->have_owner = TRUE;
+ } else {
+ gncOwnerInitCustomer(&isi->owner, NULL);
+ }
+ isi->book = book;
+ isi->label = label;
+
+ edit = gnc_general_search_new (GNC_INVOICE_MODULE_NAME, _("Select..."),
+ gnc_invoice_select_search_cb, isi);
+ if (!edit) {
+ g_free(isi);
+ return NULL;
+ }
+
+ gnc_general_search_set_selected (GNC_GENERAL_SEARCH (edit), invoice);
+ gtk_box_pack_start (GTK_BOX (hbox), edit, FALSE, FALSE, 0);
+ g_object_set_data_full(G_OBJECT(edit), "isi-state", isi, g_free);
+
+ /* Set the label */
+ gnc_invoice_select_search_set_label(isi);
+
+ return edit;
+}
+
+GncInvoice * gnc_invoice_get_invoice (GtkWidget *widget)
+{
+ g_return_val_if_fail (widget != NULL, NULL);
+
+ return gnc_general_search_get_selected (GNC_GENERAL_SEARCH (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);
+}
+
+void gnc_invoice_set_owner (GtkWidget *widget, GncOwner *owner)
+{
+ GncISI *isi;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (owner != NULL);
+
+ isi = g_object_get_data(G_OBJECT(widget), "isi-state");
+ g_assert(isi);
+
+ if (isi->owner.owner.undefined == owner->owner.undefined)
+ return;
+
+ 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);
+}
+
void
gnc_fill_account_select_combo (GtkWidget *combo, GNCBook *book,
GList *acct_types)
Modified: gnucash/trunk/src/business/business-gnome/business-gnome-utils.h
===================================================================
--- gnucash/trunk/src/business/business-gnome/business-gnome-utils.h 2006-02-26 22:19:18 UTC (rev 13410)
+++ gnucash/trunk/src/business/business-gnome/business-gnome-utils.h 2006-02-27 05:42:45 UTC (rev 13411)
@@ -2,7 +2,7 @@
* business-gnome-utils.h -- General GUI Utilities for GNC Business Objects
*
* Written By: Derek Atkins <warlord at MIT.EDU>
- * Copyright (C) 2001 Derek Atkins
+ * Copyright (C) 2001,2006 Derek Atkins
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -29,6 +29,7 @@
#include "gncOwner.h"
#include "gncBillTerm.h"
#include "gncTaxTable.h"
+#include "gncInvoice.h"
#define GCONF_SECTION_ORDER "dialogs/business/order"
#define GCONF_SECTION_JOB "dialogs/business/job"
@@ -46,6 +47,18 @@
void gnc_owner_set_owner (GtkWidget *widget, GncOwner *owner);
+/* An invoice select widget..
+ * the owner, invoice, and label parameters are optional
+ */
+GtkWidget * gnc_invoice_select_create (GtkWidget *hbox, GNCBook *book,
+ const GncOwner *owner,
+ GncInvoice *invoice,
+ GtkWidget *label);
+
+GncInvoice * gnc_invoice_get_invoice (GtkWidget *widget);
+void gnc_invoice_set_invoice (GtkWidget *widget, GncInvoice *invoice);
+void gnc_invoice_set_owner (GtkWidget *widget, GncOwner *owner);
+
/* Return a list of account-types based on the owner type */
GList * gnc_business_account_types (GncOwner *owner);
Modified: gnucash/trunk/src/business/business-gnome/business-options-gnome.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/business-options-gnome.c 2006-02-26 22:19:18 UTC (rev 13410)
+++ gnucash/trunk/src/business/business-gnome/business-options-gnome.c 2006-02-27 05:42:45 UTC (rev 13411)
@@ -2,7 +2,7 @@
* business-options.c -- Initialize Business Options
*
* Written By: Derek Atkins <warlord at MIT.EDU>
- * Copyright (C) 2002 Derek Atkins
+ * Copyright (C) 2002,2006 Derek Atkins
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -355,12 +355,10 @@
{
GtkWidget *widget;
- widget = gnc_general_search_new (GNC_INVOICE_MODULE_NAME,
- _("Select..."),
- gnc_invoice_search_select,
- gnc_get_current_book ());
+ /* No owner or starting invoice here, but that's okay. */
+ widget = gnc_invoice_select_create (hbox, gnc_get_current_book(),
+ NULL, NULL, NULL);
- gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
gnc_option_set_widget (option, widget);
g_signal_connect (G_OBJECT (widget), "changed",
G_CALLBACK (gnc_option_changed_option_cb), option);
Modified: gnucash/trunk/src/business/business-gnome/dialog-invoice.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2006-02-26 22:19:18 UTC (rev 13410)
+++ gnucash/trunk/src/business/business-gnome/dialog-invoice.c 2006-02-27 05:42:45 UTC (rev 13411)
@@ -1,6 +1,6 @@
/*
* dialog-invoice.c -- Dialog for Invoice entry
- * Copyright (C) 2001,2002 Derek Atkins
+ * Copyright (C) 2001,2002,2006 Derek Atkins
* Author: Derek Atkins <warlord at MIT.EDU>
*
* Copyright (c) 2005,2006 David Hampton <hampton at employees.org>
@@ -783,13 +783,11 @@
{
InvoiceWindow *iw = data;
GncInvoice *invoice = iw_get_invoice(iw);
- GNCLot *lot = gncInvoiceGetPostedLot (invoice);
- gnc_numeric val = gnc_numeric_abs (gnc_lot_get_balance (lot));
if (gncOwnerGetJob (&iw->job))
- gnc_ui_payment_new_with_value (&iw->job, iw->book, val);
+ gnc_ui_payment_new_with_invoice (&iw->job, iw->book, invoice);
else
- gnc_ui_payment_new_with_value (&iw->owner, iw->book, val);
+ gnc_ui_payment_new_with_invoice (&iw->owner, iw->book, invoice);
}
/* Sorting callbacks */
@@ -2150,15 +2148,10 @@
pay_invoice_direct (gpointer inv, gpointer user_data)
{
GncInvoice *invoice = inv;
- GNCLot *lot;
- gnc_numeric val;
g_return_if_fail (invoice);
-
- lot = gncInvoiceGetPostedLot (invoice);
- val = gnc_numeric_abs (gnc_lot_get_balance (lot));
- gnc_ui_payment_new_with_value (gncInvoiceGetOwner (invoice),
- gncInvoiceGetBook (invoice), val);
+ gnc_ui_payment_new_with_invoice (gncInvoiceGetOwner (invoice),
+ gncInvoiceGetBook (invoice), invoice);
}
static void
Modified: gnucash/trunk/src/business/business-gnome/dialog-payment.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-payment.c 2006-02-26 22:19:18 UTC (rev 13410)
+++ gnucash/trunk/src/business/business-gnome/dialog-payment.c 2006-02-27 05:42:45 UTC (rev 13411)
@@ -1,6 +1,6 @@
/*
* dialog-payment.c -- Dialog for payment entry
- * Copyright (C) 2002 Derek Atkins
+ * Copyright (C) 2002,2006 Derek Atkins
* Author: Derek Atkins <warlord at MIT.EDU>
*
* This program is free software; you can redistribute it and/or
@@ -53,6 +53,7 @@
GtkWidget * memo_entry;
GtkWidget * post_combo;
GtkWidget * owner_choice;
+ GtkWidget * invoice_choice;
GtkWidget * amount_edit;
GtkWidget * date_edit;
GtkWidget * acct_tree;
@@ -60,6 +61,7 @@
gint component_id;
GNCBook * book;
GncOwner owner;
+ GncInvoice * invoice;
GList * acct_types;
};
@@ -87,13 +89,44 @@
}
static void
+gnc_payment_dialog_invoice_changed(PaymentWindow *pw)
+{
+ GNCLot *lot;
+ gnc_numeric val;
+
+ /* Set the payment amount in the dialog */
+ if (pw->invoice) {
+ lot = gncInvoiceGetPostedLot (pw->invoice);
+ val = gnc_numeric_abs (gnc_lot_get_balance (lot));
+ } else {
+ val = gnc_numeric_zero();
+ }
+
+ gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT(pw->amount_edit), val);
+}
+
+static void
gnc_payment_dialog_owner_changed(PaymentWindow *pw)
{
Account *last_acct;
GUID *guid;
KvpValue* value;
- KvpFrame* slots = gncOwnerGetSlots(&pw->owner);
+ KvpFrame* slots;
+ /* If the owner changed, the invoice selection is invalid */
+ pw->invoice = NULL;
+ 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) return;
value = kvp_frame_get_slot_path(slots, "payment", "last_acct", NULL);
@@ -157,6 +190,25 @@
return FALSE;
}
+static int
+gnc_payment_dialog_invoice_changed_cb (GtkWidget *widget, gpointer data)
+{
+ PaymentWindow *pw = data;
+ GncInvoice *invoice;
+
+ if (!pw) return FALSE;
+
+ invoice = gnc_invoice_get_invoice (pw->invoice_choice);
+
+ /* If this invoice really changed, then reset ourselves */
+ if (invoice != pw->invoice) {
+ pw->invoice = invoice;
+ gnc_payment_dialog_invoice_changed(pw);
+ }
+
+ return FALSE;
+}
+
void
gnc_payment_ok_cb (GtkWidget *widget, gpointer data)
{
@@ -225,7 +277,8 @@
date = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (pw->date_edit));
/* Now apply the payment */
- gncOwnerApplyPayment (&pw->owner, post, acc, amount, date, memo, num);
+ gncOwnerApplyPayment (&pw->owner, pw->invoice,
+ post, acc, amount, date, memo, num);
}
gnc_resume_gui_refresh ();
@@ -290,7 +343,7 @@
}
static PaymentWindow *
-new_payment_window (GncOwner *owner, GNCBook *book, gnc_numeric initial_payment)
+new_payment_window (GncOwner *owner, GNCBook *book, GncInvoice *invoice)
{
PaymentWindow *pw;
GladeXML *xml;
@@ -336,12 +389,16 @@
box = glade_xml_get_widget (xml, "owner_box");
pw->owner_choice = gnc_owner_select_create (label, box, book, owner);
+ label = glade_xml_get_widget (xml, "invoice_label");
+ box = glade_xml_get_widget (xml, "invoice_box");
+ pw->invoice_choice = gnc_invoice_select_create (box, book, owner, invoice, label);
+
box = glade_xml_get_widget (xml, "amount_box");
pw->amount_edit = gnc_amount_edit_new ();
gtk_box_pack_start (GTK_BOX (box), pw->amount_edit, TRUE, TRUE, 0);
gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (pw->amount_edit),
TRUE);
- gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (pw->amount_edit), initial_payment);
+ gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (pw->amount_edit), gnc_numeric_zero());
box = glade_xml_get_widget (xml, "date_box");
pw->date_edit = gnc_date_edit_new (time(NULL), FALSE, FALSE);
@@ -356,6 +413,10 @@
/* Set the dialog for the 'new' owner */
gnc_payment_dialog_owner_changed(pw);
+ /* Set the dialog for the 'new' invoice */
+ pw->invoice = invoice;
+ gnc_payment_dialog_invoice_changed(pw);
+
/* Setup signals */
glade_xml_signal_autoconnect_full( xml,
gnc_glade_autoconnect_full_func,
@@ -364,6 +425,9 @@
g_signal_connect (G_OBJECT (pw->owner_choice), "changed",
G_CALLBACK (gnc_payment_dialog_owner_changed_cb), pw);
+ g_signal_connect (G_OBJECT (pw->invoice_choice), "changed",
+ G_CALLBACK (gnc_payment_dialog_invoice_changed_cb), pw);
+
/* Register with the component manager */
pw->component_id =
gnc_register_gui_component (cm_class,
@@ -415,8 +479,8 @@
}
PaymentWindow *
-gnc_ui_payment_new_with_value (GncOwner *owner, GNCBook *book,
- gnc_numeric initial_payment)
+gnc_ui_payment_new_with_invoice (GncOwner *owner, GNCBook *book,
+ GncInvoice *invoice)
{
GncOwner owner_def;
@@ -429,12 +493,12 @@
owner = &owner_def;
}
- return new_payment_window (owner, book, initial_payment);
+ return new_payment_window (owner, book, invoice);
}
PaymentWindow *
gnc_ui_payment_new (GncOwner *owner, GNCBook *book)
{
- return gnc_ui_payment_new_with_value (owner, book, gnc_numeric_zero());
+ return gnc_ui_payment_new_with_invoice (owner, book, NULL);
}
Modified: gnucash/trunk/src/business/business-gnome/dialog-payment.h
===================================================================
--- gnucash/trunk/src/business/business-gnome/dialog-payment.h 2006-02-26 22:19:18 UTC (rev 13410)
+++ gnucash/trunk/src/business/business-gnome/dialog-payment.h 2006-02-27 05:42:45 UTC (rev 13411)
@@ -1,6 +1,6 @@
/*
* dialog-payment.h -- Dialog to enter payments
- * Copyright (C) 2002 Derek Atkins
+ * Copyright (C) 2002,2006 Derek Atkins
* Author: Derek Atkins <warlord at MIT.EDU>
*
* This program is free software; you can redistribute it and/or
@@ -28,11 +28,13 @@
#include "gnc-book.h"
#include "gncOwner.h"
+#include "gncInvoice.h"
/* Create a payment window */
PaymentWindow * gnc_ui_payment_new (GncOwner *owner, GNCBook *book);
-PaymentWindow * gnc_ui_payment_new_with_value (GncOwner *owner, GNCBook *book,
- gnc_numeric initial_payment);
+PaymentWindow * gnc_ui_payment_new_with_invoice (GncOwner *owner,
+ GNCBook *book,
+ GncInvoice *invoice);
/* Destroy a payment window */
void gnc_ui_payment_window_destroy (PaymentWindow *pw);
Modified: gnucash/trunk/src/business/business-gnome/glade/payment.glade
===================================================================
--- gnucash/trunk/src/business/business-gnome/glade/payment.glade 2006-02-26 22:19:18 UTC (rev 13410)
+++ gnucash/trunk/src/business/business-gnome/glade/payment.glade 2006-02-27 05:42:45 UTC (rev 13411)
@@ -114,6 +114,27 @@
</child>
<child>
+ <widget class="GtkLabel" id="invoice_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">(invoice)</property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">Date</property>
@@ -229,6 +250,23 @@
</child>
<child>
+ <widget class="GtkHBox" id="invoice_box">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <placeholder/>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkHBox" id="date_box">
<property name="visible">True</property>
<property name="homogeneous">False</property>
More information about the gnucash-changes
mailing list