static gboolean order_should_be_saved (GncOrder *order) { const char *id; /* make sure this is a valid order before we save it -- should have an ID */ id = gncOrderGetID (order); if (id == NULL || *id == '\0') return FALSE; return TRUE; }
static xmlNodePtr order_dom_tree_create (GncOrder *order) { xmlNodePtr ret; Timespec ts; kvp_frame *kf; ret = xmlNewNode(NULL, BAD_CAST gnc_order_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST order_version_string); xmlAddChild(ret, guid_to_dom_tree(order_guid_string, qof_instance_get_guid(QOF_INSTANCE (order)))); xmlAddChild(ret, text_to_dom_tree(order_id_string, gncOrderGetID (order))); xmlAddChild(ret, gnc_owner_to_dom_tree (order_owner_string, gncOrderGetOwner (order))); ts = gncOrderGetDateOpened (order); xmlAddChild(ret, timespec_to_dom_tree (order_opened_string, &ts)); ts = gncOrderGetDateClosed (order); if (ts.tv_sec || ts.tv_nsec) xmlAddChild(ret, timespec_to_dom_tree (order_closed_string, &ts)); maybe_add_string (ret, order_notes_string, gncOrderGetNotes (order)); maybe_add_string (ret, order_reference_string, gncOrderGetReference (order)); xmlAddChild(ret, int_to_dom_tree(order_active_string, gncOrderGetActive (order))); kf = qof_instance_get_slots (QOF_INSTANCE(order)); if (kf) { xmlNodePtr kvpnode = kvp_frame_to_dom_tree(order_slots_string, kf); if (kvpnode) { xmlAddChild(ret, kvpnode); } } return ret; }
static xmlNodePtr order_dom_tree_create (GncOrder* order) { xmlNodePtr ret; time64 tt; ret = xmlNewNode (NULL, BAD_CAST gnc_order_string); xmlSetProp (ret, BAD_CAST "version", BAD_CAST order_version_string); xmlAddChild (ret, guid_to_dom_tree (order_guid_string, qof_instance_get_guid (QOF_INSTANCE (order)))); xmlAddChild (ret, text_to_dom_tree (order_id_string, gncOrderGetID (order))); xmlAddChild (ret, gnc_owner_to_dom_tree (order_owner_string, gncOrderGetOwner (order))); tt = gncOrderGetDateOpened (order); xmlAddChild (ret, time64_to_dom_tree (order_opened_string, tt)); tt = gncOrderGetDateClosed (order); if (tt != INT64_MAX) xmlAddChild (ret, time64_to_dom_tree (order_closed_string, tt)); maybe_add_string (ret, order_notes_string, gncOrderGetNotes (order)); maybe_add_string (ret, order_reference_string, gncOrderGetReference (order)); xmlAddChild (ret, int_to_dom_tree (order_active_string, gncOrderGetActive (order))); /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */ xmlAddChild (ret, qof_instance_slots_to_dom_tree (order_slots_string, QOF_INSTANCE (order))); return ret; }