mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
gncCustomer: change terms from gint to string
gncEntry: emit engine events for changes emit an event when the order is set: 'owner' modified gncOrder: add the entry to the order before setting the entry business-gnome.scm: change the API for invoice/order find/edit functions dialog-customer: change terms entry to a GtkEntry; handle as string integrate invoice/order API changes dialog-invoice: change find/edit API; start work for asynchronous UI dialog-order: change find/edit API; start work for asynchronous UI dialog-vendor: integrate invoice/order API changes dialog-job-select: integrate invoice/order API changes git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@6750 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
8e51e62781
commit
2e801a6460
@ -28,11 +28,11 @@ struct _gncCustomer {
|
||||
char * id;
|
||||
char * name;
|
||||
char * notes;
|
||||
char * terms;
|
||||
GncAddress * addr;
|
||||
GncAddress * shipaddr;
|
||||
gnc_numeric discount;
|
||||
gnc_numeric credit;
|
||||
gint terms;
|
||||
gboolean taxincluded;
|
||||
gboolean active;
|
||||
GList * jobs;
|
||||
@ -61,11 +61,11 @@ GncCustomer *gncCustomerCreate (GNCBook *book)
|
||||
cust->id = CACHE_INSERT ("");
|
||||
cust->name = CACHE_INSERT ("");
|
||||
cust->notes = CACHE_INSERT ("");
|
||||
cust->terms = CACHE_INSERT ("Net-30");
|
||||
cust->addr = gncAddressCreate (book);
|
||||
cust->shipaddr = gncAddressCreate (book);
|
||||
cust->discount = gnc_numeric_zero();
|
||||
cust->credit = gnc_numeric_zero();
|
||||
cust->terms = 30;
|
||||
cust->taxincluded = FALSE;
|
||||
cust->active = TRUE;
|
||||
cust->jobs = NULL;
|
||||
@ -83,6 +83,7 @@ void gncCustomerDestroy (GncCustomer *cust)
|
||||
CACHE_REMOVE (cust->id);
|
||||
CACHE_REMOVE (cust->name);
|
||||
CACHE_REMOVE (cust->notes);
|
||||
CACHE_REMOVE (cust->terms);
|
||||
gncAddressDestroy (cust->addr);
|
||||
gncAddressDestroy (cust->shipaddr);
|
||||
g_list_free (cust->jobs);
|
||||
@ -137,11 +138,10 @@ void gncCustomerSetGUID (GncCustomer *cust, const GUID *guid)
|
||||
addObj (cust);
|
||||
}
|
||||
|
||||
void gncCustomerSetTerms (GncCustomer *cust, gint terms)
|
||||
void gncCustomerSetTerms (GncCustomer *cust, const char *terms)
|
||||
{
|
||||
if (!cust) return;
|
||||
if (terms == cust->terms) return;
|
||||
cust->terms = terms;
|
||||
if (!cust || !terms) return;
|
||||
SET_STR(cust->terms, terms);
|
||||
cust->dirty = TRUE;
|
||||
}
|
||||
|
||||
@ -254,9 +254,9 @@ const char * gncCustomerGetNotes (GncCustomer *cust)
|
||||
return cust->notes;
|
||||
}
|
||||
|
||||
gint gncCustomerGetTerms (GncCustomer *cust)
|
||||
const char * gncCustomerGetTerms (GncCustomer *cust)
|
||||
{
|
||||
if (!cust) return 0;
|
||||
if (!cust) return NULL;
|
||||
return cust->terms;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ void gncCustomerDestroy (GncCustomer *customer);
|
||||
void gncCustomerSetID (GncCustomer *customer, const char *id);
|
||||
void gncCustomerSetName (GncCustomer *customer, const char *name);
|
||||
void gncCustomerSetNotes (GncCustomer *customer, const char *notes);
|
||||
void gncCustomerSetTerms (GncCustomer *customer, gint terms);
|
||||
void gncCustomerSetTerms (GncCustomer *customer, const char *terms);
|
||||
void gncCustomerSetTaxIncluded (GncCustomer *customer, gboolean taxincl);
|
||||
void gncCustomerSetActive (GncCustomer *customer, gboolean active);
|
||||
void gncCustomerSetDiscount (GncCustomer *customer, gnc_numeric discount);
|
||||
@ -47,7 +47,7 @@ const char * gncCustomerGetName (GncCustomer *customer);
|
||||
GncAddress * gncCustomerGetAddr (GncCustomer *customer);
|
||||
GncAddress * gncCustomerGetShipAddr (GncCustomer *customer);
|
||||
const char * gncCustomerGetNotes (GncCustomer *customer);
|
||||
gint gncCustomerGetTerms (GncCustomer *customer);
|
||||
const char * gncCustomerGetTerms (GncCustomer *customer);
|
||||
gboolean gncCustomerGetTaxIncluded (GncCustomer *customer);
|
||||
gboolean gncCustomerGetActive (GncCustomer *customer);
|
||||
gnc_numeric gncCustomerGetDiscount (GncCustomer *customer);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "gnc-book-p.h"
|
||||
#include "GNCIdP.h"
|
||||
#include "QueryObject.h"
|
||||
#include "gnc-event-p.h"
|
||||
|
||||
#include "gncBusiness.h"
|
||||
#include "gncEntry.h"
|
||||
@ -88,6 +89,15 @@ gint gncEntryGetTypeFromStr (const char *type)
|
||||
return -1;
|
||||
}
|
||||
|
||||
G_INLINE_FUNC void mark_entry (GncEntry *entry);
|
||||
G_INLINE_FUNC void
|
||||
mark_entry (GncEntry *entry)
|
||||
{
|
||||
entry->dirty = TRUE;
|
||||
|
||||
gnc_engine_generate_event (&entry->guid, GNC_EVENT_MODIFY);
|
||||
}
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
|
||||
GncEntry *gncEntryCreate (GNCBook *book)
|
||||
@ -104,10 +114,10 @@ GncEntry *gncEntryCreate (GNCBook *book)
|
||||
|
||||
{
|
||||
gnc_numeric zero = gnc_numeric_zero ();
|
||||
gncEntrySetQuantity (entry, zero);
|
||||
gncEntrySetPrice (entry, zero);
|
||||
gncEntrySetTax (entry, zero);
|
||||
gncEntrySetDiscount (entry, zero);
|
||||
entry->quantity = zero;
|
||||
entry->price = zero;
|
||||
entry->tax = zero;
|
||||
entry->discount = zero;
|
||||
}
|
||||
entry->tax_type = GNC_ENTRY_INTERP_PERCENT;
|
||||
entry->disc_type = GNC_ENTRY_INTERP_PERCENT;
|
||||
@ -116,6 +126,8 @@ GncEntry *gncEntryCreate (GNCBook *book)
|
||||
xaccGUIDNew (&entry->guid, book);
|
||||
addObj (entry);
|
||||
|
||||
gnc_engine_generate_event (&entry->guid, GNC_EVENT_CREATE);
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
@ -123,6 +135,8 @@ void gncEntryDestroy (GncEntry *entry)
|
||||
{
|
||||
if (!entry) return;
|
||||
|
||||
gnc_engine_generate_event (&entry->guid, GNC_EVENT_DESTROY);
|
||||
|
||||
CACHE_REMOVE (entry->desc);
|
||||
CACHE_REMOVE (entry->action);
|
||||
remObj (entry);
|
||||
@ -146,70 +160,70 @@ void gncEntrySetDate (GncEntry *entry, Timespec date)
|
||||
{
|
||||
if (!entry) return;
|
||||
entry->date = date;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetDateEntered (GncEntry *entry, Timespec date)
|
||||
{
|
||||
if (!entry) return;
|
||||
entry->date_entered = date;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetDescription (GncEntry *entry, const char *desc)
|
||||
{
|
||||
if (!entry || !desc) return;
|
||||
SET_STR (entry->desc, desc);
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetAction (GncEntry *entry, const char *action)
|
||||
{
|
||||
if (!entry || !action) return;
|
||||
SET_STR (entry->action, action);
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetQuantity (GncEntry *entry, gnc_numeric quantity)
|
||||
{
|
||||
if (!entry) return;
|
||||
entry->quantity = quantity;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetPrice (GncEntry *entry, gnc_numeric price)
|
||||
{
|
||||
if (!entry) return;
|
||||
entry->price = price;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetTax (GncEntry *entry, gnc_numeric tax)
|
||||
{
|
||||
if (!entry) return;
|
||||
entry->tax = tax;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetDiscount (GncEntry *entry, gnc_numeric discount)
|
||||
{
|
||||
if (!entry) return;
|
||||
entry->discount = discount;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetAccount (GncEntry *entry, Account *acc)
|
||||
{
|
||||
if (!entry) return;
|
||||
entry->account = acc;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetTaxAccount (GncEntry *entry, Account *acc)
|
||||
{
|
||||
if (!entry) return;
|
||||
entry->taxaccount = acc;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
/* Called from gncOrder when we're added to the Order */
|
||||
@ -217,7 +231,11 @@ void gncEntrySetOrder (GncEntry *entry, GncOrder *order)
|
||||
{
|
||||
if (!entry) return;
|
||||
entry->order = order;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
|
||||
/* Generate an event modifying the Order's end-owner */
|
||||
gnc_engine_generate_event (gncOwnerGetEndGUID (gncOrderGetOwner (order)),
|
||||
GNC_EVENT_MODIFY);
|
||||
}
|
||||
|
||||
/* called from gncInvoice when we're added to the Invoice */
|
||||
@ -225,7 +243,7 @@ void gncEntrySetInvoice (GncEntry *entry, GncInvoice *invoice)
|
||||
{
|
||||
if (!entry) return;
|
||||
entry->invoice = invoice;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetTaxType (GncEntry *entry, gint type)
|
||||
@ -234,7 +252,7 @@ void gncEntrySetTaxType (GncEntry *entry, gint type)
|
||||
if (type < 0 || type > 1) return;
|
||||
|
||||
entry->tax_type = type;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetDiscountType (GncEntry *entry, gint type)
|
||||
@ -243,7 +261,7 @@ void gncEntrySetDiscountType (GncEntry *entry, gint type)
|
||||
if (type < 0 || type > 3) return;
|
||||
|
||||
entry->disc_type = type;
|
||||
entry->dirty = TRUE;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetDirty (GncEntry *entry, gboolean dirty)
|
||||
|
@ -174,9 +174,11 @@ void gncOrderAddEntry (GncOrder *order, GncEntry *entry)
|
||||
if (old == order) return; /* I already own it */
|
||||
if (old) gncOrderRemoveEntry (old, entry);
|
||||
|
||||
gncEntrySetOrder (entry, order);
|
||||
order->entries = g_list_insert_sorted (order->entries, entry,
|
||||
(GCompareFunc)gncEntryCompare);
|
||||
|
||||
/* This will send out an event -- make sure we're attached */
|
||||
gncEntrySetOrder (entry, order);
|
||||
order->dirty = TRUE;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
||||
(N_ "Find Order")
|
||||
(list "Extensions" "Customers" "")
|
||||
(lambda ()
|
||||
(gnc:order-find #f #f last-cust
|
||||
(gnc:order-find #f last-cust
|
||||
(gnc:get-current-book)))))
|
||||
|
||||
(define new-invoice-item
|
||||
@ -58,7 +58,7 @@
|
||||
(N_ "Find Invoice")
|
||||
(list "Extensions" "Customers" "")
|
||||
(lambda ()
|
||||
(gnc:invoice-find #f #f last-cust
|
||||
(gnc:invoice-find #f last-cust
|
||||
(gnc:get-current-book)))))
|
||||
|
||||
(define new-job-item
|
||||
@ -128,7 +128,7 @@
|
||||
(N_ "Find Order")
|
||||
(list "Extensions" "Vendors" "")
|
||||
(lambda ()
|
||||
(gnc:order-find #f #f last-vendor
|
||||
(gnc:order-find #f last-vendor
|
||||
(gnc:get-current-book)))))
|
||||
|
||||
(define new-invoice-item
|
||||
@ -144,7 +144,7 @@
|
||||
(N_ "Find Invoice")
|
||||
(list "Extensions" "Vendors" "")
|
||||
(lambda ()
|
||||
(gnc:invoice-find #f #f last-vendor
|
||||
(gnc:invoice-find #f last-vendor
|
||||
(gnc:get-current-book)))))
|
||||
|
||||
(define new-job-item
|
||||
@ -305,10 +305,10 @@
|
||||
(gnc:group-insert-account group tax-acct)
|
||||
|
||||
;; Launch the order editor
|
||||
(gnc:order-edit #f order)
|
||||
(gnc:order-edit order)
|
||||
|
||||
;; Launch the invoice editor
|
||||
(gnc:invoice-edit #f invoice)
|
||||
(gnc:invoice-edit invoice)
|
||||
))))
|
||||
|
||||
|
||||
|
@ -716,19 +716,18 @@
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>GtkHBox</class>
|
||||
<name>terms_box</name>
|
||||
<homogeneous>False</homogeneous>
|
||||
<spacing>0</spacing>
|
||||
<class>GtkEntry</class>
|
||||
<name>terms_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>True</expand>
|
||||
<fill>True</fill>
|
||||
<expand>False</expand>
|
||||
<fill>False</fill>
|
||||
</child>
|
||||
|
||||
<widget>
|
||||
<class>Placeholder</class>
|
||||
</widget>
|
||||
</widget>
|
||||
|
||||
<widget>
|
||||
|
@ -69,7 +69,7 @@ typedef struct _customer_window {
|
||||
GtkWidget * shipfax_entry;
|
||||
GtkWidget * shipemail_entry;
|
||||
|
||||
GtkWidget * terms_amount;
|
||||
GtkWidget * terms_entry;
|
||||
GtkWidget * discount_amount;
|
||||
GtkWidget * credit_amount;
|
||||
|
||||
@ -97,7 +97,6 @@ cw_get_customer (CustomerWindow *cw)
|
||||
static void gnc_ui_to_customer (CustomerWindow *cw, GncCustomer *cust)
|
||||
{
|
||||
GncAddress *addr, *shipaddr;
|
||||
gnc_numeric num;
|
||||
|
||||
addr = gncCustomerGetAddr (cust);
|
||||
shipaddr = gncCustomerGetShipAddr (cust);
|
||||
@ -151,8 +150,8 @@ static void gnc_ui_to_customer (CustomerWindow *cw, GncCustomer *cust)
|
||||
(GTK_EDITABLE (cw->notes_text), 0, -1));
|
||||
|
||||
/* Parse and set the terms, discount, and credit amounts */
|
||||
num = gnc_amount_edit_get_amount (GNC_AMOUNT_EDIT (cw->terms_amount));
|
||||
gncCustomerSetTerms (cust, gnc_numeric_num (num));
|
||||
gncCustomerSetTerms (cust, gtk_editable_get_chars
|
||||
(GTK_EDITABLE (cw->terms_entry), 0, -1));
|
||||
gncCustomerSetDiscount (cust, gnc_amount_edit_get_amount
|
||||
(GNC_AMOUNT_EDIT (cw->discount_amount)));
|
||||
gncCustomerSetCredit (cust, gnc_amount_edit_get_amount
|
||||
@ -225,10 +224,10 @@ gnc_customer_window_ok_cb (GtkWidget *widget, gpointer data)
|
||||
/* Verify terms, discount, and credit are valid (or empty) */
|
||||
min = gnc_numeric_zero ();
|
||||
max = gnc_numeric_create (100, 1);
|
||||
if (check_edit_amount (cw->dialog, cw->terms_amount, &min, NULL,
|
||||
_("Terms must be a positive integer or "
|
||||
"you must leave it blank.")))
|
||||
return;
|
||||
// if (check_edit_amount (cw->dialog, cw->terms_amount, &min, NULL,
|
||||
// _("Terms must be a positive integer or "
|
||||
// "you must leave it blank.")))
|
||||
// return;
|
||||
|
||||
if (check_edit_amount (cw->dialog, cw->discount_amount, &min, &max,
|
||||
_("Discount percentage must be between 0-100 "
|
||||
@ -419,21 +418,12 @@ gnc_customer_new_window (GtkWidget *parent, GNCBook *bookp,
|
||||
cw->taxincluded_check = glade_xml_get_widget (xml, "tax_included_check");
|
||||
cw->notes_text = glade_xml_get_widget (xml, "notes_text");
|
||||
|
||||
/* TERMS: Integer Value */
|
||||
edit = gnc_amount_edit_new();
|
||||
gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
|
||||
print_info = gnc_integral_print_info ();
|
||||
gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
|
||||
gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), 1);
|
||||
cw->terms_amount = edit;
|
||||
gtk_widget_show (edit);
|
||||
|
||||
hbox = glade_xml_get_widget (xml, "terms_box");
|
||||
gtk_box_pack_start (GTK_BOX (hbox), edit, TRUE, TRUE, 0);
|
||||
cw->terms_entry = glade_xml_get_widget (xml, "terms_entry");
|
||||
|
||||
/* DISCOUNT: Percentage Value */
|
||||
edit = gnc_amount_edit_new();
|
||||
gnc_amount_edit_set_evaluate_on_enter (GNC_AMOUNT_EDIT (edit), TRUE);
|
||||
print_info = gnc_integral_print_info ();
|
||||
print_info.max_decimal_places = 5;
|
||||
gnc_amount_edit_set_print_info (GNC_AMOUNT_EDIT (edit), print_info);
|
||||
gnc_amount_edit_set_fraction (GNC_AMOUNT_EDIT (edit), 100000);
|
||||
@ -570,19 +560,16 @@ gnc_customer_new_window (GtkWidget *parent, GNCBook *bookp,
|
||||
cw);
|
||||
}
|
||||
|
||||
|
||||
/* I know that cust exists here -- either passed in or just created */
|
||||
{
|
||||
gnc_numeric terms;
|
||||
|
||||
/* Set the Terms, Discount, and Credit amounts */
|
||||
terms = gnc_numeric_create (gncCustomerGetTerms (cust), 1);
|
||||
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->terms_amount), terms);
|
||||
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->discount_amount),
|
||||
gncCustomerGetDiscount (cust));
|
||||
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->credit_amount),
|
||||
gncCustomerGetCredit (cust));
|
||||
}
|
||||
gtk_entry_set_text (GTK_ENTRY (cw->terms_entry),
|
||||
gncCustomerGetTerms (cust));
|
||||
|
||||
/* Set the Discount, and Credit amounts */
|
||||
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->discount_amount),
|
||||
gncCustomerGetDiscount (cust));
|
||||
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (cw->credit_amount),
|
||||
gncCustomerGetCredit (cust));
|
||||
|
||||
gnc_gui_component_watch_entity_type (cw->component_id,
|
||||
GNC_CUSTOMER_MODULE_NAME,
|
||||
@ -648,7 +635,7 @@ invoice_customer_cb (gpointer *cust_p, gpointer user_data)
|
||||
return TRUE;
|
||||
|
||||
gncOwnerInitCustomer (&owner, cust);
|
||||
gnc_invoice_find (sw->parent, NULL, &owner, sw->book);
|
||||
gnc_invoice_find (NULL, &owner, sw->book);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -667,7 +654,7 @@ order_customer_cb (gpointer *cust_p, gpointer user_data)
|
||||
return TRUE;
|
||||
|
||||
gncOwnerInitCustomer (&owner, cust);
|
||||
gnc_order_find (sw->parent, NULL, &owner, sw->book);
|
||||
gnc_order_find (NULL, &owner, sw->book);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ struct _invoice_select_window {
|
||||
gboolean no_close;
|
||||
};
|
||||
|
||||
typedef struct _invoice_window {
|
||||
struct _invoice_window {
|
||||
GladeXML * xml;
|
||||
|
||||
GtkWidget * dialog;
|
||||
@ -75,7 +75,7 @@ typedef struct _invoice_window {
|
||||
GncInvoice * created_invoice;
|
||||
GncOwner owner;
|
||||
|
||||
} InvoiceWindow;
|
||||
};
|
||||
|
||||
static void gnc_invoice_update_window (InvoiceWindow *iw);
|
||||
|
||||
@ -864,6 +864,25 @@ gnc_invoice_window_new_invoice (GtkWidget *parent, GNCBook *bookp,
|
||||
return iw;
|
||||
}
|
||||
|
||||
InvoiceWindow * gnc_ui_invoice_window_create (GncInvoice *invoice)
|
||||
{
|
||||
InvoiceWindow *iw;
|
||||
InvoiceDialogType type;
|
||||
|
||||
if (!invoice) return NULL;
|
||||
|
||||
/* Immutable once we've been posted */
|
||||
if (gncInvoiceGetPostedAcc (invoice))
|
||||
type = VIEW_INVOICE;
|
||||
else
|
||||
type = EDIT_INVOICE;
|
||||
|
||||
iw = gnc_invoice_new_window (NULL, gncInvoiceGetBook(invoice), type,
|
||||
invoice, gncInvoiceGetOwner (invoice));
|
||||
|
||||
return iw;
|
||||
}
|
||||
|
||||
GncInvoice *
|
||||
gnc_invoice_new (GtkWidget *parent, GncOwner *ownerp, GNCBook *bookp)
|
||||
{
|
||||
@ -905,43 +924,16 @@ gnc_invoice_new (GtkWidget *parent, GncOwner *ownerp, GNCBook *bookp)
|
||||
gtk_main ();
|
||||
|
||||
if (created_invoice)
|
||||
gnc_invoice_edit (parent, created_invoice);
|
||||
gnc_ui_invoice_window_create (created_invoice);
|
||||
|
||||
return created_invoice;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_invoice_edit (GtkWidget *parent, GncInvoice *invoice)
|
||||
{
|
||||
InvoiceWindow *iw;
|
||||
InvoiceDialogType type;
|
||||
|
||||
if (!invoice) return;
|
||||
|
||||
/* Immutable once we've been posted */
|
||||
if (gncInvoiceGetPostedAcc (invoice))
|
||||
type = VIEW_INVOICE;
|
||||
else
|
||||
type = EDIT_INVOICE;
|
||||
|
||||
iw = gnc_invoice_new_window (parent, gncInvoiceGetBook(invoice), type, invoice,
|
||||
gncInvoiceGetOwner (invoice));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (iw->dialog), "close",
|
||||
GTK_SIGNAL_FUNC (gnc_invoice_on_close_cb),
|
||||
NULL);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Functions for invoice selection widgets */
|
||||
|
||||
static gboolean
|
||||
edit_invoice_cb (gpointer *invoice_p, gpointer user_data)
|
||||
{
|
||||
struct _invoice_select_window *sw = user_data;
|
||||
GncInvoice *invoice;
|
||||
|
||||
g_return_val_if_fail (invoice_p && user_data, TRUE);
|
||||
@ -951,7 +943,7 @@ edit_invoice_cb (gpointer *invoice_p, gpointer user_data)
|
||||
if (!invoice)
|
||||
return TRUE;
|
||||
|
||||
gnc_invoice_edit (sw->parent, invoice);
|
||||
gnc_ui_invoice_window_create (invoice);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -1053,10 +1045,9 @@ gnc_invoice_select (GtkWidget *parent, GncInvoice *start, GncOwner *owner,
|
||||
}
|
||||
|
||||
void
|
||||
gnc_invoice_find (GtkWidget *parent, GncInvoice *start, GncOwner *owner,
|
||||
GNCBook *book)
|
||||
gnc_invoice_find (GncInvoice *start, GncOwner *owner, GNCBook *book)
|
||||
{
|
||||
gnc_invoice_select (parent, start, owner, book, FALSE);
|
||||
gnc_invoice_select (NULL, start, owner, book, FALSE);
|
||||
}
|
||||
|
||||
GncInvoice *
|
||||
@ -1079,6 +1070,7 @@ gpointer gnc_invoice_edit_new_edit (gpointer bookp, gpointer v,
|
||||
|
||||
g_return_val_if_fail (invoice != NULL, NULL);
|
||||
|
||||
gnc_invoice_edit (toplevel, invoice);
|
||||
/* XXX: figure out if this window exists and should be raised */
|
||||
gnc_ui_invoice_window_create (invoice);
|
||||
return invoice;
|
||||
}
|
||||
|
@ -8,15 +8,19 @@
|
||||
#ifndef GNC_DIALOG_INVOICE_H_
|
||||
#define GNC_DIALOG_INVOICE_H_
|
||||
|
||||
typedef struct _invoice_window InvoiceWindow;
|
||||
|
||||
#include "gncInvoice.h"
|
||||
#include "gncOwner.h"
|
||||
|
||||
/* Functions to create and edit invoices */
|
||||
GncInvoice * gnc_invoice_new (GtkWidget *parent, GncOwner *owner, GNCBook *book);
|
||||
void gnc_invoice_edit (GtkWidget *parent, GncInvoice *invoice);
|
||||
/* Create an invoice window */
|
||||
InvoiceWindow * gnc_ui_invoice_window_create (GncInvoice *invoice);
|
||||
|
||||
void gnc_invoice_find (GncInvoice *start, GncOwner *owner, GNCBook *book);
|
||||
|
||||
/* Functions to create and return an invoice */
|
||||
GncInvoice * gnc_invoice_new (GtkWidget *parent, GncOwner *owner, GNCBook *book);
|
||||
|
||||
void gnc_invoice_find (GtkWidget *parent, GncInvoice *start,
|
||||
GncOwner *owner, GNCBook *book);
|
||||
GncInvoice * gnc_invoice_choose (GtkWidget *parent, GncInvoice *start,
|
||||
GncOwner *owner, GNCBook *book);
|
||||
|
||||
|
@ -158,7 +158,7 @@ gnc_ui_select_job_order_cb(GtkButton * button, gpointer user_data)
|
||||
return;
|
||||
|
||||
gncOwnerInitJob (&owner, w->job);
|
||||
gnc_order_find (w->parent, NULL, &owner, w->book);
|
||||
gnc_order_find (NULL, &owner, w->book);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -171,7 +171,7 @@ gnc_ui_select_job_invoice_cb(GtkButton * button, gpointer user_data)
|
||||
return;
|
||||
|
||||
gncOwnerInitJob (&owner, w->job);
|
||||
gnc_invoice_find (w->parent, NULL, &owner, w->book);
|
||||
gnc_invoice_find (NULL, &owner, w->book);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -48,7 +48,7 @@ struct _order_select_window {
|
||||
gboolean no_close;
|
||||
};
|
||||
|
||||
typedef struct _order_window {
|
||||
struct _order_window {
|
||||
GladeXML * xml;
|
||||
|
||||
GtkWidget * dialog;
|
||||
@ -76,7 +76,7 @@ typedef struct _order_window {
|
||||
GncOrder * created_order;
|
||||
GncOwner owner;
|
||||
|
||||
} OrderWindow;
|
||||
};
|
||||
|
||||
static void gnc_order_update_window (OrderWindow *ow);
|
||||
|
||||
@ -208,7 +208,7 @@ gnc_order_window_invoice_cb (GtkWidget *widget, gpointer data)
|
||||
return;
|
||||
|
||||
/* Ok, go make an invoice */
|
||||
gnc_invoice_find (ow->parent, NULL, &(ow->owner), ow->book);
|
||||
gnc_invoice_find (NULL, &(ow->owner), ow->book);
|
||||
|
||||
/* refresh the window */
|
||||
gnc_order_update_window (ow);
|
||||
@ -734,6 +734,27 @@ gnc_order_window_new_order (GtkWidget *parent, GNCBook *bookp, GncOwner *owner)
|
||||
return ow;
|
||||
}
|
||||
|
||||
OrderWindow *
|
||||
gnc_ui_order_window_create (GncOrder *order)
|
||||
{
|
||||
OrderWindow *ow;
|
||||
OrderDialogType type;
|
||||
|
||||
if (!order) return NULL;
|
||||
|
||||
type = EDIT_ORDER;
|
||||
{
|
||||
Timespec ts = gncOrderGetDateClosed (order);
|
||||
if (ts.tv_sec || ts.tv_nsec)
|
||||
type = VIEW_ORDER;
|
||||
}
|
||||
|
||||
ow = gnc_order_new_window (NULL, gncOrderGetBook(order), type, order,
|
||||
gncOrderGetOwner (order));
|
||||
|
||||
return ow;
|
||||
}
|
||||
|
||||
GncOrder *
|
||||
gnc_order_new (GtkWidget *parent, GncOwner *ownerp, GNCBook *bookp)
|
||||
{
|
||||
@ -769,44 +790,16 @@ gnc_order_new (GtkWidget *parent, GncOwner *ownerp, GNCBook *bookp)
|
||||
|
||||
/* now open up the ledger */
|
||||
if (created_order)
|
||||
gnc_order_edit (parent, created_order);
|
||||
gnc_ui_order_window_create (created_order);
|
||||
|
||||
return created_order;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_order_edit (GtkWidget *parent, GncOrder *order)
|
||||
{
|
||||
OrderWindow *ow;
|
||||
OrderDialogType type;
|
||||
|
||||
if (!order) return;
|
||||
|
||||
type = EDIT_ORDER;
|
||||
{
|
||||
Timespec ts = gncOrderGetDateClosed (order);
|
||||
if (ts.tv_sec || ts.tv_nsec)
|
||||
type = VIEW_ORDER;
|
||||
}
|
||||
|
||||
ow = gnc_order_new_window (parent, gncOrderGetBook(order), type, order,
|
||||
gncOrderGetOwner (order));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (ow->dialog), "close",
|
||||
GTK_SIGNAL_FUNC (gnc_order_on_close_cb),
|
||||
NULL);
|
||||
|
||||
gtk_main ();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* Functions for order selection widgets */
|
||||
|
||||
static gboolean
|
||||
edit_order_cb (gpointer *order_p, gpointer user_data)
|
||||
{
|
||||
struct _order_select_window *sw = user_data;
|
||||
GncOrder *order;
|
||||
|
||||
g_return_val_if_fail (order_p && user_data, TRUE);
|
||||
@ -816,7 +809,7 @@ edit_order_cb (gpointer *order_p, gpointer user_data)
|
||||
if (!order)
|
||||
return TRUE;
|
||||
|
||||
gnc_order_edit (sw->parent, order);
|
||||
gnc_ui_order_window_create (order);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -923,10 +916,9 @@ gnc_order_select (GtkWidget *parent, GncOrder *start, GncOwner *owner,
|
||||
}
|
||||
|
||||
void
|
||||
gnc_order_find (GtkWidget *parent, GncOrder *start, GncOwner *owner,
|
||||
GNCBook *book)
|
||||
gnc_order_find (GncOrder *start, GncOwner *owner, GNCBook *book)
|
||||
{
|
||||
gnc_order_select (parent, start, owner, book, FALSE);
|
||||
gnc_order_select (NULL, start, owner, book, FALSE);
|
||||
}
|
||||
|
||||
GncOrder *
|
||||
@ -949,6 +941,6 @@ gpointer gnc_order_edit_new_edit (gpointer bookp, gpointer v,
|
||||
|
||||
g_return_val_if_fail (order != NULL, NULL);
|
||||
|
||||
gnc_order_edit (toplevel, order);
|
||||
gnc_ui_order_window_create (order);
|
||||
return order;
|
||||
}
|
||||
|
@ -8,15 +8,19 @@
|
||||
#ifndef GNC_DIALOG_ORDER_H_
|
||||
#define GNC_DIALOG_ORDER_H_
|
||||
|
||||
typedef struct _order_window OrderWindow;
|
||||
|
||||
#include "gncOrder.h"
|
||||
#include "gncOwner.h"
|
||||
|
||||
/* Create an order window */
|
||||
OrderWindow * gnc_ui_order_window_create (GncOrder *order);
|
||||
|
||||
void gnc_order_find (GncOrder *start, GncOwner *owner, GNCBook *book);
|
||||
|
||||
/* Functions to create and edit orders */
|
||||
GncOrder * gnc_order_new (GtkWidget *parent, GncOwner *owner, GNCBook *book);
|
||||
void gnc_order_edit (GtkWidget *parent, GncOrder *order);
|
||||
|
||||
void gnc_order_find (GtkWidget *parent, GncOrder *start, GncOwner *owner,
|
||||
GNCBook *book);
|
||||
GncOrder * gnc_order_choose (GtkWidget *parent, GncOrder *start,
|
||||
GncOwner *owner, GNCBook *book);
|
||||
|
||||
|
@ -543,7 +543,7 @@ invoice_vendor_cb (gpointer *vendor_p, gpointer user_data)
|
||||
return TRUE;
|
||||
|
||||
gncOwnerInitVendor (&owner, vendor);
|
||||
gnc_invoice_find (sw->parent, NULL, &owner, sw->book);
|
||||
gnc_invoice_find (NULL, &owner, sw->book);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -562,7 +562,7 @@ order_vendor_cb (gpointer *vendor_p, gpointer user_data)
|
||||
return TRUE;
|
||||
|
||||
gncOwnerInitVendor (&owner, vendor);
|
||||
gnc_order_find (sw->parent, NULL, &owner, sw->book);
|
||||
gnc_order_find (NULL, &owner, sw->book);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -124,20 +124,19 @@
|
||||
ws
|
||||
'gnc:invoice-edit
|
||||
'<gw:void>
|
||||
"gnc_invoice_edit"
|
||||
'((<gnc:UIWidget> parent) (<gnc:GncInvoice*> invoice))
|
||||
"Dialog: Edit a GncInvoice. Parent may be NULL.")
|
||||
|
||||
"gnc_ui_invoice_window_create"
|
||||
'((<gnc:GncInvoice*> invoice))
|
||||
"Dialog: Edit a GncInvoice.")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:invoice-find
|
||||
'<gw:void>
|
||||
"gnc_invoice_find"
|
||||
'((<gnc:UIWidget> parent) (<gnc:GncInvoice*> start_selection)
|
||||
(<gnc:GncOwner*> owner) (<gnc:Book*> book))
|
||||
"Dialog: Select a GncInvoice. Any of the parent, start_selection, "
|
||||
"and owner may be NULL.")
|
||||
'((<gnc:GncInvoice*> start_selection) (<gnc:GncOwner*> owner)
|
||||
(<gnc:Book*> book))
|
||||
"Dialog: Select a GncInvoice. Either start_selection or "
|
||||
"owner may be NULL.")
|
||||
|
||||
;;
|
||||
;; dialog-job.h
|
||||
@ -189,9 +188,9 @@
|
||||
ws
|
||||
'gnc:order-edit
|
||||
'<gw:void>
|
||||
"gnc_order_edit"
|
||||
'((<gnc:UIWidget> parent) (<gnc:GncOrder*> order))
|
||||
"Dialog: Edit a GncOrder. Parent may be NULL.")
|
||||
"gnc_ui_order_window_create"
|
||||
'((<gnc:GncOrder*> order))
|
||||
"Dialog: Edit a GncOrder.")
|
||||
|
||||
|
||||
(gw:wrap-function
|
||||
@ -199,9 +198,9 @@
|
||||
'gnc:order-find
|
||||
'<gw:void>
|
||||
"gnc_order_find"
|
||||
'((<gnc:UIWidget> parent) (<gnc:GncOrder*> start_selection)
|
||||
(<gnc:GncOwner*> order_owner) (<gnc:Book*> book) )
|
||||
"Dialog: Select a GncOrder. Any of parent, start_selection, and "
|
||||
'((<gnc:GncOrder*> start_selection) (<gnc:GncOwner*> order_owner)
|
||||
(<gnc:Book*> book) )
|
||||
"Dialog: Select a GncOrder. Either start_selection or "
|
||||
"order_owner may be NULL.")
|
||||
|
||||
;;
|
||||
|
@ -56,11 +56,33 @@ static void
|
||||
gnc_entry_ledger_set_watches (GncEntryLedger *ledger, GList *entries)
|
||||
{
|
||||
GList *node;
|
||||
GNCIdType type = NULL;
|
||||
|
||||
gnc_gui_component_clear_watches (ledger->component_id);
|
||||
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_ORDER_VIEWER:
|
||||
type = GNC_ORDER_MODULE_NAME;
|
||||
break;
|
||||
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
/* Watch the invoice owner to see when items get added via orders */
|
||||
gnc_gui_component_watch_entity (ledger->component_id,
|
||||
gncOwnerGetGUID
|
||||
(gncInvoiceGetOwner (ledger->invoice)),
|
||||
GNC_EVENT_MODIFY);
|
||||
case GNCENTRY_INVOICE_VIEWER:
|
||||
type = GNC_INVOICE_MODULE_NAME;
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("Invalid ledger type");
|
||||
break;
|
||||
}
|
||||
|
||||
gnc_gui_component_watch_entity_type (ledger->component_id,
|
||||
GNC_ID_ACCOUNT,
|
||||
type,
|
||||
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
|
||||
|
||||
for (node = entries; node; node = node->next)
|
||||
@ -76,15 +98,8 @@ static void
|
||||
refresh_handler (GHashTable *changes, gpointer user_data)
|
||||
{
|
||||
GncEntryLedger *ledger = user_data;
|
||||
GList *entries;
|
||||
|
||||
if (!ledger || ledger->loading) return;
|
||||
|
||||
entries = gnc_entry_ledger_get_entries (ledger);
|
||||
|
||||
gnc_entry_ledger_set_watches (ledger, entries);
|
||||
|
||||
gnc_entry_ledger_refresh_internal (ledger, entries);
|
||||
gnc_entry_ledger_display_refresh (ledger);
|
||||
}
|
||||
|
||||
void
|
||||
@ -96,7 +111,7 @@ gnc_entry_ledger_display_init (GncEntryLedger *ledger)
|
||||
ledger->component_id = gnc_register_gui_component (ENTRYLEDGER_CLASS,
|
||||
refresh_handler,
|
||||
NULL, ledger);
|
||||
refresh_handler (NULL, ledger);
|
||||
gnc_entry_ledger_display_refresh (ledger);
|
||||
}
|
||||
|
||||
void
|
||||
@ -110,9 +125,13 @@ gnc_entry_ledger_display_fini (GncEntryLedger *ledger)
|
||||
void
|
||||
gnc_entry_ledger_display_refresh (GncEntryLedger *ledger)
|
||||
{
|
||||
if (!ledger || ledger->loading)
|
||||
return;
|
||||
GList *entries;
|
||||
|
||||
gnc_entry_ledger_refresh_internal (ledger,
|
||||
gnc_entry_ledger_get_entries (ledger));
|
||||
if (!ledger || ledger->loading) return;
|
||||
|
||||
entries = gnc_entry_ledger_get_entries (ledger);
|
||||
|
||||
gnc_entry_ledger_set_watches (ledger, entries);
|
||||
|
||||
gnc_entry_ledger_refresh_internal (ledger, entries);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user