gncInvoice: add function to return the Type string, based on the Owner..

returns "Invoice" or "Bill"
            add this type to the list of accessible parameters
gncOwner:   add GetCommodity() interface

Refactor some common code out of dialog-date-close and dialog-invoice
into business-utils so that the payment dialog can use it too.

Add Payment Dialog, glade file, C and header, and link it into scheme


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6868 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2002-05-16 22:45:50 +00:00
parent 3ef4566deb
commit ec60f221fa
14 changed files with 928 additions and 50 deletions

View File

@ -314,6 +314,29 @@ const char * gncInvoiceGetNotes (GncInvoice *invoice)
return invoice->notes;
}
static GncOwnerType gncInvoiceGetOwnerType (GncInvoice *invoice)
{
GncOwner *owner;
g_return_val_if_fail (invoice, GNC_OWNER_NONE);
owner = gncOwnerGetEndOwner (gncInvoiceGetOwner (invoice));
return (gncOwnerGetType (owner));
}
const char * gncInvoiceGetType (GncInvoice *invoice)
{
if (!invoice) return NULL;
switch (gncInvoiceGetOwnerType (invoice)) {
case GNC_OWNER_CUSTOMER:
return _("Invoice");
case GNC_OWNER_VENDOR:
return _("Bill");
default:
return NULL;
}
}
gnc_commodity * gncInvoiceGetCommonCommodity (GncInvoice *invoice)
{
if (!invoice) return NULL;
@ -390,12 +413,13 @@ gncInvoiceAttachInvoiceToTxn (GncInvoice *invoice, Transaction *txn)
Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
Timespec *post_date, Timespec *due_date,
const char * memo, gboolean reverse)
const char * memo)
{
Transaction *txn;
GList *iter;
GList *splitinfo = NULL;
gnc_numeric total;
gboolean reverse;
const char *name;
struct acct_val {
Account * acc;
@ -404,6 +428,8 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
if (!invoice || !acc) return NULL;
reverse = (gncInvoiceGetOwnerType (invoice) == GNC_OWNER_CUSTOMER);
txn = xaccMallocTransaction (invoice->book);
xaccTransBeginEdit (txn);
@ -489,7 +515,7 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
/* Set action/memo */
xaccSplitSetMemo (split, memo);
xaccSplitSetAction (split, reverse ? _("Invoice") : _("Bill"));
xaccSplitSetAction (split, gncInvoiceGetType (invoice));
xaccSplitSetBaseValue (split, (reverse ? total : gnc_numeric_neg (total)),
invoice->common_commodity);
@ -661,6 +687,7 @@ gboolean gncInvoiceRegister (void)
{ INVOICE_NOTES, QUERYCORE_STRING, (QueryAccess)gncInvoiceGetNotes },
{ INVOICE_ACC, GNC_ID_ACCOUNT, (QueryAccess)gncInvoiceGetPostedAcc },
{ INVOICE_POST_TXN, GNC_ID_TRANS, (QueryAccess)gncInvoiceGetPostedTxn },
{ INVOICE_TYPE, QUERYCORE_STRING, (QueryAccess)gncInvoiceGetType },
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncInvoiceGetBook },
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncInvoiceGetGUID },
{ NULL },

View File

