mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Some const correctness improvements in owner and invoice functions
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21411 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
e409352c65
commit
012ab52a07
@ -56,7 +56,7 @@ const gchar *owner_version_string = "2.0.0";
|
||||
#define owner_id_string "owner:id"
|
||||
|
||||
xmlNodePtr
|
||||
gnc_owner_to_dom_tree (const char *tag, GncOwner *owner)
|
||||
gnc_owner_to_dom_tree (const char *tag, const GncOwner *owner)
|
||||
{
|
||||
xmlNodePtr ret;
|
||||
const char *type_str;
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
gboolean gnc_dom_tree_to_owner (xmlNodePtr node, GncOwner *owner,
|
||||
QofBook *book);
|
||||
xmlNodePtr gnc_owner_to_dom_tree (const char *tag, GncOwner *addr);
|
||||
xmlNodePtr gnc_owner_to_dom_tree (const char *tag, const GncOwner *addr);
|
||||
void gnc_owner_xml_initialize (void);
|
||||
|
||||
#endif /* GNC_OWNER_XML_V2_H */
|
||||
|
@ -204,19 +204,12 @@ 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);
|
||||
}
|
||||
owner_type = gncOwnerGetType(gncOwnerGetEndOwner(&isi->owner));
|
||||
|
||||
/* Translators: See comments in dialog-invoice.c:gnc_invoice_search() */
|
||||
switch (owner_type)
|
||||
|
@ -1480,7 +1480,7 @@ gnc_invoice_window_refresh_handler (GHashTable *changes, gpointer user_data)
|
||||
InvoiceWindow *iw = user_data;
|
||||
const EventInfo *info;
|
||||
GncInvoice *invoice = iw_get_invoice (iw);
|
||||
GncOwner *owner;
|
||||
const GncOwner *owner;
|
||||
|
||||
/* If there isn't an invoice behind us, close down */
|
||||
if (!invoice)
|
||||
@ -1840,7 +1840,7 @@ find_handler (gpointer find_data, gpointer user_data)
|
||||
|
||||
static InvoiceWindow *
|
||||
gnc_invoice_new_page (QofBook *bookp, InvoiceDialogType type,
|
||||
GncInvoice *invoice, GncOwner *owner,
|
||||
GncInvoice *invoice, const GncOwner *owner,
|
||||
GncMainWindow *window)
|
||||
{
|
||||
InvoiceWindow *iw;
|
||||
@ -2198,13 +2198,14 @@ gnc_invoice_create_page (InvoiceWindow *iw, gpointer page)
|
||||
}
|
||||
|
||||
static InvoiceWindow *
|
||||
gnc_invoice_window_new_invoice (QofBook *bookp, GncOwner *owner,
|
||||
gnc_invoice_window_new_invoice (QofBook *bookp, const GncOwner *owner,
|
||||
GncInvoice *invoice)
|
||||
{
|
||||
InvoiceWindow *iw;
|
||||
GladeXML *xml;
|
||||
GtkWidget *hbox;
|
||||
GncOwner *billto;
|
||||
const GncOwner *start_owner;
|
||||
|
||||
if (invoice)
|
||||
{
|
||||
@ -2236,17 +2237,18 @@ gnc_invoice_window_new_invoice (QofBook *bookp, GncOwner *owner,
|
||||
invoice = gncInvoiceCreate (bookp);
|
||||
gncInvoiceSetCurrency (invoice, gnc_default_currency ());
|
||||
iw->book = bookp;
|
||||
start_owner = owner;
|
||||
}
|
||||
else
|
||||
{
|
||||
iw->dialog_type = MOD_INVOICE;
|
||||
owner = gncInvoiceGetOwner (invoice);
|
||||
start_owner = gncInvoiceGetOwner (invoice);
|
||||
iw->book = gncInvoiceGetBook (invoice);
|
||||
}
|
||||
|
||||
/* Save this for later */
|
||||
gncOwnerCopy (gncOwnerGetEndOwner(owner), &(iw->owner));
|
||||
gncOwnerInitJob (&(iw->job), gncOwnerGetJob (owner));
|
||||
gncOwnerCopy (gncOwnerGetEndOwner(start_owner), &(iw->owner));
|
||||
gncOwnerInitJob (&(iw->job), gncOwnerGetJob (start_owner));
|
||||
|
||||
billto = gncInvoiceGetBillTo (invoice);
|
||||
gncOwnerCopy (gncOwnerGetEndOwner (billto), &(iw->proj_cust));
|
||||
@ -2677,15 +2679,8 @@ gnc_invoice_search (GncInvoice *start, GncOwner *owner, QofBook *book)
|
||||
*/
|
||||
if (owner)
|
||||
{
|
||||
GncOwner *tmp = owner;
|
||||
|
||||
/* First, figure out the type of owner here.. */
|
||||
owner_type = gncOwnerGetType(owner);
|
||||
while (owner_type == GNC_OWNER_JOB)
|
||||
{
|
||||
tmp = gncOwnerGetEndOwner(tmp);
|
||||
owner_type = gncOwnerGetType(tmp);
|
||||
}
|
||||
owner_type = gncOwnerGetType (gncOwnerGetEndOwner (owner));
|
||||
|
||||
/* Then if there's an actual owner add it to the query
|
||||
* and limit the search to this owner
|
||||
@ -2771,34 +2766,6 @@ gnc_invoice_search (GncInvoice *start, GncOwner *owner, QofBook *book)
|
||||
label);
|
||||
}
|
||||
|
||||
GNCSearchWindow *
|
||||
gnc_invoice_search_select (gpointer start, gpointer book)
|
||||
{
|
||||
GncInvoice *i = start;
|
||||
GncOwner owner, *ownerp;
|
||||
|
||||
if (!book) return NULL;
|
||||
|
||||
if (i)
|
||||
{
|
||||
ownerp = gncInvoiceGetOwner (i);
|
||||
gncOwnerCopy (ownerp, &owner);
|
||||
}
|
||||
else
|
||||
gncOwnerInitCustomer (&owner, NULL); /* XXX */
|
||||
|
||||
return gnc_invoice_search (start, NULL, book);
|
||||
}
|
||||
|
||||
GNCSearchWindow *
|
||||
gnc_invoice_search_edit (gpointer start, gpointer book)
|
||||
{
|
||||
if (start)
|
||||
gnc_ui_invoice_edit (start);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DialogQueryList *
|
||||
gnc_invoice_show_bills_due (QofBook *book, double days_in_advance)
|
||||
{
|
||||
|
@ -59,15 +59,6 @@ InvoiceWindow * gnc_ui_invoice_duplicate (GncInvoice *invoice);
|
||||
/* Search for invoices */
|
||||
GNCSearchWindow * gnc_invoice_search (GncInvoice *start, GncOwner *owner, QofBook *book);
|
||||
|
||||
/*
|
||||
* These callbacks are for use with the gnc_general_search widget
|
||||
*
|
||||
* select() provides a Select Dialog and returns it.
|
||||
* edit() opens the existing invoice for editing and returns NULL.
|
||||
*/
|
||||
GNCSearchWindow * gnc_invoice_search_select (gpointer start, gpointer book);
|
||||
GNCSearchWindow * gnc_invoice_search_edit (gpointer start, gpointer book);
|
||||
|
||||
void gnc_business_call_owner_report (GncOwner *owner, Account *acc);
|
||||
|
||||
void gnc_invoice_window_sort (InvoiceWindow *iw, invoice_sort_type_t sort_code);
|
||||
|
@ -706,7 +706,7 @@ gnc_ui_payment_window_destroy (PaymentWindow *pw)
|
||||
}
|
||||
|
||||
PaymentWindow *
|
||||
gnc_ui_payment_new_with_invoice (GncOwner *owner, QofBook *book,
|
||||
gnc_ui_payment_new_with_invoice (const GncOwner *owner, QofBook *book,
|
||||
GncInvoice *invoice)
|
||||
{
|
||||
GncOwner owner_def;
|
||||
@ -715,15 +715,14 @@ gnc_ui_payment_new_with_invoice (GncOwner *owner, QofBook *book,
|
||||
if (owner)
|
||||
{
|
||||
/* Figure out the company */
|
||||
owner = gncOwnerGetEndOwner (owner);
|
||||
gncOwnerCopy (gncOwnerGetEndOwner (owner), &owner_def);
|
||||
}
|
||||
else
|
||||
{
|
||||
gncOwnerInitCustomer (&owner_def, NULL);
|
||||
owner = &owner_def;
|
||||
}
|
||||
|
||||
return new_payment_window (owner, book, invoice);
|
||||
return new_payment_window (&owner_def, book, invoice);
|
||||
}
|
||||
|
||||
PaymentWindow *
|
||||
|
@ -31,7 +31,7 @@ typedef struct _payment_window PaymentWindow;
|
||||
|
||||
/* Create a payment window */
|
||||
PaymentWindow * gnc_ui_payment_new (GncOwner *owner, QofBook *book);
|
||||
PaymentWindow * gnc_ui_payment_new_with_invoice (GncOwner *owner,
|
||||
PaymentWindow * gnc_ui_payment_new_with_invoice (const GncOwner *owner,
|
||||
QofBook *book,
|
||||
GncInvoice *invoice);
|
||||
PaymentWindow * gnc_ui_payment_new_with_txn (GncOwner *owner, Transaction *txn);
|
||||
|
@ -141,7 +141,7 @@ gnc_entry_ledger_set_watches (GncEntryLedger *ledger, GList *entries)
|
||||
/* For expense vouchers, watch the employee and refresh if it's changed */
|
||||
if (ledger->type == GNCENTRY_EXPVOUCHER_ENTRY)
|
||||
{
|
||||
GncOwner *owner = gncOwnerGetEndOwner (gncInvoiceGetOwner (ledger->invoice));
|
||||
const GncOwner *owner = gncOwnerGetEndOwner (gncInvoiceGetOwner (ledger->invoice));
|
||||
GncEmployee *employee = gncOwnerGetEmployee (owner);
|
||||
|
||||
if (employee)
|
||||
|
@ -108,7 +108,7 @@ static void load_discount_how_cells (GncEntryLedger *ledger)
|
||||
static void load_payment_type_cells (GncEntryLedger *ledger)
|
||||
{
|
||||
ComboCell *cell;
|
||||
GncOwner *owner;
|
||||
const GncOwner *owner;
|
||||
GncEmployee *employee;
|
||||
|
||||
cell = (ComboCell *) gnc_table_layout_get_cell (ledger->table->layout,
|
||||
@ -356,7 +356,7 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
|
||||
/* The rest of this does not apply to expense vouchers */
|
||||
if (ledger->type != GNCENTRY_EXPVOUCHER_ENTRY)
|
||||
{
|
||||
GncOwner *owner = gncInvoiceGetOwner (ledger->invoice);
|
||||
const GncOwner *owner = gncInvoiceGetOwner (ledger->invoice);
|
||||
GncTaxTable *table = NULL;
|
||||
GncTaxIncluded taxincluded_p = GNC_TAXINCLUDED_USEGLOBAL;
|
||||
gboolean taxincluded = FALSE;
|
||||
@ -364,8 +364,7 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
|
||||
GNCOptionDB *odb;
|
||||
|
||||
/* Determine the TaxIncluded and Discount values */
|
||||
owner = gncOwnerGetEndOwner (owner);
|
||||
switch (gncOwnerGetType (owner))
|
||||
switch (gncOwnerGetType (gncOwnerGetEndOwner (owner)))
|
||||
{
|
||||
case GNC_OWNER_CUSTOMER:
|
||||
taxincluded_p = gncCustomerGetTaxIncluded (owner->owner.customer);
|
||||
|
@ -696,7 +696,7 @@ const char * gncInvoiceGetID (const GncInvoice *invoice)
|
||||
return invoice->id;
|
||||
}
|
||||
|
||||
GncOwner * gncInvoiceGetOwner (GncInvoice *invoice)
|
||||
const GncOwner * gncInvoiceGetOwner (const GncInvoice *invoice)
|
||||
{
|
||||
if (!invoice) return NULL;
|
||||
return &invoice->owner;
|
||||
@ -776,7 +776,7 @@ const char * gncInvoiceGetNotes (const GncInvoice *invoice)
|
||||
return invoice->notes;
|
||||
}
|
||||
|
||||
GncOwnerType gncInvoiceGetOwnerType (GncInvoice *invoice)
|
||||
GncOwnerType gncInvoiceGetOwnerType (const GncInvoice *invoice)
|
||||
{
|
||||
const GncOwner *owner;
|
||||
g_return_val_if_fail (invoice, GNC_OWNER_NONE);
|
||||
@ -877,7 +877,7 @@ GList * gncInvoiceGetTypeListForOwnerType (GncOwnerType type)
|
||||
|
||||
}
|
||||
|
||||
GncInvoiceType gncInvoiceGetType (GncInvoice *invoice)
|
||||
GncInvoiceType gncInvoiceGetType (const GncInvoice *invoice)
|
||||
{
|
||||
if (!invoice) return GNC_INVOICE_UNDEFINED;
|
||||
switch (gncInvoiceGetOwnerType (invoice))
|
||||
@ -893,7 +893,7 @@ GncInvoiceType gncInvoiceGetType (GncInvoice *invoice)
|
||||
}
|
||||
}
|
||||
|
||||
const char * gncInvoiceGetTypeString (GncInvoice *invoice)
|
||||
const char * gncInvoiceGetTypeString (const GncInvoice *invoice)
|
||||
{
|
||||
GncInvoiceType type = gncInvoiceGetType(invoice);
|
||||
switch (type)
|
||||
@ -1154,7 +1154,7 @@ gncInvoiceGetInvoiceFromTxn (const Transaction *txn)
|
||||
return gncInvoiceLookup(book, guid);
|
||||
}
|
||||
|
||||
gboolean gncInvoiceAmountPositive (GncInvoice *invoice)
|
||||
gboolean gncInvoiceAmountPositive (const GncInvoice *invoice)
|
||||
{
|
||||
switch (gncInvoiceGetType (invoice))
|
||||
{
|
||||
@ -1174,7 +1174,7 @@ gboolean gncInvoiceAmountPositive (GncInvoice *invoice)
|
||||
|
||||
struct lotmatch
|
||||
{
|
||||
GncOwner *owner;
|
||||
const GncOwner *owner;
|
||||
gboolean positive_balance;
|
||||
};
|
||||
|
||||
@ -1182,7 +1182,8 @@ static gboolean
|
||||
gnc_lot_match_owner_payment (GNCLot *lot, gpointer user_data)
|
||||
{
|
||||
struct lotmatch *lm = user_data;
|
||||
GncOwner owner_def, *owner;
|
||||
GncOwner owner_def;
|
||||
const GncOwner *owner;
|
||||
gnc_numeric balance = gnc_lot_get_balance (lot);
|
||||
|
||||
/* Is this a payment lot */
|
||||
@ -1217,7 +1218,7 @@ Transaction * gncInvoicePostToAccount (GncInvoice *invoice, Account *acc,
|
||||
const char *name, *type;
|
||||
char *lot_title;
|
||||
Account *ccard_acct = NULL;
|
||||
GncOwner *owner;
|
||||
const GncOwner *owner;
|
||||
|
||||
if (!invoice || !acc) return NULL;
|
||||
|
||||
@ -1964,7 +1965,7 @@ gboolean gncInvoiceRegister (void)
|
||||
return qof_object_register (&gncInvoiceDesc);
|
||||
}
|
||||
|
||||
gchar *gncInvoiceNextID (QofBook *book, GncOwner *owner)
|
||||
gchar *gncInvoiceNextID (QofBook *book, const GncOwner *owner)
|
||||
{
|
||||
gchar *nextID;
|
||||
switch (gncOwnerGetType(gncOwnerGetEndOwner(owner)))
|
||||
|
@ -129,17 +129,17 @@ void gncInvoiceSortEntries (GncInvoice *invoice);
|
||||
/** @name Get Functions
|
||||
@{ */
|
||||
const char * gncInvoiceGetID (const GncInvoice *invoice);
|
||||
GncOwner * gncInvoiceGetOwner (GncInvoice *invoice);
|
||||
const GncOwner * gncInvoiceGetOwner (const GncInvoice *invoice);
|
||||
Timespec gncInvoiceGetDateOpened (const GncInvoice *invoice);
|
||||
Timespec gncInvoiceGetDatePosted (const GncInvoice *invoice);
|
||||
Timespec gncInvoiceGetDateDue (const GncInvoice *invoice);
|
||||
GncBillTerm * gncInvoiceGetTerms (const GncInvoice *invoice);
|
||||
const char * gncInvoiceGetBillingID (const GncInvoice *invoice);
|
||||
const char * gncInvoiceGetNotes (const GncInvoice *invoice);
|
||||
GncOwnerType gncInvoiceGetOwnerType (GncInvoice *invoice);
|
||||
GncOwnerType gncInvoiceGetOwnerType (const GncInvoice *invoice);
|
||||
GList * gncInvoiceGetTypeListForOwnerType (const GncOwnerType type);
|
||||
GncInvoiceType gncInvoiceGetType (GncInvoice *invoice);
|
||||
const char * gncInvoiceGetTypeString (GncInvoice *invoice);
|
||||
GncInvoiceType gncInvoiceGetType (const GncInvoice *invoice);
|
||||
const char * gncInvoiceGetTypeString (const GncInvoice *invoice);
|
||||
gnc_commodity * gncInvoiceGetCurrency (const GncInvoice *invoice);
|
||||
GncOwner * gncInvoiceGetBillTo (GncInvoice *invoice);
|
||||
gnc_numeric gncInvoiceGetToChargeAmount (const GncInvoice *invoice);
|
||||
@ -170,7 +170,7 @@ GNCPrice * gncInvoiceGetPrice(GncInvoice *invoice, gnc_commodity* commodity);
|
||||
* Returns TRUE if the invoice will increase the balance or FALSE
|
||||
* otherwise.
|
||||
*/
|
||||
gboolean gncInvoiceAmountPositive (GncInvoice *invoice);
|
||||
gboolean gncInvoiceAmountPositive (const GncInvoice *invoice);
|
||||
|
||||
/** Post this invoice to an account. Returns the new Transaction
|
||||
* that is tied to this invoice. The transaction is set with
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "gncOwner.h"
|
||||
|
||||
gboolean gncInvoiceRegister (void);
|
||||
gchar *gncInvoiceNextID (QofBook *book, GncOwner *owner);
|
||||
gchar *gncInvoiceNextID (QofBook *book, const GncOwner *owner);
|
||||
void gncInvoiceSetPostedAcc (GncInvoice *invoice, Account *acc);
|
||||
void gncInvoiceSetPostedTxn (GncInvoice *invoice, Transaction *txn);
|
||||
void gncInvoiceSetPostedLot (GncInvoice *invoice, GNCLot *lot);
|
||||
|
@ -571,7 +571,7 @@ GncGUID gncOwnerRetGUID (GncOwner *owner)
|
||||
return *guid_null ();
|
||||
}
|
||||
|
||||
GncOwner * gncOwnerGetEndOwner (GncOwner *owner)
|
||||
const GncOwner * gncOwnerGetEndOwner (const GncOwner *owner)
|
||||
{
|
||||
if (!owner) return NULL;
|
||||
switch (owner->type)
|
||||
@ -615,11 +615,10 @@ int gncOwnerCompare (const GncOwner *a, const GncOwner *b)
|
||||
}
|
||||
}
|
||||
|
||||
const GncGUID * gncOwnerGetEndGUID (GncOwner *owner)
|
||||
const GncGUID * gncOwnerGetEndGUID (const GncOwner *owner)
|
||||
{
|
||||
if (!owner) return NULL;
|
||||
owner = gncOwnerGetEndOwner (owner);
|
||||
return gncOwnerGetGUID (owner);
|
||||
return gncOwnerGetGUID (gncOwnerGetEndOwner (owner));
|
||||
}
|
||||
|
||||
void gncOwnerAttachToLot (const GncOwner *owner, GNCLot *lot)
|
||||
|
@ -175,8 +175,8 @@ GncGUID gncOwnerRetGUID (GncOwner *owner);
|
||||
* Get the "parent" Owner or GncGUID thereof. The "parent" owner
|
||||
* is the Customer or Vendor, or the Owner of a Job
|
||||
*/
|
||||
GncOwner * gncOwnerGetEndOwner (GncOwner *owner);
|
||||
const GncGUID * gncOwnerGetEndGUID (GncOwner *owner);
|
||||
const GncOwner * gncOwnerGetEndOwner (const GncOwner *owner);
|
||||
const GncGUID * gncOwnerGetEndGUID (const GncOwner *owner);
|
||||
|
||||
/** attach an owner to a lot */
|
||||
void gncOwnerAttachToLot (const GncOwner *owner, GNCLot *lot);
|
||||
|
Loading…
Reference in New Issue
Block a user