mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* fix the business XML to use symbolic names for enums (instead of
their integer values). This is an incompatible change -- old business XML objects will not load properly. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7053 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
edc1a34ecc
commit
52b503aca9
@ -4,6 +4,10 @@
|
|||||||
* gw-gnome-utils-spec: wrap URLType type, #defines, and gnc_build_url()
|
* gw-gnome-utils-spec: wrap URLType type, #defines, and gnc_build_url()
|
||||||
* get the rest of the C code to use URLTypes properly
|
* get the rest of the C code to use URLTypes properly
|
||||||
|
|
||||||
|
* fix the business XML to use symbolic names for enums (instead of
|
||||||
|
their integer values). This is an incompatible change -- old
|
||||||
|
business XML objects will not load properly.
|
||||||
|
|
||||||
2002-06-29 David Hampton <hampton@employees.org>
|
2002-06-29 David Hampton <hampton@employees.org>
|
||||||
|
|
||||||
* configure.in:
|
* configure.in:
|
||||||
|
@ -109,8 +109,9 @@ customer_dom_tree_create (GncCustomer *cust)
|
|||||||
xmlAddChild(ret, guid_to_dom_tree(cust_terms_string,
|
xmlAddChild(ret, guid_to_dom_tree(cust_terms_string,
|
||||||
gncBillTermGetGUID (term)));
|
gncBillTermGetGUID (term)));
|
||||||
|
|
||||||
xmlAddChild(ret, int_to_dom_tree(cust_taxincluded_string,
|
xmlAddChild(ret, text_to_dom_tree(cust_taxincluded_string,
|
||||||
gncCustomerGetTaxIncluded (cust)));
|
gncTaxIncludedTypeToString (
|
||||||
|
gncCustomerGetTaxIncluded (cust))));
|
||||||
|
|
||||||
xmlAddChild(ret, int_to_dom_tree(cust_active_string,
|
xmlAddChild(ret, int_to_dom_tree(cust_active_string,
|
||||||
gncCustomerGetActive (cust)));
|
gncCustomerGetActive (cust)));
|
||||||
@ -241,14 +242,18 @@ static gboolean
|
|||||||
customer_taxincluded_handler (xmlNodePtr node, gpointer cust_pdata)
|
customer_taxincluded_handler (xmlNodePtr node, gpointer cust_pdata)
|
||||||
{
|
{
|
||||||
struct customer_pdata *pdata = cust_pdata;
|
struct customer_pdata *pdata = cust_pdata;
|
||||||
gint64 val;
|
GncTaxIncluded type;
|
||||||
|
char *str;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
ret = dom_tree_to_integer(node, &val);
|
str = dom_tree_to_text (node);
|
||||||
if (ret) {
|
g_return_val_if_fail (str, FALSE);
|
||||||
if (!val) val = GNC_TAXINCLUDED_USEGLOBAL;
|
|
||||||
gncCustomerSetTaxIncluded(pdata->customer, (GncTaxIncluded)val);
|
ret = gncTaxIncludedStringToType (str, &type);
|
||||||
}
|
g_free (str);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
gncCustomerSetTaxIncluded(pdata->customer, type);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -122,10 +122,12 @@ entry_dom_tree_create (GncEntry *entry)
|
|||||||
maybe_add_numeric (ret, entry_price_string, gncEntryGetPrice (entry));
|
maybe_add_numeric (ret, entry_price_string, gncEntryGetPrice (entry));
|
||||||
|
|
||||||
maybe_add_numeric (ret, entry_discount_string, gncEntryGetDiscount (entry));
|
maybe_add_numeric (ret, entry_discount_string, gncEntryGetDiscount (entry));
|
||||||
xmlAddChild(ret, int_to_dom_tree(entry_disctype_string,
|
xmlAddChild(ret, text_to_dom_tree(entry_disctype_string,
|
||||||
gncEntryGetDiscountType (entry)));
|
gncAmountTypeToString (
|
||||||
xmlAddChild(ret, int_to_dom_tree(entry_dischow_string,
|
gncEntryGetDiscountType (entry))));
|
||||||
gncEntryGetDiscountHow (entry)));
|
xmlAddChild(ret, text_to_dom_tree(entry_dischow_string,
|
||||||
|
gncEntryDiscountHowToString (
|
||||||
|
gncEntryGetDiscountHow (entry))));
|
||||||
|
|
||||||
acc = gncEntryGetAccount (entry);
|
acc = gncEntryGetAccount (entry);
|
||||||
if (acc)
|
if (acc)
|
||||||
@ -288,24 +290,40 @@ static gboolean
|
|||||||
entry_disctype_handler (xmlNodePtr node, gpointer entry_pdata)
|
entry_disctype_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||||
{
|
{
|
||||||
struct entry_pdata *pdata = entry_pdata;
|
struct entry_pdata *pdata = entry_pdata;
|
||||||
gint64 val;
|
GncAmountType type;
|
||||||
|
char *str;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
dom_tree_to_integer(node, &val);
|
str = dom_tree_to_text (node);
|
||||||
gncEntrySetDiscountType(pdata->entry, (gint)val);
|
g_return_val_if_fail (str, FALSE);
|
||||||
|
|
||||||
return TRUE;
|
ret = gncAmountStringToType (str, &type);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
gncEntrySetDiscountType(pdata->entry, type);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
entry_dischow_handler (xmlNodePtr node, gpointer entry_pdata)
|
entry_dischow_handler (xmlNodePtr node, gpointer entry_pdata)
|
||||||
{
|
{
|
||||||
struct entry_pdata *pdata = entry_pdata;
|
struct entry_pdata *pdata = entry_pdata;
|
||||||
gint64 val;
|
GncDiscountHow how;
|
||||||
|
char *str;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
dom_tree_to_integer(node, &val);
|
str = dom_tree_to_text (node);
|
||||||
gncEntrySetDiscountHow(pdata->entry, (gint)val);
|
g_return_val_if_fail (str, FALSE);
|
||||||
|
|
||||||
return TRUE;
|
ret = gncEntryDiscountStringToHow (str, &how);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
gncEntrySetDiscountHow(pdata->entry, how);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -92,8 +92,9 @@ ttentry_dom_tree_create (GncTaxTableEntry *entry)
|
|||||||
amount = gncTaxTableEntryGetAmount (entry);
|
amount = gncTaxTableEntryGetAmount (entry);
|
||||||
xmlAddChild (ret, gnc_numeric_to_dom_tree (ttentry_amount_string, &amount));
|
xmlAddChild (ret, gnc_numeric_to_dom_tree (ttentry_amount_string, &amount));
|
||||||
|
|
||||||
xmlAddChild(ret, int_to_dom_tree (ttentry_type_string,
|
xmlAddChild(ret, text_to_dom_tree (ttentry_type_string,
|
||||||
gncTaxTableEntryGetType (entry)));
|
gncAmountTypeToString (
|
||||||
|
gncTaxTableEntryGetType (entry))));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -157,11 +158,20 @@ static gboolean
|
|||||||
ttentry_type_handler (xmlNodePtr node, gpointer taxtable_pdata)
|
ttentry_type_handler (xmlNodePtr node, gpointer taxtable_pdata)
|
||||||
{
|
{
|
||||||
struct ttentry_pdata *pdata = taxtable_pdata;
|
struct ttentry_pdata *pdata = taxtable_pdata;
|
||||||
gint64 val;
|
GncAmountType type;
|
||||||
|
char *str;
|
||||||
|
gboolean ret;
|
||||||
|
|
||||||
dom_tree_to_integer(node, &val);
|
str = dom_tree_to_text (node);
|
||||||
gncTaxTableEntrySetType (pdata->ttentry, val);
|
g_return_val_if_fail (str, FALSE);
|
||||||
return TRUE;
|
|
||||||
|
ret = gncAmountStringToType (str, &type);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
gncTaxTableEntrySetType (pdata->ttentry, type);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -102,8 +102,9 @@ vendor_dom_tree_create (GncVendor *vendor)
|
|||||||
xmlAddChild(ret, guid_to_dom_tree(vendor_terms_string,
|
xmlAddChild(ret, guid_to_dom_tree(vendor_terms_string,
|
||||||
gncBillTermGetGUID (term)));
|
gncBillTermGetGUID (term)));
|
||||||
|
|
||||||
xmlAddChild(ret, int_to_dom_tree(vendor_taxincluded_string,
|
xmlAddChild(ret, text_to_dom_tree(vendor_taxincluded_string,
|
||||||
gncVendorGetTaxIncluded (vendor)));
|
gncTaxIncludedTypeToString (
|
||||||
|
gncVendorGetTaxIncluded (vendor))));
|
||||||
|
|
||||||
xmlAddChild(ret, int_to_dom_tree(vendor_active_string,
|
xmlAddChild(ret, int_to_dom_tree(vendor_active_string,
|
||||||
gncVendorGetActive (vendor)));
|
gncVendorGetActive (vendor)));
|
||||||
@ -218,14 +219,18 @@ static gboolean
|
|||||||
vendor_taxincluded_handler (xmlNodePtr node, gpointer vendor_pdata)
|
vendor_taxincluded_handler (xmlNodePtr node, gpointer vendor_pdata)
|
||||||
{
|
{
|
||||||
struct vendor_pdata *pdata = vendor_pdata;
|
struct vendor_pdata *pdata = vendor_pdata;
|
||||||
gint64 val;
|
GncTaxIncluded type;
|
||||||
|
char *str;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
ret = dom_tree_to_integer(node, &val);
|
str = dom_tree_to_text (node);
|
||||||
if (ret) {
|
g_return_val_if_fail (str, FALSE);
|
||||||
if (!val) val = GNC_TAXINCLUDED_USEGLOBAL;
|
|
||||||
gncVendorSetTaxIncluded(pdata->vendor, (GncTaxIncluded)val);
|
ret = gncTaxIncludedStringToType (str, &type);
|
||||||
}
|
g_free (str);
|
||||||
|
|
||||||
|
if (ret)
|
||||||
|
gncVendorSetTaxIncluded(pdata->vendor, type);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,39 @@ struct _gncEntry {
|
|||||||
gboolean dirty;
|
gboolean dirty;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* You must edit the functions in this block in tandem. KEEP THEM IN
|
||||||
|
SYNC! */
|
||||||
|
|
||||||
|
#define GNC_RETURN_ENUM_AS_STRING(x,s) case (x): return (s);
|
||||||
|
const char *
|
||||||
|
gncEntryDiscountHowToString (GncDiscountHow how)
|
||||||
|
{
|
||||||
|
switch(how)
|
||||||
|
{
|
||||||
|
GNC_RETURN_ENUM_AS_STRING(GNC_DISC_PRETAX, "PRETAX");
|
||||||
|
GNC_RETURN_ENUM_AS_STRING(GNC_DISC_SAMETIME, "SAMETIME");
|
||||||
|
GNC_RETURN_ENUM_AS_STRING(GNC_DISC_POSTTAX, "POSTTAX");
|
||||||
|
default:
|
||||||
|
g_warning ("asked to translate unknown discount-how %d.\n", how);
|
||||||
|
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); }
|
||||||
|
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);
|
||||||
|
g_warning ("asked to translate unknown discount-how string %s.\n",
|
||||||
|
str ? str : "(null)");
|
||||||
|
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
#undef GNC_RETURN_ON_MATCH
|
||||||
|
|
||||||
#define _GNC_MOD_NAME GNC_ENTRY_MODULE_NAME
|
#define _GNC_MOD_NAME GNC_ENTRY_MODULE_NAME
|
||||||
|
|
||||||
#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
|
#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
|
||||||
|
@ -32,6 +32,9 @@ typedef enum {
|
|||||||
GNC_DISC_POSTTAX
|
GNC_DISC_POSTTAX
|
||||||
} GncDiscountHow;
|
} GncDiscountHow;
|
||||||
|
|
||||||
|
const char * gncEntryDiscountHowToString (GncDiscountHow how);
|
||||||
|
gboolean gncEntryDiscountStringToHow (const char *str, GncDiscountHow *how);
|
||||||
|
|
||||||
/* Create/Destroy Functions */
|
/* Create/Destroy Functions */
|
||||||
|
|
||||||
GncEntry *gncEntryCreate (GNCBook *book);
|
GncEntry *gncEntryCreate (GNCBook *book);
|
||||||
|
@ -46,6 +46,65 @@ struct _book_info {
|
|||||||
GList * tables; /* visible tables */
|
GList * tables; /* visible tables */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* You must edit the functions in this block in tandem. KEEP THEM IN
|
||||||
|
SYNC! */
|
||||||
|
|
||||||
|
#define GNC_RETURN_ENUM_AS_STRING(x,s) case (x): return (s);
|
||||||
|
const char *
|
||||||
|
gncAmountTypeToString (GncAmountType type)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
GNC_RETURN_ENUM_AS_STRING(GNC_AMT_TYPE_VALUE, "VALUE");
|
||||||
|
GNC_RETURN_ENUM_AS_STRING(GNC_AMT_TYPE_PERCENT, "PERCENT");
|
||||||
|
default:
|
||||||
|
g_warning ("asked to translate unknown amount type %d.\n", type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
gncTaxIncludedTypeToString (GncTaxIncluded type)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
GNC_RETURN_ENUM_AS_STRING(GNC_TAXINCLUDED_YES, "YES");
|
||||||
|
GNC_RETURN_ENUM_AS_STRING(GNC_TAXINCLUDED_NO, "NO");
|
||||||
|
GNC_RETURN_ENUM_AS_STRING(GNC_TAXINCLUDED_USEGLOBAL, "USEGLOBAL");
|
||||||
|
default:
|
||||||
|
g_warning ("asked to translate unknown taxincluded 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) { *type = x; return(TRUE); }
|
||||||
|
gboolean
|
||||||
|
gncAmountStringToType (const char *str, GncAmountType *type)
|
||||||
|
{
|
||||||
|
GNC_RETURN_ON_MATCH ("VALUE", GNC_AMT_TYPE_VALUE);
|
||||||
|
GNC_RETURN_ON_MATCH ("PERCENT", GNC_AMT_TYPE_PERCENT);
|
||||||
|
g_warning ("asked to translate unknown amount type string %s.\n",
|
||||||
|
str ? str : "(null)");
|
||||||
|
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gncTaxIncludedStringToType (const char *str, GncTaxIncluded *type)
|
||||||
|
{
|
||||||
|
GNC_RETURN_ON_MATCH ("YES", GNC_TAXINCLUDED_YES);
|
||||||
|
GNC_RETURN_ON_MATCH ("NO", GNC_TAXINCLUDED_NO);
|
||||||
|
GNC_RETURN_ON_MATCH ("USEGLOBAL", GNC_TAXINCLUDED_USEGLOBAL);
|
||||||
|
g_warning ("asked to translate unknown taxincluded type string %s.\n",
|
||||||
|
str ? str : "(null)");
|
||||||
|
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
#undef GNC_RETURN_ON_MATCH
|
||||||
|
|
||||||
#define _GNC_MOD_NAME GNC_TAXTABLE_MODULE_NAME
|
#define _GNC_MOD_NAME GNC_TAXTABLE_MODULE_NAME
|
||||||
|
|
||||||
#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
|
#define CACHE_INSERT(str) g_cache_insert(gnc_engine_get_string_cache(), (gpointer)(str));
|
||||||
|
@ -34,6 +34,12 @@ typedef enum {
|
|||||||
GNC_TAXINCLUDED_USEGLOBAL,
|
GNC_TAXINCLUDED_USEGLOBAL,
|
||||||
} GncTaxIncluded;
|
} GncTaxIncluded;
|
||||||
|
|
||||||
|
const char * gncAmountTypeToString (GncAmountType type);
|
||||||
|
gboolean gncAmountStringToType (const char *str, GncAmountType *type);
|
||||||
|
|
||||||
|
const char * gncTaxIncludedTypeToString (GncTaxIncluded type);
|
||||||
|
gboolean gncTaxIncludedStringToType (const char *str, GncTaxIncluded *type);
|
||||||
|
|
||||||
/* Create/Destroy Functions */
|
/* Create/Destroy Functions */
|
||||||
GncTaxTable * gncTaxTableCreate (GNCBook *book);
|
GncTaxTable * gncTaxTableCreate (GNCBook *book);
|
||||||
void gncTaxTableDestroy (GncTaxTable *table);
|
void gncTaxTableDestroy (GncTaxTable *table);
|
||||||
|
Loading…
Reference in New Issue
Block a user