@ -47,6 +47,7 @@ Timespec gncInvoiceGetDateDue (GncInvoice *invoice);
const char * gncInvoiceGetTerms (GncInvoice *invoice);
const char * gncInvoiceGetBillingID (GncInvoice *invoice);
const char * gncInvoiceGetNotes (GncInvoice *invoice);
const char * gncInvoiceGetType (GncInvoice *invoice);
gnc_commodity * gncInvoiceGetCommonCommodity (GncInvoice *invoice);
gboolean gncInvoiceGetActive (GncInvoice *invoice);
@ -57,14 +58,13 @@ GList * gncInvoiceGetEntries (GncInvoice *invoice);
/* Post this invoice to an account. Returns the new Transaction
* that is tied to this invoice. The transaction is set with
* the posted date. Set reverse to TRUE to reverse the sense of
* the splits (necessary for posting to A/R accounts from Income
* splits).
* the supplied posted date, due date, and memo. The Transaction
* description is set to the name of the company.
*/
Transaction *
gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
Timespec *posted_date, Timespec *due_date,
const char *description, gboolean reverse);
const char *memo);
/* Given a transaction, find and return the Invoice */
@ -89,5 +89,6 @@ gboolean gncInvoiceIsPaid (GncInvoice *invoice);
#define INVOICE_NOTES "notes"
#define INVOICE_ACC "account"
#define INVOICE_POST_TXN "posted_txn"
#define INVOICE_TYPE "type"
#endif /* GNC_INVOICE_H_ */

View File

@ -91,6 +91,22 @@ GncVendor * gncOwnerGetVendor (const GncOwner *owner)
return owner->owner.vendor;
}
gnc_commodity * gncOwnerGetCommodity (GncOwner *owner)
{
if (!owner) return NULL;
switch (owner->type) {
case GNC_OWNER_NONE:
case GNC_OWNER_UNDEFINED:
return NULL;
case GNC_OWNER_CUSTOMER:
return gncCustomerGetCommodity (owner->owner.customer);
case GNC_OWNER_VENDOR:
return gncVendorGetCommodity (owner->owner.vendor);
case GNC_OWNER_JOB:
return gncOwnerGetCommodity (gncJobGetOwner (owner->owner.job));
}
}
void gncOwnerCopy (const GncOwner *src, GncOwner *dest)
{
if (!src || !dest) return;

View File

@ -49,6 +49,7 @@ gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b);
int gncOwnerCompare (const GncOwner *a, const GncOwner *b);
const char * gncOwnerGetName (GncOwner *owner);
gnc_commodity * gncOwnerGetCommodity (GncOwner *owner);
/* Get the GUID of the immediate owner */
const GUID * gncOwnerGetGUID (GncOwner *owner);

View File

@ -32,6 +32,7 @@ libgncmod_business_gnome_la_SOURCES = \
dialog-invoice.c \
dialog-job.c \
dialog-order.c \
dialog-payment.c \
dialog-vendor.c \
gnc-business-utils.c
@ -43,6 +44,7 @@ noinst_HEADERS = \
dialog-invoice.h \
dialog-job.h \
dialog-order.h \
dialog-payment.h \
dialog-vendor.h \
gnc-business-utils.h
@ -72,6 +74,7 @@ glade_DATA = \
invoice.glade \
job.glade \
order.glade \
payment.glade \
vendor.glade
gwmoddir = ${GNC_GWRAP_LIBDIR}

View File

