static xmlNodePtr vendor_dom_tree_create (GncVendor* vendor) { xmlNodePtr ret; GncBillTerm* term; GncTaxTable* taxtable; ret = xmlNewNode (NULL, BAD_CAST gnc_vendor_string); xmlSetProp (ret, BAD_CAST "version", BAD_CAST vendor_version_string); xmlAddChild (ret, guid_to_dom_tree (vendor_guid_string, qof_instance_get_guid (QOF_INSTANCE (vendor)))); xmlAddChild (ret, text_to_dom_tree (vendor_name_string, gncVendorGetName (vendor))); xmlAddChild (ret, text_to_dom_tree (vendor_id_string, gncVendorGetID (vendor))); xmlAddChild (ret, gnc_address_to_dom_tree (vendor_addr_string, gncVendorGetAddr (vendor))); maybe_add_string (ret, vendor_notes_string, gncVendorGetNotes (vendor)); term = gncVendorGetTerms (vendor); if (term) xmlAddChild (ret, guid_to_dom_tree (vendor_terms_string, qof_instance_get_guid (QOF_INSTANCE (term)))); xmlAddChild (ret, text_to_dom_tree (vendor_taxincluded_string, gncTaxIncludedTypeToString ( gncVendorGetTaxIncluded (vendor)))); xmlAddChild (ret, int_to_dom_tree (vendor_active_string, gncVendorGetActive (vendor))); xmlAddChild (ret, commodity_ref_to_dom_tree (vendor_currency_string, gncVendorGetCurrency (vendor))); xmlAddChild (ret, int_to_dom_tree (vendor_taxtableoverride_string, gncVendorGetTaxTableOverride (vendor))); taxtable = gncVendorGetTaxTable (vendor); if (taxtable) xmlAddChild (ret, guid_to_dom_tree (vendor_taxtable_string, qof_instance_get_guid (QOF_INSTANCE (taxtable)))); /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */ xmlAddChild (ret, qof_instance_slots_to_dom_tree (vendor_slots_string, QOF_INSTANCE (vendor))); return ret; }
static gboolean vendor_should_be_saved (GncVendor* vendor) { const char* id; /* make sure this is a valid vendor before we save it -- should have an ID */ id = gncVendorGetID (vendor); if (id == NULL || *id == '\0') return FALSE; return TRUE; }
const char * gncOwnerGetID (const GncOwner *owner) { if (!owner) return NULL; switch (owner->type) { case GNC_OWNER_NONE: case GNC_OWNER_UNDEFINED: default: return NULL; case GNC_OWNER_CUSTOMER: return gncCustomerGetID (owner->owner.customer); case GNC_OWNER_JOB: return gncJobGetID (owner->owner.job); case GNC_OWNER_VENDOR: return gncVendorGetID (owner->owner.vendor); case GNC_OWNER_EMPLOYEE: return gncEmployeeGetID (owner->owner.employee); } }