mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* src/business/business-core/gncEntry.[ch]: add interfaces
to deal with bill 'payment types', in preparation for employee expense vouchers. * src/business/business-core/file/gnc-entry-xml-v2.c: add support for the bill payment type. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8033 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -1,3 +1,11 @@
|
||||
2003-03-02 Derek Atkins <derek@ihtfp.com>
|
||||
|
||||
* src/business/business-core/gncEntry.[ch]: add interfaces
|
||||
to deal with bill 'payment types', in preparation for
|
||||
employee expense vouchers.
|
||||
* src/business/business-core/file/gnc-entry-xml-v2.c:
|
||||
add support for the bill payment type.
|
||||
|
||||
2003-03-02 Christian Stimming <stimming@tuhh.de>
|
||||
|
||||
* src/app-utils/prefs.scm: Adjust the names of register styles in
|
||||
|
||||
@@ -86,6 +86,9 @@ const gchar *entry_version_string = "2.0.0";
|
||||
#define entry_billable_string "entry:billable"
|
||||
#define entry_billto_string "entry:billto"
|
||||
|
||||
/* emp bill */
|
||||
#define entry_billpayment_string "entry:b-pay"
|
||||
|
||||
/* other stuff */
|
||||
#define entry_order_string "entry:order"
|
||||
#define entry_invoice_string "entry:invoice"
|
||||
@@ -192,6 +195,8 @@ entry_dom_tree_create (GncEntry *entry)
|
||||
gncEntryGetBillTaxable (entry)));
|
||||
xmlAddChild(ret, int_to_dom_tree(entry_btaxincluded_string,
|
||||
gncEntryGetBillTaxIncluded (entry)));
|
||||
maybe_add_string (ret, entry_billpayment_string,
|
||||
gncEntryPaymentTypeToString (gncEntryGetBillPayment (entry)));
|
||||
}
|
||||
|
||||
taxtable = gncEntryGetBillTaxTable (entry);
|
||||
@@ -525,6 +530,27 @@ entry_billto_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* employee bills */
|
||||
static gboolean
|
||||
entry_billpayment_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||
{
|
||||
struct entry_pdata *pdata = entry_pdata;
|
||||
GncEntryPaymentType type;
|
||||
char *str;
|
||||
gboolean ret;
|
||||
|
||||
str = dom_tree_to_text (node);
|
||||
g_return_val_if_fail (str, FALSE);
|
||||
|
||||
ret = gncEntryPaymentStringToType (str, &type);
|
||||
g_free (str);
|
||||
|
||||
if (ret)
|
||||
gncEntrySetBillPayment(pdata->entry, type);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* The rest of the stuff */
|
||||
|
||||
static gboolean
|
||||
@@ -653,6 +679,9 @@ static struct dom_tree_handler entry_handlers_v2[] = {
|
||||
{ entry_billable_string, entry_billable_handler, 0, 0 },
|
||||
{ entry_billto_string, entry_billto_handler, 0, 0 },
|
||||
|
||||
/* employee stuff */
|
||||
{ entry_billpayment_string, entry_billpayment_handler, 0, 0 },
|
||||
|
||||
/* Other stuff */
|
||||
{ entry_order_string, entry_order_handler, 0, 0 },
|
||||
{ entry_invoice_string, entry_invoice_handler, 0, 0 },
|
||||
|
||||
@@ -53,6 +53,10 @@ struct _gncEntry {
|
||||
gboolean billable;
|
||||
GncOwner billto;
|
||||
|
||||
/* employee bill data */
|
||||
GncEntryPaymentType b_payment;
|
||||
|
||||
/* my parent(s) */
|
||||
GncOrder * order;
|
||||
GncInvoice * invoice;
|
||||
GncInvoice * bill;
|
||||
@@ -104,14 +108,36 @@ gncEntryDiscountHowToString (GncDiscountHow how)
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
const char * gncEntryPaymentTypeToString (GncEntryPaymentType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
GNC_RETURN_ENUM_AS_STRING(GNC_PAYMENT_CASH, "CASH");
|
||||
GNC_RETURN_ENUM_AS_STRING(GNC_PAYMENT_CARD, "CARD");
|
||||
default:
|
||||
g_warning ("asked to translate unknown payment type %d.\n", type);
|
||||
break;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
#undef GNC_RETURN_ENUM_AS_STRING
|
||||
#define GNC_RETURN_ON_MATCH(s,x) \
|
||||
if(safe_strcmp((s), (str)) == 0) { *how = x; return(TRUE); }
|
||||
#define GNC_RETURN_ON_MATCH(s,x,r) \
|
||||
if(safe_strcmp((s), (str)) == 0) { *(r) = x; return(TRUE); }
|
||||
gboolean gncEntryDiscountStringToHow (const char *str, GncDiscountHow *how)
|
||||
{
|
||||
GNC_RETURN_ON_MATCH ("PRETAX", GNC_DISC_PRETAX);
|
||||
GNC_RETURN_ON_MATCH ("SAMETIME", GNC_DISC_SAMETIME);
|
||||
GNC_RETURN_ON_MATCH ("POSTTAX", GNC_DISC_POSTTAX);
|
||||
GNC_RETURN_ON_MATCH ("PRETAX", GNC_DISC_PRETAX, how);
|
||||
GNC_RETURN_ON_MATCH ("SAMETIME", GNC_DISC_SAMETIME, how);
|
||||
GNC_RETURN_ON_MATCH ("POSTTAX", GNC_DISC_POSTTAX, how);
|
||||
g_warning ("asked to translate unknown discount-how string %s.\n",
|
||||
str ? str : "(null)");
|
||||
|
||||
return(FALSE);
|
||||
}
|
||||
gboolean gncEntryPaymentStringToType (const char *str, GncEntryPaymentType *type)
|
||||
{
|
||||
GNC_RETURN_ON_MATCH ("CASH", GNC_PAYMENT_CASH, type);
|
||||
GNC_RETURN_ON_MATCH ("CARD", GNC_PAYMENT_CARD, type);
|
||||
g_warning ("asked to translate unknown discount-how string %s.\n",
|
||||
str ? str : "(null)");
|
||||
|
||||
@@ -173,6 +199,7 @@ GncEntry *gncEntryCreate (GNCBook *book)
|
||||
entry->b_price = zero;
|
||||
entry->b_taxable = TRUE;
|
||||
entry->billto.type = GNC_OWNER_CUSTOMER;
|
||||
entry->b_payment = GNC_PAYMENT_CASH;
|
||||
|
||||
entry->values_dirty = TRUE;
|
||||
|
||||
@@ -455,6 +482,16 @@ void gncEntrySetBillTo (GncEntry *entry, GncOwner *billto)
|
||||
gncEntryCommitEdit (entry);
|
||||
}
|
||||
|
||||
void gncEntrySetBillPayment (GncEntry *entry, GncEntryPaymentType type)
|
||||
{
|
||||
if (!entry) return;
|
||||
if (entry->b_payment == type) return;
|
||||
gncEntryBeginEdit (entry);
|
||||
entry->b_payment = type;
|
||||
mark_entry (entry);
|
||||
gncEntryCommitEdit (entry);
|
||||
}
|
||||
|
||||
/* Called from gncOrder when we're added to the Order */
|
||||
void gncEntrySetOrder (GncEntry *entry, GncOrder *order)
|
||||
{
|
||||
@@ -691,6 +728,12 @@ GncOwner * gncEntryGetBillTo (GncEntry *entry)
|
||||
return &entry->billto;
|
||||
}
|
||||
|
||||
GncEntryPaymentType gncEntryGetBillPayment (GncEntry* entry)
|
||||
{
|
||||
if (!entry) return 0;
|
||||
return entry->b_payment;
|
||||
}
|
||||
|
||||
GncInvoice * gncEntryGetInvoice (GncEntry *entry)
|
||||
{
|
||||
if (!entry) return NULL;
|
||||
|
||||
@@ -32,9 +32,17 @@ typedef enum {
|
||||
GNC_DISC_POSTTAX
|
||||
} GncDiscountHow;
|
||||
|
||||
typedef enum {
|
||||
GNC_PAYMENT_CASH = 1,
|
||||
GNC_PAYMENT_CARD
|
||||
} GncEntryPaymentType;
|
||||
|
||||
const char * gncEntryDiscountHowToString (GncDiscountHow how);
|
||||
gboolean gncEntryDiscountStringToHow (const char *str, GncDiscountHow *how);
|
||||
|
||||
const char * gncEntryPaymentTypeToString (GncEntryPaymentType type);
|
||||
gboolean gncEntryPaymentStringToType (const char *str, GncEntryPaymentType *type);
|
||||
|
||||
/* Create/Destroy Functions */
|
||||
|
||||
GncEntry *gncEntryCreate (GNCBook *book);
|
||||
@@ -69,6 +77,9 @@ void gncEntrySetBillTaxTable (GncEntry *entry, GncTaxTable *table);
|
||||
void gncEntrySetBillable (GncEntry *entry, gboolean billable);
|
||||
void gncEntrySetBillTo (GncEntry *entry, GncOwner *billto);
|
||||
|
||||
/* employee-stuff */
|
||||
void gncEntrySetBillPayment (GncEntry *entry, GncEntryPaymentType type);
|
||||
|
||||
/* GET FUNCTIONS */
|
||||
/* Generic (shared) data */
|
||||
GNCBook * gncEntryGetBook (GncEntry *entry);
|
||||
@@ -99,6 +110,7 @@ GncTaxTable * gncEntryGetBillTaxTable (GncEntry *entry);
|
||||
gboolean gncEntryGetBillable (GncEntry *entry);
|
||||
GncOwner *gncEntryGetBillTo (GncEntry *entry);
|
||||
|
||||
GncEntryPaymentType gncEntryGetBillPayment (GncEntry* entry);
|
||||
|
||||
void gncEntryCopy (const GncEntry *src, GncEntry *dest);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user