@ -62,10 +62,19 @@
(gnc:job-search #f last-cust
(gnc:get-current-book)))))
(define payment-item
(gnc:make-menu-item (N_ "Process Payment")
(N_ "Process Payment")
(list "Extensions" "Customers" "")
(lambda ()
(gnc:payment-new last-cust
(gnc:get-current-book)))))
(gnc:owner-init-customer last-cust #f)
(gnc:add-extension customer-menu)
(gnc:add-extension payment-item)
(gnc:add-extension find-job-item)
(gnc:add-extension new-job-item)
(gnc:add-extension find-invoice-item)
@ -131,9 +140,18 @@
(gnc:get-current-book)))))
(define payment-item
(gnc:make-menu-item (N_ "Process Payment")
(N_ "Process Payment")
(list "Extensions" "Vendors" "")
(lambda ()
(gnc:payment-new last-vendor
(gnc:get-current-book)))))
(gnc:owner-init-vendor last-vendor #f)
(gnc:add-extension vendor-menu)
(gnc:add-extension payment-item)
(gnc:add-extension find-job-item)
(gnc:add-extension new-job-item)
(gnc:add-extension find-invoice-item)

View File

@ -9,6 +9,11 @@
#include <gnome.h>
#include "Group.h"
#include "Account.h"
#include "gnc-ui-util.h"
#include "gnc-engine-util.h"
#include "gncCustomer.h"
#include "gncJob.h"
#include "gncVendor.h"
@ -134,3 +139,78 @@ void gnc_owner_set_owner (GtkWidget *widget, GncOwner *owner)
gnc_general_search_set_selected (GNC_GENERAL_SEARCH (widget),
owner->owner.undefined);
}
void
gnc_fill_account_select_combo (GtkWidget *combo, GNCBook *book,
GList *acct_types)
{
GList *list, *node, *names = NULL;
char *text;
gboolean found = FALSE;
g_return_if_fail (combo);
g_return_if_fail (book);
g_return_if_fail (acct_types);
/* Figure out if anything is set in the combo */
text = gtk_entry_get_text (GTK_ENTRY ((GTK_COMBO (combo))->entry));
if (text && strcmp (text, ""))
text = g_strdup (text);
else
text = NULL;
list = xaccGroupGetSubAccounts (gnc_book_get_group (book));
/* Create a list of names. Figure out if we've got the 'saved' one */
for (node = list; node; node = node->next) {
Account *account = node->data;
char *name;
/* Only present accounts of the appropriate type */
if (g_list_index (acct_types, (gpointer)xaccAccountGetType (account))
== -1)
continue;
name = xaccAccountGetFullName (account, gnc_get_account_separator ());
if (name != NULL) {
names = g_list_append (names, name);
if (!safe_strcmp (name, text))
found = TRUE;
}
}
g_list_free (list);
/* set the popdown strings and the default to last selected choice
* (or the first entry if none was previously selected */
if (names) {
gtk_combo_set_popdown_strings (GTK_COMBO (combo), names);
gtk_entry_set_text (GTK_ENTRY ((GTK_COMBO (combo))->entry),
found ? text : names->data);
}
for (node = names; node; node = node->next)
g_free (node->data);
g_list_free (names);
if (text)
g_free (text);
}
GList *
gnc_business_account_types (GncOwner *owner)
{
g_return_val_if_fail (owner, NULL);
switch (gncOwnerGetType (owner)) {
case GNC_OWNER_CUSTOMER:
return (g_list_prepend (NULL, (gpointer)RECEIVABLE));
case GNC_OWNER_VENDOR:
return (g_list_prepend (NULL, (gpointer)PAYABLE));
break;
default:
return (g_list_prepend (NULL, (gpointer)NO_TYPE));
}
}

View File

