mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* add Billable flag and Bill-To (owner) to line-item entries.
* save these flags only if the entry is attached to a Bill. * add a Billable column to Bill register git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7110 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
3fcc2fff44
commit
5266dcf818
@ -1,3 +1,9 @@
|
||||
2002-07-10 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* add Billable flag and Bill-To (owner) to line-item entries.
|
||||
* save these flags only if the entry is attached to a Bill.
|
||||
* add a Billable column to Bill register
|
||||
|
||||
2002-07-09 Derek Atkins <derek@ihftp.com>
|
||||
|
||||
* "global-replace for-each-in-order for-each" because the former
|
||||
|
@ -77,6 +77,8 @@ const gchar *entry_version_string = "2.0.0";
|
||||
#define entry_order_string "entry:order"
|
||||
#define entry_invoice_string "entry:invoice"
|
||||
#define entry_bill_string "entry:bill"
|
||||
#define entry_billable_string "entry:billable"
|
||||
#define entry_billto_string "entry:billto"
|
||||
|
||||
static void
|
||||
maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
|
||||
@ -155,9 +157,16 @@ entry_dom_tree_create (GncEntry *entry)
|
||||
gncInvoiceGetGUID (invoice)));
|
||||
|
||||
invoice = gncEntryGetBill (entry);
|
||||
if (invoice)
|
||||
if (invoice) {
|
||||
GncOwner *owner;
|
||||
xmlAddChild (ret, guid_to_dom_tree (entry_bill_string,
|
||||
gncInvoiceGetGUID (invoice)));
|
||||
xmlAddChild(ret, int_to_dom_tree(entry_billable_string,
|
||||
gncEntryGetBillable (entry)));
|
||||
owner = gncEntryGetBillTo (entry);
|
||||
if (owner && owner->type != GNC_OWNER_NONE)
|
||||
xmlAddChild (ret, gnc_owner_to_dom_tree (entry_billto_string, owner));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -206,6 +215,18 @@ set_numeric(xmlNodePtr node, GncEntry* entry,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
set_boolean(xmlNodePtr node, GncEntry* entry,
|
||||
void (*func)(GncEntry *entry, gboolean val))
|
||||
{
|
||||
gint64 val;
|
||||
|
||||
if (!dom_tree_to_integer(node, &val))
|
||||
return FALSE;
|
||||
func (entry, (gboolean)val);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
entry_guid_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
{
|
||||
@ -353,24 +374,14 @@ static gboolean
|
||||
entry_taxable_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
{
|
||||
struct entry_pdata *pdata = entry_pdata;
|
||||
gint64 val;
|
||||
|
||||
dom_tree_to_integer(node, &val);
|
||||
gncEntrySetTaxable(pdata->entry, (gint)val);
|
||||
|
||||
return TRUE;
|
||||
return set_boolean (node, pdata->entry, gncEntrySetTaxable);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
entry_taxincluded_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
{
|
||||
struct entry_pdata *pdata = entry_pdata;
|
||||
gint64 val;
|
||||
|
||||
dom_tree_to_integer(node, &val);
|
||||
gncEntrySetTaxIncluded(pdata->entry, (gint)val);
|
||||
|
||||
return TRUE;
|
||||
return set_boolean (node, pdata->entry, gncEntrySetTaxIncluded);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -457,6 +468,27 @@ entry_bill_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
entry_billable_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
{
|
||||
struct entry_pdata *pdata = entry_pdata;
|
||||
return set_boolean (node, pdata->entry, gncEntrySetBillable);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
entry_billto_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
{
|
||||
struct entry_pdata *pdata = entry_pdata;
|
||||
GncOwner billto;
|
||||
gboolean ret;
|
||||
|
||||
ret = gnc_dom_tree_to_owner (node, &billto, pdata->book);
|
||||
if (ret)
|
||||
gncEntrySetBillTo (pdata->entry, &billto);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct dom_tree_handler entry_handlers_v2[] = {
|
||||
{ entry_guid_string, entry_guid_handler, 1, 0 },
|
||||
{ entry_date_string, entry_date_handler, 1, 0 },
|
||||
@ -476,6 +508,8 @@ static struct dom_tree_handler entry_handlers_v2[] = {
|
||||
{ entry_order_string, entry_order_handler, 0, 0 },
|
||||
{ entry_invoice_string, entry_invoice_handler, 0, 0 },
|
||||
{ entry_bill_string, entry_bill_handler, 0, 0 },
|
||||
{ entry_billable_string, entry_billable_handler, 0, 0 },
|
||||
{ entry_billto_string, entry_billto_handler, 0, 0 },
|
||||
{ NULL, 0, 0, 0 }
|
||||
};
|
||||
|
||||
|
@ -42,6 +42,9 @@ struct _gncEntry {
|
||||
gboolean taxincluded;
|
||||
GncTaxTable * tax_table;
|
||||
|
||||
gboolean billable;
|
||||
GncOwner billto;
|
||||
|
||||
GncOrder * order;
|
||||
GncInvoice * invoice;
|
||||
GncInvoice * bill;
|
||||
@ -144,6 +147,7 @@ GncEntry *gncEntryCreate (GNCBook *book)
|
||||
entry->taxable = TRUE;
|
||||
entry->dirty = FALSE;
|
||||
entry->values_dirty = TRUE;
|
||||
entry->billto.type = GNC_OWNER_NONE;
|
||||
|
||||
xaccGUIDNew (&entry->guid, book);
|
||||
addObj (entry);
|
||||
@ -335,6 +339,24 @@ void gncEntrySetDiscountHow (GncEntry *entry, GncDiscountHow how)
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetBillable (GncEntry *entry, gboolean billable)
|
||||
{
|
||||
if (!entry) return;
|
||||
if (entry->billable == billable) return;
|
||||
|
||||
entry->billable = billable;
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetBillTo (GncEntry *entry, GncOwner *billto)
|
||||
{
|
||||
if (!entry || !billto) return;
|
||||
if (gncOwnerEqual (&entry->billto, billto)) return;
|
||||
|
||||
gncOwnerCopy (billto, &entry->billto);
|
||||
mark_entry (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetDirty (GncEntry *entry, gboolean dirty)
|
||||
{
|
||||
if (!entry) return;
|
||||
@ -357,6 +379,8 @@ void gncEntryCopy (const GncEntry *src, GncEntry *dest)
|
||||
dest->account = src->account;
|
||||
dest->taxable = src->taxable;
|
||||
dest->taxincluded = src->taxincluded;
|
||||
dest->billable = src->billable;
|
||||
dest->billto = src->billto;
|
||||
|
||||
if (src->tax_table)
|
||||
gncEntrySetTaxTable (dest, src->tax_table);
|
||||
@ -491,6 +515,18 @@ GncTaxTable * gncEntryGetTaxTable (GncEntry *entry)
|
||||
return entry->tax_table;
|
||||
}
|
||||
|
||||
gboolean gncEntryGetBillable (GncEntry *entry)
|
||||
{
|
||||
if (!entry) return FALSE;
|
||||
return entry->billable;
|
||||
}
|
||||
|
||||
GncOwner * gncEntryGetBillTo (GncEntry *entry)
|
||||
{
|
||||
if (!entry) return NULL;
|
||||
return &entry->billto;
|
||||
}
|
||||
|
||||
GncEntry * gncEntryLookup (GNCBook *book, const GUID *guid)
|
||||
{
|
||||
if (!book || !guid) return NULL;
|
||||
@ -897,6 +933,8 @@ gboolean gncEntryRegister (void)
|
||||
{ ENTRY_PRICE, QUERYCORE_NUMERIC, (QueryAccess)gncEntryGetPrice },
|
||||
{ ENTRY_INVOICE, GNC_INVOICE_MODULE_NAME, (QueryAccess)gncEntryGetInvoice },
|
||||
{ ENTRY_BILL, GNC_INVOICE_MODULE_NAME, (QueryAccess)gncEntryGetBill },
|
||||
{ ENTRY_BILLABLE, QUERYCORE_BOOLEAN, (QueryAccess)gncEntryGetBillable },
|
||||
{ ENTRY_BILLTO, GNC_OWNER_MODULE_NAME, (QueryAccess)gncEntryGetBillTo },
|
||||
{ ENTRY_ORDER, GNC_ORDER_MODULE_NAME, (QueryAccess)gncEntryGetOrder },
|
||||
{ QUERY_PARAM_BOOK, GNC_ID_BOOK, (QueryAccess)gncEntryGetBook },
|
||||
{ QUERY_PARAM_GUID, QUERYCORE_GUID, (QueryAccess)gncEntryGetGUID },
|
||||
|
@ -55,6 +55,8 @@ void gncEntrySetDiscountHow (GncEntry *entry, GncDiscountHow how);
|
||||
void gncEntrySetTaxable (GncEntry *entry, gboolean taxable);
|
||||
void gncEntrySetTaxIncluded (GncEntry *entry, gboolean tax_included);
|
||||
void gncEntrySetTaxTable (GncEntry *entry, GncTaxTable *table);
|
||||
void gncEntrySetBillable (GncEntry *entry, gboolean billable);
|
||||
void gncEntrySetBillTo (GncEntry *entry, GncOwner *billto);
|
||||
|
||||
void gncEntrySetAccount (GncEntry *entry, Account *acc);
|
||||
|
||||
@ -75,6 +77,8 @@ GncDiscountHow gncEntryGetDiscountHow (GncEntry *entry);
|
||||
gboolean gncEntryGetTaxable (GncEntry *entry);
|
||||
gboolean gncEntryGetTaxIncluded (GncEntry *entry);
|
||||
GncTaxTable * gncEntryGetTaxTable (GncEntry *entry);
|
||||
gboolean gncEntryGetBillable (GncEntry *entry);
|
||||
GncOwner *gncEntryGetBillTo (GncEntry *entry);
|
||||
|
||||
void gncEntryCopy (const GncEntry *src, GncEntry *dest);
|
||||
|
||||
@ -125,6 +129,8 @@ int gncEntryCompare (GncEntry *a, GncEntry *b);
|
||||
#define ENTRY_NOTES "notes"
|
||||
#define ENTRY_QTY "qty"
|
||||
#define ENTRY_PRICE "price"
|
||||
#define ENTRY_BILLABLE "billable?"
|
||||
#define ENTRY_BILLTO "bill-to"
|
||||
|
||||
#define ENTRY_ORDER "order"
|
||||
#define ENTRY_INVOICE "invoice"
|
||||
|
@ -43,11 +43,12 @@ typedef struct entry_ledger_colors
|
||||
#define ENTRY_DISHOW_CELL "discount-how"
|
||||
#define ENTRY_PRIC_CELL "price"
|
||||
#define ENTRY_QTY_CELL "quantity"
|
||||
#define ENTRY_TAXABLE_CELL "taxable"
|
||||
#define ENTRY_TAXABLE_CELL "taxable?"
|
||||
#define ENTRY_TAXTABLE_CELL "taxtable"
|
||||
#define ENTRY_TAXINCLUDED_CELL "taxincluded"
|
||||
#define ENTRY_BILLABLE_CELL "billable?"
|
||||
|
||||
#define ENTRY_INV_CELL "invoiced-p"
|
||||
#define ENTRY_INV_CELL "invoiced?"
|
||||
#define ENTRY_VALUE_CELL "line-value"
|
||||
#define ENTRY_TAXVAL_CELL "line-tax-val"
|
||||
|
||||
|
@ -82,6 +82,8 @@ static void gnc_entry_ledger_layout_add_cells (GncEntryLedger *ledger,
|
||||
CELL_ALIGN_RIGHT, FALSE, FALSE },
|
||||
{ ENTRY_TAXVAL_CELL, PRICE_CELL_TYPE_NAME, N_("sample:999.00")+7,
|
||||
CELL_ALIGN_RIGHT, FALSE, FALSE },
|
||||
{ ENTRY_BILLABLE_CELL, RECN_CELL_TYPE_NAME, N_("sample:BI")+7,
|
||||
CELL_ALIGN_LEFT, FALSE, FALSE },
|
||||
};
|
||||
int i;
|
||||
|
||||
@ -106,7 +108,7 @@ static void gnc_entry_ledger_layout_add_cursors (GncEntryLedger *ledger,
|
||||
break;
|
||||
case GNCENTRY_BILL_ENTRY:
|
||||
case GNCENTRY_BILL_VIEWER:
|
||||
num_cols = 8;
|
||||
num_cols = 9;
|
||||
break;
|
||||
default:
|
||||
g_assert (FALSE);
|
||||
@ -163,6 +165,7 @@ static void gnc_entry_ledger_set_cells (GncEntryLedger *ledger,
|
||||
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_BILLABLE_CELL, 0, 8);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -181,6 +181,7 @@ void gnc_entry_ledger_load (GncEntryLedger *ledger, GList *entry_list)
|
||||
load_inv_type_cells (ledger, ENTRY_INV_CELL, FALSE);
|
||||
load_inv_type_cells (ledger, ENTRY_TAXABLE_CELL, TRUE);
|
||||
load_inv_type_cells (ledger, ENTRY_TAXINCLUDED_CELL, FALSE);
|
||||
load_inv_type_cells (ledger, ENTRY_BILLABLE_CELL, FALSE);
|
||||
gnc_entry_ledger_load_xfer_cells (ledger);
|
||||
|
||||
blank_entry = gnc_entry_ledger_get_blank_entry (ledger);
|
||||
|
@ -108,6 +108,11 @@ static const char * get_taxval_label (VirtualLocation virt_loc, gpointer data)
|
||||
return _("Tax");
|
||||
}
|
||||
|
||||
static const char * get_billable_label (VirtualLocation virt_loc, gpointer data)
|
||||
{
|
||||
return _("Billable?");
|
||||
}
|
||||
|
||||
/* GET_ENTRY */
|
||||
|
||||
static const char * get_acct_entry (VirtualLocation virt_loc,
|
||||
@ -429,6 +434,24 @@ static const char * get_taxval_entry (VirtualLocation virt_loc,
|
||||
return xaccPrintAmount (value, gnc_default_print_info (TRUE));
|
||||
}
|
||||
|
||||
static const char * get_billable_entry (VirtualLocation virt_loc,
|
||||
gboolean translate,
|
||||
gboolean *conditionally_changed,
|
||||
gpointer user_data)
|
||||
{
|
||||
GncEntryLedger *ledger = user_data;
|
||||
GncEntry *entry;
|
||||
static char s[2] = { ' ', '\0' };
|
||||
|
||||
entry = gnc_entry_ledger_get_entry (ledger, virt_loc.vcell_loc);
|
||||
if (gncEntryGetBillable (entry))
|
||||
s[0] = 'X';
|
||||
else
|
||||
s[0] = ' ';
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/* GET_HELP */
|
||||
|
||||
static char * get_acct_help (VirtualLocation virt_loc, gpointer user_data)
|
||||
@ -663,6 +686,15 @@ static char * get_taxval_help (VirtualLocation virt_loc, gpointer user_data)
|
||||
return g_strdup (help);
|
||||
}
|
||||
|
||||
static char * get_billable_help (VirtualLocation virt_loc, gpointer user_data)
|
||||
{
|
||||
const char *help;
|
||||
|
||||
help = _("Is this entry billable to a customer or job?");
|
||||
|
||||
return g_strdup (help);
|
||||
}
|
||||
|
||||
/* GET_IO_FLAGS */
|
||||
|
||||
static CellIOFlags get_standard_io_flags (VirtualLocation virt_loc,
|
||||
@ -702,14 +734,10 @@ static CellIOFlags get_inv_io_flags (VirtualLocation virt_loc,
|
||||
GncEntryLedger *ledger = user_data;
|
||||
|
||||
switch (ledger->type) {
|
||||
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:
|
||||
case GNCENTRY_INVOICE_ENTRY:
|
||||
return XACC_CELL_ALLOW_ALL | XACC_CELL_ALLOW_EXACT_ONLY;
|
||||
default:
|
||||
return XACC_CELL_ALLOW_SHADOW;
|
||||
}
|
||||
}
|
||||
|
||||
@ -910,6 +938,14 @@ static void gnc_entry_ledger_save_cells (gpointer save_data,
|
||||
gncEntrySetTaxIncluded (entry, taxincluded);
|
||||
}
|
||||
|
||||
if (gnc_table_layout_get_cell_changed (ledger->table->layout,
|
||||
ENTRY_BILLABLE_CELL, TRUE)) {
|
||||
gboolean billable;
|
||||
|
||||
billable = gnc_entry_ledger_get_checkmark (ledger, ENTRY_BILLABLE_CELL);
|
||||
gncEntrySetBillable (entry, billable);
|
||||
}
|
||||
|
||||
if (ledger->type == GNCENTRY_INVOICE_ENTRY) {
|
||||
char inv_value;
|
||||
|
||||
@ -962,6 +998,7 @@ static void gnc_entry_ledger_model_new_handlers (TableModel *model,
|
||||
{ ENTRY_INV_CELL, get_inv_entry, get_inv_label, get_inv_help, get_inv_io_flags },
|
||||
{ ENTRY_VALUE_CELL, get_value_entry, get_value_label, get_value_help, get_value_io_flags },
|
||||
{ ENTRY_TAXVAL_CELL, get_taxval_entry, get_taxval_label, get_taxval_help, get_value_io_flags },
|
||||
{ ENTRY_BILLABLE_CELL, get_billable_entry, get_billable_label, get_billable_help, get_typecell_io_flags },
|
||||
};
|
||||
int i;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user