mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* Separate Bills and Invoices into (somewhat) different things.
An Entry now has pointers to an Invoice and a Bill, although both are represented by a GncInvoice. Force a GncInvoice to a Bill if the owner is a Vendor. (It's a regular Invoice if the owner is a Customer). Eventually we can support Owner == Employee to deal with Expense Reports. * gncInvoice: add gncBill{Add,Remove}Entry * gncEntry: add gncEntry{Get,Set}Bill * gw-business-core: wrap gncEntryGetBill * gnc-entry-xml-v2: add entry:bill pointer * gncEntryLedger: deal with Bill Entry. Don't need a lot of columns (compared to Invoices). This is not complete, but is at a workable point now. * dialog-invoice: call the BILL vs. INVOICE entry-ledger based on the invoice owner. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7108 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
8bee782dbf
commit
f1314f2ad7
18
ChangeLog
18
ChangeLog
@ -10,6 +10,24 @@
|
||||
"Bill" for vendor reports. Fix the aging table. Reverse the
|
||||
numerics for vendor reports.
|
||||
|
||||
* prefs.scm: change A/P's "Invoice" column header to "Bill"
|
||||
|
||||
* Separate Bills and Invoices into (somewhat) different things.
|
||||
An Entry now has pointers to an Invoice and a Bill, although
|
||||
both are represented by a GncInvoice. Force a GncInvoice to a
|
||||
Bill if the owner is a Vendor. (It's a regular Invoice if the
|
||||
owner is a Customer). Eventually we can support Owner ==
|
||||
Employee to deal with Expense Reports.
|
||||
* gncInvoice: add gncBill{Add,Remove}Entry
|
||||
* gncEntry: add gncEntry{Get,Set}Bill
|
||||
* gw-business-core: wrap gncEntryGetBill
|
||||
* gnc-entry-xml-v2: add entry:bill pointer
|
||||
* gncEntryLedger: deal with Bill Entry. Don't need a lot of
|
||||
columns (compared to Invoices). This is not complete, but is
|
||||
at a workable point now.
|
||||
* dialog-invoice: call the BILL vs. INVOICE entry-ledger based
|
||||
on the invoice owner.
|
||||
|
||||
2002-07-08 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* kvp-option-registry.scm: create a registry of kvp-options
|
||||
|
@ -76,6 +76,7 @@ const gchar *entry_version_string = "2.0.0";
|
||||
#define entry_taxtable_string "entry:taxtable"
|
||||
#define entry_order_string "entry:order"
|
||||
#define entry_invoice_string "entry:invoice"
|
||||
#define entry_bill_string "entry:bill"
|
||||
|
||||
static void
|
||||
maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
|
||||
@ -153,6 +154,11 @@ entry_dom_tree_create (GncEntry *entry)
|
||||
xmlAddChild (ret, guid_to_dom_tree (entry_invoice_string,
|
||||
gncInvoiceGetGUID (invoice)));
|
||||
|
||||
invoice = gncEntryGetBill (entry);
|
||||
if (invoice)
|
||||
xmlAddChild (ret, guid_to_dom_tree (entry_bill_string,
|
||||
gncInvoiceGetGUID (invoice)));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -430,6 +436,27 @@ entry_invoice_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
entry_bill_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
{
|
||||
struct entry_pdata *pdata = entry_pdata;
|
||||
GUID *guid;
|
||||
GncInvoice *invoice;
|
||||
|
||||
guid = dom_tree_to_guid (node);
|
||||
g_return_val_if_fail (guid, FALSE);
|
||||
invoice = gncInvoiceLookup (pdata->book, guid);
|
||||
if (!invoice) {
|
||||
invoice = gncInvoiceCreate (pdata->book);
|
||||
gncInvoiceSetGUID (invoice, guid);
|
||||
}
|
||||
gncBillAddEntry (invoice, pdata->entry);
|
||||
gncInvoiceCommitEdit (invoice);
|
||||
|
||||
g_free(guid);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static struct dom_tree_handler entry_handlers_v2[] = {
|
||||
{ entry_guid_string, entry_guid_handler, 1, 0 },
|
||||
{ entry_date_string, entry_date_handler, 1, 0 },
|
||||
@ -448,6 +475,7 @@ static struct dom_tree_handler entry_handlers_v2[] = {
|
||||
{ entry_taxtable_string, entry_taxtable_handler, 0, 0 },
|
||||
{ entry_order_string, entry_order_handler, 0, 0 },
|
||||
{ entry_invoice_string, entry_invoice_handler, 0, 0 },
|
||||
{ entry_bill_string, entry_bill_handler, 0, 0 },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
@ -542,7 +570,8 @@ xml_add_entry (gpointer entry_p, gpointer out_p)
|
||||
FILE *out = out_p;
|
||||
|
||||
/* Don't save non-attached entries! */
|
||||
if (!(gncEntryGetOrder (entry) || gncEntryGetInvoice (entry)))
|
||||
if (!(gncEntryGetOrder (entry) || gncEntryGetInvoice (entry) ||
|
||||
gncEntryGetBill (entry)))
|
||||
return;
|
||||
|
||||
node = entry_dom_tree_create (entry);
|
||||
|
@ -44,6 +44,7 @@ struct _gncEntry {
|
||||
|
||||
GncOrder * order;
|
||||
GncInvoice * invoice;
|
||||
GncInvoice * bill;
|
||||
|
||||
gnc_numeric value;
|
||||
gnc_numeric value_rounded;
|
||||
@ -274,6 +275,15 @@ void gncEntrySetInvoice (GncEntry *entry, GncInvoice *invoice)
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
/* called from gncInvoice when we're added to the Invoice/Bill */
|
||||
void gncEntrySetBill (GncEntry *entry, GncInvoice *bill)
|
||||
{
|
||||
if (!entry) return;
|
||||
if (entry->bill == bill) return;
|
||||
entry->bill = bill;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetTaxable (GncEntry *entry, gboolean taxable)
|
||||
{
|
||||
if (!entry) return;
|
||||
@ -357,6 +367,9 @@ void gncEntryCopy (const GncEntry *src, GncEntry *dest)
|
||||
if (src->invoice)
|
||||
gncInvoiceAddEntry (src->invoice, dest);
|
||||
|
||||
if (src->bill)
|
||||
gncBillAddEntry (src->bill, dest);
|
||||
|
||||
dest->values_dirty = TRUE;
|
||||
}
|
||||
|
||||
@ -436,6 +449,12 @@ GncInvoice * gncEntryGetInvoice (GncEntry *entry)
|
||||
return entry->invoice;
|
||||
}
|
||||
|
||||
GncInvoice * gncEntryGetBill (GncEntry *entry)
|
||||
{
|
||||
if (!entry) return NULL;
|
||||
return entry->bill;
|
||||
}
|
||||
|
||||
GncOrder * gncEntryGetOrder (GncEntry *entry)
|
||||
{
|
||||
if (!entry) return NULL;
|
||||
@ -683,10 +702,16 @@ void gncEntryComputeValue (gnc_numeric qty, gnc_numeric price,
|
||||
static int
|
||||
get_commodity_denom (GncEntry *entry)
|
||||
{
|
||||
gnc_commodity *c;
|
||||
if (!entry)
|
||||
return 0;
|
||||
if (entry->invoice) {
|
||||
gnc_commodity *c = gncInvoiceGetCommonCommodity (entry->invoice);
|
||||
c = gncInvoiceGetCommonCommodity (entry->invoice);
|
||||
if (c)
|
||||
return (gnc_commodity_get_fraction (c));
|
||||
}
|
||||
if (entry->bill) {
|
||||
c = gncInvoiceGetCommonCommodity (entry->bill);
|
||||
if (c)
|
||||
return (gnc_commodity_get_fraction (c));
|
||||
}
|
||||
@ -851,7 +876,7 @@ static void _gncEntryForeach (GNCBook *book, foreachObjectCB cb,
|
||||
static GncObject_t gncEntryDesc = {
|
||||
GNC_OBJECT_VERSION,
|
||||
_GNC_MOD_NAME,
|
||||
"Order/Invoice Entry",
|
||||
"Order/Invoice/Bill Entry",
|
||||
_gncEntryCreate,
|
||||
_gncEntryDestroy,
|
||||
_gncEntryIsDirty,
|
||||
@ -871,6 +896,7 @@ gboolean gncEntryRegister (void)
|
||||
{ ENTRY_QTY, QUERYCORE_NUMERIC, (QueryAccess)gncEntryGetQuantity },
|
||||
{ ENTRY_PRICE, QUERYCORE_NUMERIC, (QueryAccess)gncEntryGetPrice },
|
||||
{ ENTRY_INVOICE, GNC_INVOICE_MODULE_NAME, (QueryAccess)gncEntryGetInvoice },
|
||||
{ ENTRY_BILL, GNC_INVOICE_MODULE_NAME, (QueryAccess)gncEntryGetBill },
|
||||
{ ENTRY_ORDER, GNC_ORDER_MODULE_NAME, (QueryAccess)gncEntryGetOrder },
|
||||
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncEntryGetBook },
|
||||
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncEntryGetGUID },
|
||||
|
@ -111,6 +111,7 @@ Account * gncEntryGetAccount (GncEntry *entry);
|
||||
|
||||
GncOrder * gncEntryGetOrder (GncEntry *entry);
|
||||
GncInvoice * gncEntryGetInvoice (GncEntry *entry);
|
||||
GncInvoice * gncEntryGetBill (GncEntry *entry);
|
||||
|
||||
GncEntry * gncEntryLookup (GNCBook *book, const GUID *guid);
|
||||
|
||||
@ -127,5 +128,6 @@ int gncEntryCompare (GncEntry *a, GncEntry *b);
|
||||
|
||||
#define ENTRY_ORDER "order"
|
||||
#define ENTRY_INVOICE "invoice"
|
||||
#define ENTRY_BILL "bill"
|
||||
|
||||
#endif /* GNC_ENTRY_H_ */
|
||||
|
@ -13,6 +13,7 @@ gboolean gncEntryRegister (void);
|
||||
void gncEntrySetGUID (GncEntry *entry, const GUID *guid);
|
||||
void gncEntrySetOrder (GncEntry *entry, GncOrder *order);
|
||||
void gncEntrySetInvoice (GncEntry *entry, GncInvoice *invoice);
|
||||
void gncEntrySetBill (GncEntry *entry, GncInvoice *bill);
|
||||
void gncEntrySetDirty (GncEntry *entry, gboolean dirty);
|
||||
|
||||
#endif /* GNC_ENTRYP_H_ */
|
||||
|
@ -269,6 +269,31 @@ void gncInvoiceRemoveEntry (GncInvoice *invoice, GncEntry *entry)
|
||||
mark_invoice (invoice);
|
||||
}
|
||||
|
||||
void gncBillAddEntry (GncInvoice *bill, GncEntry *entry)
|
||||
{
|
||||
GncInvoice *old;
|
||||
|
||||
if (!bill || !entry) return;
|
||||
|
||||
old = gncEntryGetBill (entry);
|
||||
if (old == bill) return; /* I already own this one */
|
||||
if (old) gncBillRemoveEntry (old, entry);
|
||||
|
||||
gncEntrySetBill (entry, bill);
|
||||
bill->entries = g_list_insert_sorted (bill->entries, entry,
|
||||
(GCompareFunc)gncEntryCompare);
|
||||
mark_invoice (bill);
|
||||
}
|
||||
|
||||
void gncBillRemoveEntry (GncInvoice *bill, GncEntry *entry)
|
||||
{
|
||||
if (!bill || !entry) return;
|
||||
|
||||
gncEntrySetBill (entry, NULL);
|
||||
bill->entries = g_list_remove (bill->entries, entry);
|
||||
mark_invoice (bill);
|
||||
}
|
||||
|
||||
/* Get Functions */
|
||||
|
||||
GNCBook * gncInvoiceGetBook (GncInvoice *invoice)
|
||||
|
@ -37,6 +37,10 @@ void gncInvoiceSetActive (GncInvoice *invoice, gboolean active);
|
||||
void gncInvoiceAddEntry (GncInvoice *invoice, GncEntry *entry);
|
||||
void gncInvoiceRemoveEntry (GncInvoice *invoice, GncEntry *entry);
|
||||
|
||||
/* Call this function when adding an entry to a bill instead of an invoice */
|
||||
void gncBillAddEntry (GncInvoice *bill, GncEntry *entry);
|
||||
void gncBillRemoveEntry (GncInvoice *bill, GncEntry *entry);
|
||||
|
||||
/* Get Functions */
|
||||
|
||||
GNCBook * gncInvoiceGetBook (GncInvoice *invoice);
|
||||
|
@ -433,6 +433,14 @@
|
||||
'((<gnc:GncEntry*> entry))
|
||||
"Return the Entry's Invoice")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:entry-get-bill
|
||||
'<gnc:GncInvoice*>
|
||||
"gncEntryGetBill"
|
||||
'((<gnc:GncEntry*> entry))
|
||||
"Return the Entry's Bill")
|
||||
|
||||
(gw:wrap-function
|
||||
ws
|
||||
'gnc:entry-get-order
|
||||
|
@ -162,7 +162,8 @@ void gnc_invoice_window_sort_price_cb (GtkWidget *widget, gpointer data);
|
||||
void gnc_invoice_window_toolbar_cb (GtkWidget *widget, gpointer data);
|
||||
void gnc_invoice_window_statusbar_cb (GtkWidget *widget, gpointer data);
|
||||
|
||||
#define WIDTH_PREFIX "invoice_reg"
|
||||
#define INV_WIDTH_PREFIX "invoice_reg"
|
||||
#define BILL_WIDTH_PREFIX "bill_reg"
|
||||
static int last_width = 0;
|
||||
|
||||
static void gnc_invoice_update_window (InvoiceWindow *iw);
|
||||
@ -791,12 +792,27 @@ gnc_invoice_window_create_popup_menu (InvoiceWindow *iw)
|
||||
return popup;
|
||||
}
|
||||
|
||||
static char *
|
||||
gnc_invoice_get_width_prefix (InvoiceWindow *iw)
|
||||
{
|
||||
switch (gncOwnerGetType (&iw->owner)) {
|
||||
case GNC_OWNER_CUSTOMER:
|
||||
return INV_WIDTH_PREFIX;
|
||||
case GNC_OWNER_VENDOR:
|
||||
return BILL_WIDTH_PREFIX;
|
||||
default:
|
||||
g_warning ("invalid owner");
|
||||
return INV_WIDTH_PREFIX;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_invoice_save_size (InvoiceWindow *iw)
|
||||
{
|
||||
gdk_window_get_geometry (iw->dialog->window, NULL, NULL, &last_width,
|
||||
NULL, NULL);
|
||||
gnc_save_window_size (WIDTH_PREFIX, last_width, 0);
|
||||
|
||||
gnc_save_window_size (gnc_invoice_get_width_prefix (iw), last_width, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1122,7 +1138,8 @@ gnc_invoice_update_window (InvoiceWindow *iw)
|
||||
case VIEW_INVOICE:
|
||||
case EDIT_INVOICE:
|
||||
if (last_width == 0)
|
||||
gnc_get_window_size (WIDTH_PREFIX, &last_width, NULL);
|
||||
gnc_get_window_size (gnc_invoice_get_width_prefix (iw), &last_width,
|
||||
NULL);
|
||||
|
||||
gtk_window_set_default_size (GTK_WINDOW (iw->dialog), last_width, 0);
|
||||
break;
|
||||
@ -1304,6 +1321,8 @@ gnc_invoice_new_window (GNCBook *bookp, InvoiceDialogType type,
|
||||
GladeXML *xml;
|
||||
GtkWidget *hbox;
|
||||
GncEntryLedger *entry_ledger = NULL;
|
||||
GncOwnerType owner_type;
|
||||
GncEntryLedgerType ledger_type;
|
||||
|
||||
g_assert (type != NEW_INVOICE && type != MOD_INVOICE);
|
||||
|
||||
@ -1336,6 +1355,7 @@ gnc_invoice_new_window (GNCBook *bookp, InvoiceDialogType type,
|
||||
/* Save this for later */
|
||||
gncOwnerCopy (gncOwnerGetEndOwner (owner), &(iw->owner));
|
||||
gncOwnerInitJob (&(iw->job), gncOwnerGetJob (owner));
|
||||
owner_type = gncOwnerGetType (&iw->owner);
|
||||
|
||||
/* Find the dialog */
|
||||
iw->xml = xml = gnc_glade_xml_new ("invoice.glade", "Invoice Entry Window");
|
||||
@ -1391,15 +1411,34 @@ gnc_invoice_new_window (GNCBook *bookp, InvoiceDialogType type,
|
||||
gtk_widget_set_sensitive (iw->posted_date, FALSE);
|
||||
|
||||
/* Build the ledger */
|
||||
ledger_type = GNCENTRY_INVOICE_VIEWER;
|
||||
switch (type) {
|
||||
case EDIT_INVOICE:
|
||||
entry_ledger = gnc_entry_ledger_new (iw->book, GNCENTRY_INVOICE_ENTRY);
|
||||
switch (owner_type) {
|
||||
case GNC_OWNER_CUSTOMER:
|
||||
ledger_type = GNCENTRY_INVOICE_ENTRY;
|
||||
break;
|
||||
case GNC_OWNER_VENDOR:
|
||||
ledger_type = GNCENTRY_BILL_ENTRY;
|
||||
break;
|
||||
default:
|
||||
g_warning ("Invalid owner type");
|
||||
}
|
||||
break;
|
||||
case VIEW_INVOICE:
|
||||
default:
|
||||
entry_ledger = gnc_entry_ledger_new (iw->book, GNCENTRY_INVOICE_VIEWER);
|
||||
break;
|
||||
switch (owner_type) {
|
||||
case GNC_OWNER_CUSTOMER:
|
||||
ledger_type = GNCENTRY_INVOICE_VIEWER;
|
||||
break;
|
||||
case GNC_OWNER_VENDOR:
|
||||
ledger_type = GNCENTRY_BILL_VIEWER;
|
||||
break;
|
||||
default:
|
||||
g_warning ("Invalid owner type");
|
||||
}
|
||||
}
|
||||
entry_ledger = gnc_entry_ledger_new (iw->book, ledger_type);
|
||||
|
||||
/* Save the ledger... */
|
||||
iw->ledger = entry_ledger;
|
||||
|
@ -307,6 +307,7 @@ void gnc_entry_ledger_set_default_order (GncEntryLedger *ledger,
|
||||
static void create_invoice_query (GncEntryLedger *ledger)
|
||||
{
|
||||
QueryNew *q, *q1;
|
||||
char * type = NULL;
|
||||
|
||||
if (!ledger->invoice)
|
||||
return;
|
||||
@ -321,6 +322,8 @@ static void create_invoice_query (GncEntryLedger *ledger)
|
||||
* 3. ( Entry->Invoice == NULL AND
|
||||
* Entry->Order->real-parent == Invoice->parent ) )
|
||||
*
|
||||
* Param 2 uses Entry->Bill if the ledger->invoice->owner is a Vendor
|
||||
*
|
||||
* Note that term 3 is only for Editable invoices where the 'owner'
|
||||
* is valid.
|
||||
*/
|
||||
@ -328,13 +331,28 @@ static void create_invoice_query (GncEntryLedger *ledger)
|
||||
/* Term 1 */
|
||||
ledger->query = gncQueryCreateFor (GNC_ENTRY_MODULE_NAME);
|
||||
gncQuerySetBook (ledger->query, gncInvoiceGetBook (ledger->invoice));
|
||||
|
||||
|
||||
/* Term 2 */
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
case GNCENTRY_INVOICE_VIEWER:
|
||||
type = ENTRY_INVOICE;
|
||||
break;
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
case GNCENTRY_BILL_VIEWER:
|
||||
type = ENTRY_BILL;
|
||||
break;
|
||||
default:
|
||||
g_warning ("Invalid Ledger type");
|
||||
type = ENTRY_INVOICE;
|
||||
break;
|
||||
}
|
||||
|
||||
q = gncQueryCreateFor (GNC_ENTRY_MODULE_NAME);
|
||||
gncQueryAddGUIDMatch (q,
|
||||
g_slist_prepend (g_slist_prepend (NULL,
|
||||
QUERY_PARAM_GUID),
|
||||
ENTRY_INVOICE),
|
||||
type),
|
||||
gncInvoiceGetGUID (ledger->invoice), QUERY_OR);
|
||||
|
||||
/* Term 3 */
|
||||
@ -346,7 +364,7 @@ static void create_invoice_query (GncEntryLedger *ledger)
|
||||
gncQueryAddGUIDMatch (q2,
|
||||
g_slist_prepend (g_slist_prepend (NULL,
|
||||
QUERY_PARAM_GUID),
|
||||
ENTRY_INVOICE),
|
||||
type),
|
||||
NULL, QUERY_OR);
|
||||
|
||||
/* entry_order->owner->end_guid == invoice->owner->guid */
|
||||
@ -434,6 +452,10 @@ void gnc_entry_ledger_set_readonly (GncEntryLedger *ledger)
|
||||
ledger->type = GNCENTRY_INVOICE_VIEWER;
|
||||
create_invoice_query (ledger);
|
||||
break;
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
ledger->type = GNCENTRY_BILL_VIEWER;
|
||||
create_invoice_query (ledger);
|
||||
break;
|
||||
default:
|
||||
return; /* Nothing to do */
|
||||
}
|
||||
@ -580,6 +602,10 @@ gnc_entry_ledger_delete_current_entry (GncEntryLedger *ledger)
|
||||
if (invoice)
|
||||
gncInvoiceRemoveEntry (invoice, entry);
|
||||
|
||||
invoice = gncEntryGetBill (entry);
|
||||
if (invoice)
|
||||
gncBillRemoveEntry (invoice, entry);
|
||||
|
||||
gncEntryDestroy (entry);
|
||||
/* XXX: Commit the deletion? */
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ typedef enum {
|
||||
GNCENTRY_ORDER_VIEWER,
|
||||
GNCENTRY_INVOICE_ENTRY,
|
||||
GNCENTRY_INVOICE_VIEWER,
|
||||
GNCENTRY_BILL_ENTRY,
|
||||
GNCENTRY_BILL_VIEWER,
|
||||
GNCENTRY_NUM_REGISTER_TYPES
|
||||
} GncEntryLedgerType;
|
||||
|
||||
|
@ -71,6 +71,10 @@ gnc_entry_ledger_save (GncEntryLedger *ledger, gboolean do_commit)
|
||||
/* Anything entered on an invoice entry must be part of the invoice! */
|
||||
gncInvoiceAddEntry (ledger->invoice, blank_entry);
|
||||
break;
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
/* Anything entered on an invoice entry must be part of the invoice! */
|
||||
gncBillAddEntry (ledger->invoice, blank_entry);
|
||||
break;
|
||||
default:
|
||||
/* Nothing to do for viewers */
|
||||
g_warning ("blank entry traversed in a viewer");
|
||||
@ -206,6 +210,7 @@ gnc_entry_ledger_auto_completion (GncEntryLedger *ledger,
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
|
||||
/* There must be a blank entry */
|
||||
if (blank_entry == NULL)
|
||||
|
@ -44,7 +44,8 @@ gnc_entry_ledger_refresh_internal (GncEntryLedger *ledger, GList *entries)
|
||||
|
||||
/* Viewers must always have at least one entry! */
|
||||
if ((ledger->type == GNCENTRY_ORDER_VIEWER ||
|
||||
ledger->type == GNCENTRY_INVOICE_VIEWER) && !entries)
|
||||
ledger->type == GNCENTRY_INVOICE_VIEWER ||
|
||||
ledger->type == GNCENTRY_BILL_VIEWER) && !entries)
|
||||
return;
|
||||
|
||||
ledger->loading = TRUE;
|
||||
@ -73,6 +74,8 @@ gnc_entry_ledger_set_watches (GncEntryLedger *ledger, GList *entries)
|
||||
(gncInvoiceGetOwner (ledger->invoice)),
|
||||
GNC_EVENT_MODIFY);
|
||||
case GNCENTRY_INVOICE_VIEWER:
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
case GNCENTRY_BILL_VIEWER:
|
||||
type = GNC_INVOICE_MODULE_NAME;
|
||||
break;
|
||||
|
||||
|
@ -104,6 +104,10 @@ static void gnc_entry_ledger_layout_add_cursors (GncEntryLedger *ledger,
|
||||
case GNCENTRY_INVOICE_VIEWER:
|
||||
num_cols = 15;
|
||||
break;
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
case GNCENTRY_BILL_VIEWER:
|
||||
num_cols = 9;
|
||||
break;
|
||||
default:
|
||||
g_assert (FALSE);
|
||||
return;
|
||||
@ -147,6 +151,22 @@ static void gnc_entry_ledger_set_cells (GncEntryLedger *ledger,
|
||||
|
||||
break;
|
||||
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
case GNCENTRY_BILL_VIEWER:
|
||||
|
||||
curs = gnc_table_layout_get_cursor (layout, "cursor");
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_INV_CELL, 0, 0);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_DATE_CELL, 0, 1);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_DESC_CELL, 0, 2);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_ACTN_CELL, 0, 3);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_ACCT_CELL, 0, 4);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_QTY_CELL, 0, 5);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_PRIC_CELL, 0, 6);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_VALUE_CELL, 0, 7);
|
||||
gnc_table_layout_set_cell (layout, curs, ENTRY_TAXVAL_CELL, 0, 8);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert (FALSE);
|
||||
return;
|
||||
|
@ -189,6 +189,7 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
blank_entry = gncEntryCreate (ledger->book);
|
||||
gncEntrySetDate (blank_entry, ledger->last_date_entered);
|
||||
ledger->blank_entry_guid = *gncEntryGetGUID (blank_entry);
|
||||
|
@ -624,6 +624,8 @@ static char * get_inv_help (VirtualLocation virt_loc, gpointer user_data)
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_ORDER_VIEWER:
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
case GNCENTRY_BILL_VIEWER:
|
||||
help = _("Is this entry Invoiced?");
|
||||
break;
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
@ -669,6 +671,7 @@ static CellIOFlags get_standard_io_flags (VirtualLocation virt_loc,
|
||||
GncEntryLedger *ledger = user_data;
|
||||
switch (ledger->type) {
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
{
|
||||
GncEntry *entry =
|
||||
gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
|
||||
@ -702,6 +705,8 @@ static CellIOFlags get_inv_io_flags (VirtualLocation virt_loc,
|
||||
case GNCENTRY_ORDER_ENTRY:
|
||||
case GNCENTRY_ORDER_VIEWER:
|
||||
case GNCENTRY_INVOICE_VIEWER:
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
case GNCENTRY_BILL_VIEWER:
|
||||
return XACC_CELL_ALLOW_SHADOW;
|
||||
default:
|
||||
return XACC_CELL_ALLOW_ALL | XACC_CELL_ALLOW_EXACT_ONLY;
|
||||
@ -905,7 +910,7 @@ static void gnc_entry_ledger_save_cells (gpointer save_data,
|
||||
gncEntrySetTaxIncluded (entry, taxincluded);
|
||||
}
|
||||
|
||||
{
|
||||
if (ledger->type == GNCENTRY_INVOICE_ENTRY) {
|
||||
char inv_value;
|
||||
|
||||
inv_value = gnc_entry_ledger_get_inv (ledger, ENTRY_INV_CELL);
|
||||
@ -921,8 +926,9 @@ static void gnc_entry_ledger_save_cells (gpointer save_data,
|
||||
gncInvoiceAddEntry (ledger->invoice, entry);
|
||||
|
||||
} else {
|
||||
/* Remove from the invoice iff we're attached to an order */
|
||||
if (gncEntryGetOrder (entry) != NULL)
|
||||
/* Remove from the invoice iff we're attached to an order or bill */
|
||||
if ((gncEntryGetOrder (entry) != NULL) ||
|
||||
(gncEntryGetBill (entry) != NULL))
|
||||
gncInvoiceRemoveEntry (ledger->invoice, entry);
|
||||
}
|
||||
}
|
||||
@ -989,6 +995,7 @@ static void gnc_entry_ledger_model_new_handlers (TableModel *model,
|
||||
switch (type) {
|
||||
case GNCENTRY_ORDER_VIEWER:
|
||||
case GNCENTRY_INVOICE_VIEWER:
|
||||
case GNCENTRY_BILL_VIEWER:
|
||||
/* make this table read-only */
|
||||
gnc_table_model_set_read_only (model, TRUE);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user