@ -20,4 +20,12 @@ GtkWidget * gnc_owner_edit_create (GtkWidget *label, GtkWidget *hbox,
void gnc_owner_get_owner (GtkWidget *widget, GncOwner *owner);
void gnc_owner_set_owner (GtkWidget *widget, GncOwner *owner);
/* Return a list of account-types based on the owner type */
GList * gnc_business_account_types (GncOwner *owner);
/* Fill in a combo box with the appropriate list of accounts */
void gnc_fill_account_select_combo (GtkWidget *combo, GNCBook *book,
GList *acct_types);
#endif /* GNC_BUSINESS_UTILS_H_ */

View File

@ -8,7 +8,6 @@
#include <gnome.h>
#include "Group.h"
#include "dialog-utils.h"
#include "gnc-engine-util.h"
#include "gnc-gui-query.h"
@ -17,6 +16,7 @@
#include "AccWindow.h"
#include "gnc-date-edit.h"
#include "business-utils.h"
#include "dialog-date-close.h"
typedef struct _dialog_date_close_window {
@ -132,36 +132,7 @@ gnc_dialog_date_close_cb (GnomeDialog *dialog, gpointer data)
static void
fill_in_acct_info (DialogDateClose *ddc)
{
GList *list, *node, *names = NULL;
list = xaccGroupGetSubAccounts (gnc_book_get_group (ddc->book));
for (node = list; node; node = node->next) {
Account *account = node->data;
char *name;
/* Only present accounts of the appropriate type */
if (g_list_index (ddc->acct_types,
(gpointer)xaccAccountGetType (account)) == -1)
continue;
name = xaccAccountGetFullName (account, gnc_get_account_separator ());
if (name != NULL)
names = g_list_append (names, name);
}
g_list_free (list);
/* set the popdown strings and the default to the first one */
if (names) {
gtk_combo_set_popdown_strings (GTK_COMBO (ddc->acct_combo), names);
gtk_entry_set_text (GTK_ENTRY ( (GTK_COMBO (ddc->acct_combo))->entry),
names->data);
}
for (node = names; node; node = node->next)
g_free (node->data);
g_list_free (names);
gnc_fill_account_select_combo (ddc->acct_combo, ddc->book, ddc->acct_types);
}
static void

View File

@ -270,7 +270,6 @@ gnc_invoice_window_post_invoice_cb (GtkWidget *widget, gpointer data)
Account *acc = NULL;
GList * acct_types = NULL;
Timespec ddue, postdate;
gboolean reverse = FALSE;
/* Make sure the invoice is ok */
if (!gnc_invoice_window_verify_ok (iw))
@ -297,17 +296,7 @@ gnc_invoice_window_post_invoice_cb (GtkWidget *widget, gpointer data)
acct_label = _("Post to Account");
/* Determine the type of account to post to */
switch (gncOwnerGetType (&(iw->owner))) {
case GNC_OWNER_CUSTOMER:
acct_types = g_list_prepend (NULL, (gpointer)RECEIVABLE);
reverse = TRUE;
break;
case GNC_OWNER_VENDOR:
acct_types = g_list_prepend (NULL, (gpointer)PAYABLE);
break;
default:
acct_types = g_list_prepend (NULL, (gpointer)NO_TYPE);
}
acct_types = gnc_business_account_types (&(iw->owner));
/* Get the due date and posted account */
timespecFromTime_t (&postdate, time(NULL));
@ -328,7 +317,7 @@ gnc_invoice_window_post_invoice_cb (GtkWidget *widget, gpointer data)
gnc_invoice_window_ok_save (iw);
/* ... post it; post date is set to now ... */
gncInvoicePostToAccount (invoice, acc, &postdate, &ddue, memo, reverse);
gncInvoicePostToAccount (invoice, acc, &postdate, &ddue, memo);
gnc_resume_gui_refresh ();
if (memo)
@ -1279,6 +1268,8 @@ gnc_invoice_search (GncInvoice *start, GncOwner *owner, GNCBook *book)
columns = gnc_search_param_prepend (columns, _("Company"), NULL, type,
INVOICE_OWNER, OWNER_PARENT,
OWNER_NAME, NULL);
columns = gnc_search_param_prepend (columns, _("Type"), NULL, type,
INVOICE_TYPE, NULL);
columns = gnc_search_param_prepend (columns, _("Posted"), NULL, type,
INVOICE_POSTED, NULL);
columns = gnc_search_param_prepend (columns, _("Opened"), NULL, type,

View File

@ -0,0 +1,366 @@
/*
* dialog-payment.c -- Dialog for payment entry
* Copyright (C) 2002 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#include "config.h"
#include <gnome.h>
#include "dialog-utils.h"
#include "global-options.h"
#include "gnc-component-manager.h"
#include "gnc-ui.h"
#include "gnc-gui-query.h"
#include "gnc-ui-util.h"
#include "gnc-engine-util.h"
#include "gnc-date-edit.h"
#include "gnc-amount-edit.h"
#include "gnc-account-tree.h"
#include "Transaction.h"
#include "Account.h"
#include "gnc-numeric.h"
#include "dialog-payment.h"
#include "business-utils.h"
#define DIALOG_PAYMENT_CUSTOMER_CM_CLASS "customer-payment-dialog"
#define DIALOG_PAYMENT_VENDOR_CM_CLASS "vendor-payment-dialog"
struct _payment_window {
GtkWidget * dialog;
GtkWidget * num_entry;
GtkWidget * memo_entry;
GtkWidget * post_combo;
GtkWidget * owner_choice;
GtkWidget * amount_edit;
GtkWidget * date_edit;
GtkWidget * acct_tree;
gint component_id;
GNCBook * book;
GncOwner owner;
GList * acct_types;
};
static void
gnc_payment_window_refresh_handler (GHashTable *changes, gpointer data)
{
PaymentWindow *pw = data;
gnc_fill_account_select_combo (pw->post_combo, pw->book, pw->acct_types);
}
static void
gnc_payment_window_close_handler (gpointer data)
{
PaymentWindow *pw = data;
if (pw)
gnome_dialog_close (GNOME_DIALOG (pw->dialog));
}
static void
gnc_payment_set_owner (PaymentWindow *pw, GncOwner *owner)
{
gnc_owner_set_owner (pw->owner_choice, owner);
}
static void
gnc_payment_ok_cb (GtkWidget *widget, gpointer data)
{
PaymentWindow *pw = data;
char *text;
Account *post, *acc;
gnc_numeric amount;
if (!pw)
return;
/* Verify the amount is non-zero */
amount = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (pw->amount_edit));
if (gnc_numeric_check (amount) || gnc_numeric_zero_p (amount)) {
text = _("You must enter the amount of the payment. "
"Payments may not be zero.");
gnc_error_dialog_parented (GTK_WINDOW (pw->dialog), text);
return;
}
/* Verify the user has selected an owner */
gnc_owner_get_owner (pw->owner_choice, &(pw->owner));
if (pw->owner.owner.undefined == NULL) {
text = _("You must select a company for payment processing.");
gnc_error_dialog_parented (GTK_WINDOW (pw->dialog), text);
return;
}
/* Verify the user has selected a transfer account */
acc = gnc_account_tree_get_current_account (GNC_ACCOUNT_TREE(pw->acct_tree));
if (!acc) {
text = _("You must select a transfer account from the account tree.");
gnc_error_dialog_parented (GTK_WINDOW (pw->dialog), text);
return;
}
/* Verify the "post" account */
text = gtk_entry_get_text (GTK_ENTRY ((GTK_COMBO (pw->post_combo))->entry));
if (!text || safe_strcmp (text, "") == 0) {
text = _("You must enter an account name for posting.");
gnc_error_dialog_parented (GTK_WINDOW (pw->dialog), text);
return;
}
post = xaccGetAccountFromFullName (gnc_book_get_group (pw->book),
text, gnc_get_account_separator ());
if (!post) {
char *msg = g_strdup_printf (
_("Your selected post account, %s, does not exist"),
text);
gnc_error_dialog_parented (GTK_WINDOW (pw->dialog), msg);
g_free (msg);
return;
}
/* Ok, now post the damn thing */
{
Transaction *txn;
Split *split;
char *memo, *num;
const char *name;
gnc_commodity *commodity;
Timespec date;
gboolean reverse;
/* Obtain all our ancillary information */
memo = gtk_entry_get_text (GTK_ENTRY (pw->memo_entry));
num = gtk_entry_get_text (GTK_ENTRY (pw->num_entry));
date = gnc_date_edit_get_date_ts (GNC_DATE_EDIT (pw->date_edit));
name = gncOwnerGetName (gncOwnerGetEndOwner (&(pw->owner)));
commodity = gncOwnerGetCommodity (&(pw->owner));
reverse = (gncOwnerGetType (&(pw->owner)) == GNC_OWNER_CUSTOMER);
txn = xaccMallocTransaction (pw->book);
xaccTransBeginEdit (txn);
/* Set up the transaction */
xaccTransSetDescription (txn, name);
xaccTransSetNum (txn, num);
xaccTransSetCurrency (txn, commodity);
xaccTransSetDateEnteredTS (txn, &date);
xaccTransSetDatePostedTS (txn, &date);
xaccTransSetTxnType (txn, TXN_TYPE_PAYMENT);
/* The split for the transfer account */
split = xaccMallocSplit (pw->book);
xaccSplitSetMemo (split, memo);
xaccSplitSetBaseValue (split, reverse ? amount :
gnc_numeric_neg (amount), commodity);
xaccAccountBeginEdit (acc);
xaccAccountInsertSplit (acc, split);
xaccAccountCommitEdit (acc);
xaccTransAppendSplit (txn, split);
/* The split for the posting account */
split = xaccMallocSplit (pw->book);
xaccSplitSetMemo (split, memo);
xaccSplitSetAction (split, _("Payment"));
xaccSplitSetBaseValue (split, reverse ? gnc_numeric_neg (amount) :
amount, commodity);
xaccAccountBeginEdit (post);
xaccAccountInsertSplit (post, split);
xaccAccountCommitEdit (post);
xaccTransAppendSplit (txn, split);
/*
* Attach the OWNER to the transaction? Or, better yet, attach to
* the proper lots from this owner in this post account
*/
/* Commit it */
xaccTransCommitEdit (txn);
}
gnc_ui_payment_window_destroy (pw);
}
static void
gnc_payment_cancel_cb (GtkWidget *widget, gpointer data)
{
PaymentWindow *pw = data;
gnc_ui_payment_window_destroy (pw);
}
static void
gnc_payment_window_destroy_cb (GtkWidget *widget, gpointer data)
{
PaymentWindow *pw = data;
if (!pw) return;
gnc_unregister_gui_component (pw->component_id);
g_list_free (pw->acct_types);
g_free (pw);
}
/* Select the list of accounts to show in the tree */
static void
gnc_payment_set_account_types (GNCAccountTree *tree)
{
AccountViewInfo avi;
int i;
gnc_account_tree_get_view_info (tree, &avi);
for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
switch (i) {
case BANK:
case CASH:
case CREDIT:
case ASSET:
case LIABILITY:
avi.include_type[i] = TRUE;
break;
default:
avi.include_type[i] = FALSE;
break;
}
gnc_account_tree_set_view_info (tree, &avi);
}
static gboolean
find_handler (gpointer find_data, gpointer user_data)
{
PaymentWindow *pw = user_data;
return (pw != NULL);
}
static PaymentWindow *
new_payment_window (GncOwner *owner, GNCBook *book)
{
PaymentWindow *pw;
GladeXML *xml;
GtkWidget *box, *label;
char * cm_class = (gncOwnerGetType (owner) == GNC_OWNER_CUSTOMER ?
DIALOG_PAYMENT_CUSTOMER_CM_CLASS :
DIALOG_PAYMENT_VENDOR_CM_CLASS);
/*
* Find an existing payment window. If found, bring it to
* the front. If we have an actual owner, then set it in
* the window.
*/
pw = gnc_find_first_gui_component (cm_class, find_handler, NULL);
if (pw) {
if (owner->owner.undefined)
gnc_payment_set_owner (pw, owner);
gtk_window_present (GTK_WINDOW(pw->dialog));
return(pw);
}
/* Ok, we need a new window */
pw = g_new0 (PaymentWindow, 1);
pw->book = book;
gncOwnerCopy (owner, &(pw->owner));
/* Compute the post-to account types */
pw->acct_types = gnc_business_account_types (owner);
/* Open and read the XML */
xml = gnc_glade_xml_new ("payment.glade", "Payment Dialog");
pw->dialog = glade_xml_get_widget (xml, "Payment Dialog");
/* Grab the widgets and build the dialog */
pw->num_entry = glade_xml_get_widget (xml, "num_entry");
pw->memo_entry = glade_xml_get_widget (xml, "memo_entry");
pw->post_combo = glade_xml_get_widget (xml, "post_combo");
label = glade_xml_get_widget (xml, "owner_label");
box = glade_xml_get_widget (xml, "owner_box");
pw->owner_choice = gnc_owner_select_create (label, box, book, owner);
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);
box = glade_xml_get_widget (xml, "date_box");
pw->date_edit = gnc_date_edit_new (time(NULL), FALSE, FALSE);
gtk_box_pack_start (GTK_BOX (box), pw->date_edit, TRUE, TRUE, 0);
box = glade_xml_get_widget (xml, "acct_window");
pw->acct_tree = gnc_account_tree_new ();
gtk_container_add (GTK_CONTAINER (box), pw->acct_tree);
gtk_clist_column_titles_hide(GTK_CLIST(pw->acct_tree));
gnc_account_tree_hide_all_but_name(GNC_ACCOUNT_TREE(pw->acct_tree));
gnc_payment_set_account_types (GNC_ACCOUNT_TREE (pw->acct_tree));
/* Connect the dialog buttons */
gnome_dialog_button_connect (GNOME_DIALOG (pw->dialog), 0,
gnc_payment_ok_cb, pw);
gnome_dialog_button_connect (GNOME_DIALOG (pw->dialog), 1,
gnc_payment_cancel_cb, pw);
/* Setup various signal handlers */
gtk_signal_connect (GTK_OBJECT (pw->dialog), "destroy",
gnc_payment_window_destroy_cb, pw);
/* Register with the component manager */
pw->component_id =
gnc_register_gui_component (cm_class,
gnc_payment_window_refresh_handler,
gnc_payment_window_close_handler,
pw);
/* Watch for any new or changed accounts */
gnc_gui_component_watch_entity_type (pw->component_id,
GNC_ID_ACCOUNT,
GNC_EVENT_CREATE | GNC_EVENT_MODIFY |
GNC_EVENT_DESTROY);
/* Fill in the post_combo and account_tree widgets */
gnc_account_tree_refresh(GNC_ACCOUNT_TREE(pw->acct_tree));
gnc_fill_account_select_combo (pw->post_combo, pw->book, pw->acct_types);
/* Show it all */
gtk_widget_show_all (pw->dialog);
return pw;
}
void
gnc_ui_payment_window_destroy (PaymentWindow *pw)
{
if (!pw) return;
gnc_close_gui_component (pw->component_id);
}
PaymentWindow *
gnc_ui_payment_new (GncOwner *owner, GNCBook *book)
{
GncOwner owner_def;
if (!book) return NULL;
if (owner) {
/* Figure out the company */
owner = gncOwnerGetEndOwner (owner);
} else {
gncOwnerInitCustomer (&owner_def, NULL);
owner = &owner_def;
}
return new_payment_window (owner, book);
}

