From 2f3555c9ee2530aaa4e5d59cc3968e9bbf88f1c6 Mon Sep 17 00:00:00 2001 From: Phil Longstaff Date: Sat, 28 Jan 2012 00:15:04 +0000 Subject: [PATCH] Add more vendor gobject attributes and use those to save/restore to sql db git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21898 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/backend/sql/gnc-vendor-sql.c | 26 ++--- src/engine/gncVendor.c | 172 ++++++++++++++++++++++++++++++- 2 files changed, 180 insertions(+), 18 deletions(-) diff --git a/src/backend/sql/gnc-vendor-sql.c b/src/backend/sql/gnc-vendor-sql.c index cb60dc2153..7d6080b8cc 100644 --- a/src/backend/sql/gnc-vendor-sql.c +++ b/src/backend/sql/gnc-vendor-sql.c @@ -64,22 +64,16 @@ static QofLogModule log_module = G_LOG_DOMAIN; static GncSqlColumnTableEntry col_table[] = { { "guid", CT_GUID, 0, COL_NNUL | COL_PKEY, "guid" }, - { "name", CT_STRING, MAX_NAME_LEN, COL_NNUL, "name" }, - { "id", CT_STRING, MAX_ID_LEN, COL_NNUL, NULL, VENDOR_ID }, - { "notes", CT_STRING, MAX_NOTES_LEN, COL_NNUL, NULL, VENDOR_NOTES }, - { - "currency", CT_COMMODITYREF, 0, COL_NNUL, NULL, NULL, - (QofAccessFunc)gncVendorGetCurrency, (QofSetterFunc)gncVendorSetCurrency - }, - { - "active", CT_BOOLEAN, 0, COL_NNUL, NULL, NULL, - (QofAccessFunc)gncVendorGetActive, (QofSetterFunc)gncVendorSetActive - }, - { "tax_override", CT_BOOLEAN, 0, COL_NNUL, NULL, VENDOR_TAX_OVERRIDE }, - { "addr", CT_ADDRESS, 0, 0, NULL, VENDOR_ADDR }, - { "terms", CT_BILLTERMREF, 0, 0, NULL, VENDOR_TERMS }, - { "tax_inc", CT_STRING, MAX_TAX_INC_LEN, 0, NULL, VENDOR_TAX_INC }, - { "tax_table", CT_TAXTABLEREF, 0, 0, NULL, VENDOR_TAX_TABLE }, + { "name", CT_STRING, MAX_NAME_LEN, COL_NNUL, "name" }, + { "id", CT_STRING, MAX_ID_LEN, COL_NNUL, "id" }, + { "notes", CT_STRING, MAX_NOTES_LEN, COL_NNUL, "notes" }, + { "currency", CT_COMMODITYREF, 0, COL_NNUL, "currency" }, + { "active", CT_BOOLEAN, 0, COL_NNUL, "active" }, + { "tax_override", CT_BOOLEAN, 0, COL_NNUL, "tax-table-override" }, + { "addr", CT_ADDRESS, 0, 0, "address" }, + { "terms", CT_BILLTERMREF, 0, 0, "terms" }, + { "tax_inc", CT_STRING, MAX_TAX_INC_LEN, 0, "tax-included-string" }, + { "tax_table", CT_TAXTABLEREF, 0, 0, "tax-table" }, { NULL } }; diff --git a/src/engine/gncVendor.c b/src/engine/gncVendor.c index 9e48fac418..2bd03abf07 100644 --- a/src/engine/gncVendor.c +++ b/src/engine/gncVendor.c @@ -43,6 +43,9 @@ static gint gs_address_event_handler_id = 0; static void listen_for_address_events(QofInstance *entity, QofEventId event_type, gpointer user_data, gpointer event_data); +static void qofVendorSetAddr (GncVendor *vendor, QofInstance *addr_ent); +static const char* qofVendorGetTaxIncluded(const GncVendor *vendor); +static void qofVendorSetTaxIncluded(GncVendor *vendor, const char* type_string); struct _gncVendor { @@ -85,7 +88,17 @@ void mark_vendor (GncVendor *vendor) enum { PROP_0, - PROP_NAME + PROP_NAME, + PROP_ID, + PROP_NOTES, + PROP_CURRENCY, + PROP_ACTIVE, + PROP_TAXTABLE_OVERRIDE, + PROP_BILLTERMS, + PROP_TAXTABLE, + PROP_ADDRESS, + PROP_TAX_INCLUDED, + PROP_TAX_INCLUDED_STR }; /* GObject Initialization */ @@ -124,6 +137,36 @@ gnc_vendor_get_property (GObject *object, case PROP_NAME: g_value_set_string(value, vendor->name); break; + case PROP_ID: + g_value_set_string(value, vendor->id); + break; + case PROP_NOTES: + g_value_set_string(value, vendor->notes); + break; + case PROP_CURRENCY: + g_value_set_object(value, vendor->currency); + break; + case PROP_ACTIVE: + g_value_set_boolean(value, vendor->active); + break; + case PROP_TAXTABLE_OVERRIDE: + g_value_set_boolean(value, vendor->taxtable_override); + break; + case PROP_BILLTERMS: + g_value_set_object(value, vendor->terms); + break; + case PROP_TAXTABLE: + g_value_set_object(value, vendor->taxtable); + break; + case PROP_ADDRESS: + g_value_set_object(value, vendor->addr); + break; + case PROP_TAX_INCLUDED: + g_value_set_int(value, vendor->taxincluded); + break; + case PROP_TAX_INCLUDED_STR: + g_value_set_string(value, qofVendorGetTaxIncluded(vendor)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -146,7 +189,37 @@ gnc_vendor_set_property (GObject *object, case PROP_NAME: gncVendorSetName(vendor, g_value_get_string(value)); break; - default: + case PROP_ID: + gncVendorSetID(vendor, g_value_get_string(value)); + break; + case PROP_NOTES: + gncVendorSetNotes(vendor, g_value_get_string(value)); + break; + case PROP_CURRENCY: + gncVendorSetCurrency(vendor, g_value_get_object(value)); + break; + case PROP_ACTIVE: + gncVendorSetActive(vendor, g_value_get_boolean(value)); + break; + case PROP_TAXTABLE_OVERRIDE: + gncVendorSetTaxTableOverride(vendor, g_value_get_boolean(value)); + break; + case PROP_BILLTERMS: + gncVendorSetTerms(vendor, g_value_get_object(value)); + break; + case PROP_TAXTABLE: + gncVendorSetTaxTable(vendor, g_value_get_object(value)); + break; + case PROP_ADDRESS: + qofVendorSetAddr(vendor, g_value_get_object(value)); + break; + case PROP_TAX_INCLUDED: + gncVendorSetTaxIncluded(vendor, (GncTaxIncluded)g_value_get_int(value)); + break; + case PROP_TAX_INCLUDED_STR: + qofVendorSetTaxIncluded(vendor, g_value_get_string(value)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } @@ -216,6 +289,101 @@ gnc_vendor_class_init (GncVendorClass *klass) "assigned by the user to provide the vendor name.", NULL, G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_ID, + g_param_spec_string ("id", + "Vendor ID", + "The vendor id is an arbitrary string " + "assigned by the user to identify the vendor.", + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_NOTES, + g_param_spec_string ("notes", + "Vendor notes", + "The vendor notes is an arbitrary string " + "assigned by the user to add extra information about the vendor.", + NULL, + G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_CURRENCY, + g_param_spec_object ("currency", + "Currency", + "The currency property denotes the currency used by this vendor.", + GNC_TYPE_COMMODITY, + G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_ACTIVE, + g_param_spec_boolean ("active", + "Active", + "TRUE if the vendor is active. FALSE if inactive.", + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_TAXTABLE_OVERRIDE, + g_param_spec_boolean ("tax-table-override", + "Tax table override", + "TRUE if the vendor has a specific tax table which overrides the default " + "tax table. FALSE if the default table should be used.", + FALSE, + G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_BILLTERMS, + g_param_spec_object ("terms", + "Terms", + "The billing terms used by this vendor.", + GNC_TYPE_COMMODITY, + G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_TAXTABLE, + g_param_spec_object ("tax-table", + "Tax table", + "The tax table which applies to this vendor.", + GNC_TYPE_COMMODITY, + G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_ADDRESS, + g_param_spec_object ("address", + "Address", + "The address property contains the address information for this vendor.", + GNC_TYPE_ADDRESS, + G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_TAX_INCLUDED, + g_param_spec_int ("tax-included", + "Tax included", + "The tax-included property contains the information about tax calculation this vendor.", + GNC_TAXINCLUDED_YES, /* min */ + GNC_TAXINCLUDED_USEGLOBAL, /* max */ + GNC_TAXINCLUDED_USEGLOBAL, /* default */ + G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_TAX_INCLUDED_STR, + g_param_spec_string("tax-included-string", + "Tax included string", + "The tax-included-string property contains a character version of tax-included.", + FALSE, + G_PARAM_READWRITE)); } /* Create/Destroy Functions */