xmlNodePtr gnc_lot_dom_tree_create(GNCLot *lot) { xmlNodePtr ret; kvp_frame *kf; ENTER("(lot=%p)", lot); ret = xmlNewNode(NULL, BAD_CAST gnc_lot_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST lot_version_string); xmlAddChild(ret, guid_to_dom_tree(lot_id_string, gnc_lot_get_guid(lot))); kf = gnc_lot_get_slots (lot); if (kf) { xmlNodePtr kvpnode = kvp_frame_to_dom_tree(lot_slots_string, kf); if (kvpnode) { xmlAddChild(ret, kvpnode); } } LEAVE(""); return ret; }
xmlNodePtr gnc_lot_dom_tree_create(GNCLot *lot) { xmlNodePtr ret; ENTER("(lot=%p)", lot); ret = xmlNewNode(NULL, BAD_CAST gnc_lot_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST lot_version_string); xmlAddChild(ret, guid_to_dom_tree(lot_id_string, gnc_lot_get_guid(lot))); /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */ xmlAddChild(ret, qof_instance_slots_to_dom_tree(lot_slots_string, QOF_INSTANCE(lot))); LEAVE(""); return ret; }
static xmlNodePtr invoice_dom_tree_create (GncInvoice* invoice) { xmlNodePtr ret; Timespec ts; Transaction* txn; GNCLot* lot; Account* acc; GncBillTerm* term; GncOwner* billto; gnc_numeric amt; ret = xmlNewNode (NULL, BAD_CAST gnc_invoice_string); xmlSetProp (ret, BAD_CAST "version", BAD_CAST invoice_version_string); xmlAddChild (ret, guid_to_dom_tree (invoice_guid_string, qof_instance_get_guid (QOF_INSTANCE (invoice)))); xmlAddChild (ret, text_to_dom_tree (invoice_id_string, gncInvoiceGetID (invoice))); xmlAddChild (ret, gnc_owner_to_dom_tree (invoice_owner_string, gncInvoiceGetOwner (invoice))); ts = gncInvoiceGetDateOpened (invoice); xmlAddChild (ret, timespec_to_dom_tree (invoice_opened_string, &ts)); maybe_add_timespec (ret, invoice_posted_string, gncInvoiceGetDatePosted (invoice)); term = gncInvoiceGetTerms (invoice); if (term) xmlAddChild (ret, guid_to_dom_tree (invoice_terms_string, qof_instance_get_guid (QOF_INSTANCE (term)))); maybe_add_string (ret, invoice_billing_id_string, gncInvoiceGetBillingID (invoice)); maybe_add_string (ret, invoice_notes_string, gncInvoiceGetNotes (invoice)); xmlAddChild (ret, int_to_dom_tree (invoice_active_string, gncInvoiceGetActive (invoice))); txn = gncInvoiceGetPostedTxn (invoice); if (txn) xmlAddChild (ret, guid_to_dom_tree (invoice_posttxn_string, xaccTransGetGUID (txn))); lot = gncInvoiceGetPostedLot (invoice); if (lot) xmlAddChild (ret, guid_to_dom_tree (invoice_postlot_string, gnc_lot_get_guid (lot))); acc = gncInvoiceGetPostedAcc (invoice); if (acc) xmlAddChild (ret, guid_to_dom_tree (invoice_postacc_string, qof_instance_get_guid (QOF_INSTANCE (acc)))); xmlAddChild (ret, commodity_ref_to_dom_tree (invoice_currency_string, gncInvoiceGetCurrency (invoice))); billto = gncInvoiceGetBillTo (invoice); if (billto && billto->owner.undefined != NULL) xmlAddChild (ret, gnc_owner_to_dom_tree (invoice_billto_string, billto)); amt = gncInvoiceGetToChargeAmount (invoice); if (! gnc_numeric_zero_p (amt)) xmlAddChild (ret, gnc_numeric_to_dom_tree (invoice_tochargeamt_string, &amt)); /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */ xmlAddChild (ret, qof_instance_slots_to_dom_tree (invoice_slots_string, QOF_INSTANCE (invoice))); return ret; }
static xmlNodePtr split_to_dom_tree(const gchar *tag, Split *spl) { xmlNodePtr ret; ret = xmlNewNode(NULL, BAD_CAST tag); xmlAddChild(ret, guid_to_dom_tree("split:id", xaccSplitGetGUID(spl))); { char *memo = g_strdup (xaccSplitGetMemo(spl)); if (memo && g_strcmp0(memo, "") != 0) { xmlNewTextChild(ret, NULL, BAD_CAST "split:memo", checked_char_cast (memo)); } g_free (memo); } { char *action = g_strdup (xaccSplitGetAction(spl)); if (action && g_strcmp0(action, "") != 0) { xmlNewTextChild(ret, NULL, BAD_CAST "split:action", checked_char_cast (action)); } g_free (action); } { char tmp[2]; tmp[0] = xaccSplitGetReconcile(spl); tmp[1] = '\0'; xmlNewTextChild(ret, NULL, BAD_CAST "split:reconciled-state", BAD_CAST tmp); } add_timespec(ret, "split:reconcile-date", xaccSplitRetDateReconciledTS(spl), FALSE); add_gnc_num(ret, "split:value", xaccSplitGetValue(spl)); add_gnc_num(ret, "split:quantity", xaccSplitGetAmount(spl)); { Account * account = xaccSplitGetAccount (spl); xmlAddChild (ret, guid_to_dom_tree("split:account", xaccAccountGetGUID (account))); } { GNCLot * lot = xaccSplitGetLot (spl); if (lot) { xmlAddChild (ret, guid_to_dom_tree("split:lot", gnc_lot_get_guid(lot))); } } { xmlNodePtr kvpnode = kvp_frame_to_dom_tree("split:slots", xaccSplitGetSlots(spl)); if (kvpnode) { xmlAddChild(ret, kvpnode); } } return ret; }
static xmlNodePtr split_to_dom_tree (const gchar* tag, Split* spl) { xmlNodePtr ret; ret = xmlNewNode (NULL, BAD_CAST tag); xmlAddChild (ret, guid_to_dom_tree ("split:id", xaccSplitGetGUID (spl))); { char* memo = g_strdup (xaccSplitGetMemo (spl)); if (memo && g_strcmp0 (memo, "") != 0) { xmlNewTextChild (ret, NULL, BAD_CAST "split:memo", checked_char_cast (memo)); } g_free (memo); } { char* action = g_strdup (xaccSplitGetAction (spl)); if (action && g_strcmp0 (action, "") != 0) { xmlNewTextChild (ret, NULL, BAD_CAST "split:action", checked_char_cast (action)); } g_free (action); } { char tmp[2]; tmp[0] = xaccSplitGetReconcile (spl); tmp[1] = '\0'; xmlNewTextChild (ret, NULL, BAD_CAST "split:reconciled-state", BAD_CAST tmp); } add_timespec (ret, "split:reconcile-date", xaccSplitRetDateReconciledTS (spl), FALSE); add_gnc_num (ret, "split:value", xaccSplitGetValue (spl)); add_gnc_num (ret, "split:quantity", xaccSplitGetAmount (spl)); { Account* account = xaccSplitGetAccount (spl); xmlAddChild (ret, guid_to_dom_tree ("split:account", xaccAccountGetGUID (account))); } { GNCLot* lot = xaccSplitGetLot (spl); if (lot) { xmlAddChild (ret, guid_to_dom_tree ("split:lot", gnc_lot_get_guid (lot))); } } /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */ xmlAddChild (ret, qof_instance_slots_to_dom_tree ("split:slots", QOF_INSTANCE (spl))); return ret; }