View File

@ -0,0 +1,21 @@
/*
* dialog-payment.h -- Dialog to enter payments
* Copyright (C) 2002 Derek Atkins
* Author: Derek Atkins <warlord@MIT.EDU>
*/
#ifndef _DIALOG_PAYMENT_H
#define _DIALOG_PAYMENT_H
typedef struct _payment_window PaymentWindow;
#include "gnc-book.h"
#include "gncOwner.h"
/* Create a payment window */
PaymentWindow * gnc_ui_payment_new (GncOwner *owner, GNCBook *book);
/* Destroy a payment window */
void gnc_ui_payment_window_destroy (PaymentWindow *pw);
#endif /* _DIALOG_PAYMENT_H */

View File

@ -37,6 +37,7 @@
"#include <dialog-invoice.h>\n"
"#include <dialog-job.h>\n"
"#include <dialog-order.h>\n"
"#include <dialog-payment.h>\n"
"#include <dialog-vendor.h>\n"
)))
@ -192,6 +193,18 @@
"Dialog: Select a GncOrder. Either start_selection or "
"order_owner may be NULL.")
;;
;; dialog-payment.h
;;
(gw:wrap-function
ws
'gnc:payment-new
'<gw:void>
"gnc_ui_payment_new"
'((<gnc:GncOwner*> owner) (<gnc:Book*> book))
"Dialog: Enter a payment. The owner may be NULL.")
;;
;; dialog-vendor.h
;;

View File

@ -0,0 +1,362 @@
<?xml version="1.0"?>
<GTK-Interface>
<project>
<name>Payment</name>
<program_name>payment</program_name>
<directory></directory>
<source_directory>src</source_directory>
<pixmaps_directory>pixmaps</pixmaps_directory>
<language>C</language>
<gnome_support>True</gnome_support>
<gettext_support>True</gettext_support>
<output_main_file>False</output_main_file>
<output_support_files>False</output_support_files>
<output_build_files>False</output_build_files>
</project>
<widget>
<class>GnomeDialog</class>
<name>Payment Dialog</name>
<type>GTK_WINDOW_TOPLEVEL</type>
<position>GTK_WIN_POS_NONE</position>
<modal>False</modal>
<allow_shrink>False</allow_shrink>
<allow_grow>False</allow_grow>
<auto_shrink>False</auto_shrink>
<auto_close>False</auto_close>
<hide_on_close>False</hide_on_close>
<widget>
<class>GtkVBox</class>
<child_name>GnomeDialog:vbox</child_name>
<name>dialog-vbox1</name>
<homogeneous>False</homogeneous>
<spacing>8</spacing>
<child>
<padding>4</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHButtonBox</class>
<child_name>GnomeDialog:action_area</child_name>
<name>dialog-action_area1</name>
<layout_style>GTK_BUTTONBOX_END</layout_style>
<spacing>8</spacing>
<child_min_width>85</child_min_width>
<child_min_height>27</child_min_height>
<child_ipad_x>7</child_ipad_x>
<child_ipad_y>0</child_ipad_y>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
<pack>GTK_PACK_END</pack>
</child>
<widget>
<class>GtkButton</class>
<name>button1</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_OK</stock_button>
</widget>
<widget>
<class>GtkButton</class>
<name>button3</name>
<can_default>True</can_default>
<can_focus>True</can_focus>
<stock_button>GNOME_STOCK_BUTTON_CANCEL</stock_button>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox1</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkFrame</class>
<name>frame1</name>
<label>Payment Information</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>hbox1</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<widget>
<class>GtkVBox</class>
<name>vbox2</name>
<border_width>3</border_width>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkLabel</class>
<name>owner_label</name>
<label>(owner)</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label3</name>
<label>Date</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label2</name>
<label>Amount</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label4</name>
<label>Num</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkLabel</class>
<name>label5</name>
<label>Memo</label>
<justify>GTK_JUSTIFY_RIGHT</justify>
<wrap>False</wrap>
<xalign>1</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
<widget>
<class>GtkVBox</class>
<name>vbox3</name>
<border_width>3</border_width>
<homogeneous>True</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>GtkHBox</class>
<name>owner_box</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>date_box</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
</widget>
<widget>
<class>GtkHBox</class>
<name>amount_box</name>
<homogeneous>False</homogeneous>
<spacing>0</spacing>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>Placeholder</class>
</widget>
</widget>
<widget>
<class>GtkEntry</class>
<name>num_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
<widget>
<class>GtkEntry</class>
<name>memo_entry</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
<child>
<padding>0</padding>
<expand>False</expand>
<fill>False</fill>
</child>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame2</name>
<label>Post To</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkCombo</class>
<name>post_combo</name>
<border_width>3</border_width>
<value_in_list>True</value_in_list>
<ok_if_empty>False</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items></items>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>combo-entry1</name>
<can_focus>True</can_focus>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text></text>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frame3</name>
<label>Transfer Account</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<child>
<padding>0</padding>
<expand>True</expand>
<fill>True</fill>
</child>
<widget>
<class>GtkScrolledWindow</class>
<name>acct_window</name>
<border_width>3</border_width>
<hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
<widget>
<class>Placeholder</class>
</widget>
</widget>
</widget>
</widget>
</widget>
</widget>
</GTK-Interface>