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 xmlNodePtr employee_dom_tree_create (GncEmployee *employee) { xmlNodePtr ret, kvpnode; gnc_numeric num; Account* ccard_acc; ret = xmlNewNode(NULL, BAD_CAST gnc_employee_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST employee_version_string); xmlAddChild(ret, guid_to_dom_tree(employee_guid_string, qof_instance_get_guid(QOF_INSTANCE (employee)))); xmlAddChild(ret, text_to_dom_tree(employee_username_string, gncEmployeeGetUsername (employee))); xmlAddChild(ret, text_to_dom_tree(employee_id_string, gncEmployeeGetID (employee))); xmlAddChild(ret, gnc_address_to_dom_tree(employee_addr_string, gncEmployeeGetAddr (employee))); maybe_add_string (ret, employee_language_string, gncEmployeeGetLanguage (employee)); maybe_add_string (ret, employee_acl_string, gncEmployeeGetAcl (employee)); xmlAddChild(ret, int_to_dom_tree(employee_active_string, gncEmployeeGetActive (employee))); num = gncEmployeeGetWorkday (employee); xmlAddChild(ret, gnc_numeric_to_dom_tree (employee_workday_string, &num)); num = gncEmployeeGetRate (employee); xmlAddChild(ret, gnc_numeric_to_dom_tree (employee_rate_string, &num)); xmlAddChild (ret, commodity_ref_to_dom_tree(employee_currency_string, gncEmployeeGetCurrency (employee))); ccard_acc = gncEmployeeGetCCard (employee); if (ccard_acc) xmlAddChild(ret, guid_to_dom_tree(employee_ccard_string, qof_instance_get_guid(QOF_INSTANCE(ccard_acc)))); kvpnode = kvp_frame_to_dom_tree (employee_slots_string, qof_instance_get_slots (QOF_INSTANCE(employee))); if (kvpnode) xmlAddChild (ret, kvpnode); return ret; }
xmlNodePtr gnc_budget_dom_tree_create (GncBudget* bgt) { xmlNodePtr ret; ENTER ("(budget=%p)", bgt); ret = xmlNewNode (NULL, BAD_CAST gnc_budget_string); xmlSetProp (ret, BAD_CAST "version", BAD_CAST budget_version_string); /* field: GncGUID */ xmlAddChild (ret, guid_to_dom_tree (bgt_id_string, gnc_budget_get_guid (bgt))); /* field: char* name */ xmlAddChild (ret, text_to_dom_tree (bgt_name_string, gnc_budget_get_name (bgt))); /* field: char* description */ xmlAddChild (ret, text_to_dom_tree (bgt_description_string, gnc_budget_get_description (bgt))); /* field: guint num_periods */ xmlAddChild (ret, guint_to_dom_tree (bgt_num_periods_string, gnc_budget_get_num_periods (bgt))); /* field: Recurrence* */ xmlAddChild (ret, recurrence_to_dom_tree (bgt_recurrence_string, gnc_budget_get_recurrence (bgt))); /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */ xmlAddChild (ret, qof_instance_slots_to_dom_tree (bgt_slots_string, QOF_INSTANCE (bgt))); LEAVE (" "); return ret; }
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_owner_to_dom_tree (const char* tag, const GncOwner* owner) { xmlNodePtr ret; const char* type_str; switch (gncOwnerGetType (owner)) { case GNC_OWNER_CUSTOMER: type_str = GNC_ID_CUSTOMER; break; case GNC_OWNER_JOB: type_str = GNC_ID_JOB; break; case GNC_OWNER_VENDOR: type_str = GNC_ID_VENDOR; break; case GNC_OWNER_EMPLOYEE: type_str = GNC_ID_EMPLOYEE; break; default: PWARN ("Invalid owner type: %d", gncOwnerGetType (owner)); return NULL; } ret = xmlNewNode (NULL, BAD_CAST tag); xmlSetProp (ret, BAD_CAST "version", BAD_CAST owner_version_string); xmlAddChild (ret, text_to_dom_tree (owner_type_string, type_str)); xmlAddChild (ret, guid_to_dom_tree (owner_id_string, gncOwnerGetGUID (owner))); return ret; }
static void test_dom_tree_to_guid(void) { int i; for (i = 0; i < 20; i++) { GncGUID *test_guid1; GncGUID *test_guid2; xmlNodePtr test_node; test_guid1 = get_random_guid(); if (!(test_node = guid_to_dom_tree("test-guid", test_guid1))) { failure_args("guid_to_dom_tree", __FILE__, __LINE__, "conversion to dom tree failed"); } test_guid2 = dom_tree_to_guid(test_node); do_test(guid_equal(test_guid1, test_guid2), "dom_tree_to_guid" ); xmlFreeNode(test_node); g_free(test_guid1); g_free(test_guid2); } }
gboolean write_book_parts(FILE *out, QofBook *book) { xmlNodePtr domnode; domnode = guid_to_dom_tree(book_id_string, qof_book_get_guid(book)); xmlElemDump(out, NULL, domnode); xmlFreeNode (domnode); if (ferror(out) || fprintf(out, "\n") < 0) return FALSE; if (qof_instance_get_slots (QOF_INSTANCE (book))) { xmlNodePtr kvpnode = kvp_frame_to_dom_tree(book_slots_string, qof_instance_get_slots (QOF_INSTANCE (book))); if (kvpnode) { xmlElemDump(out, NULL, kvpnode); xmlFreeNode(kvpnode); if (ferror(out) || fprintf(out, "\n") < 0) return FALSE; } } return TRUE; }
static xmlNodePtr job_dom_tree_create (GncJob *job) { xmlNodePtr ret; ret = xmlNewNode(NULL, BAD_CAST gnc_job_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST job_version_string); xmlAddChild(ret, guid_to_dom_tree(job_guid_string, qof_instance_get_guid (QOF_INSTANCE (job)))); xmlAddChild(ret, text_to_dom_tree(job_id_string, gncJobGetID (job))); xmlAddChild(ret, text_to_dom_tree(job_name_string, gncJobGetName (job))); maybe_add_string (ret, job_reference_string, gncJobGetReference (job)); xmlAddChild(ret, gnc_owner_to_dom_tree (job_owner_string, gncJobGetOwner (job))); xmlAddChild(ret, int_to_dom_tree(job_active_string, gncJobGetActive (job))); return ret; }
static void maybe_add_guid (xmlNodePtr ptr, const char *tag, GncTaxTable *table) { if (table) xmlAddChild (ptr, guid_to_dom_tree (tag, qof_instance_get_guid(QOF_INSTANCE(table)))); }
static xmlNodePtr gnc_price_to_dom_tree(const xmlChar *tag, GNCPrice *price) { xmlNodePtr price_xml; const gchar *typestr, *sourcestr; xmlNodePtr tmpnode; gnc_commodity *commodity; gnc_commodity *currency; Timespec timesp; gnc_numeric value; if (!(tag && price)) return NULL; price_xml = xmlNewNode(NULL, tag); if (!price_xml) return NULL; commodity = gnc_price_get_commodity(price); currency = gnc_price_get_currency(price); if (!(commodity && currency)) return NULL; tmpnode = guid_to_dom_tree("price:id", gnc_price_get_guid(price)); if (!add_child_or_kill_parent(price_xml, tmpnode)) return NULL; tmpnode = commodity_ref_to_dom_tree("price:commodity", commodity); if (!add_child_or_kill_parent(price_xml, tmpnode)) return NULL; tmpnode = commodity_ref_to_dom_tree("price:currency", currency); if (!add_child_or_kill_parent(price_xml, tmpnode)) return NULL; timesp = gnc_price_get_time(price); tmpnode = timespec_to_dom_tree("price:time", ×p); if (!add_child_or_kill_parent(price_xml, tmpnode)) return NULL; sourcestr = gnc_price_get_source(price); if (sourcestr && (strlen(sourcestr) != 0)) { tmpnode = text_to_dom_tree("price:source", sourcestr); if (!add_child_or_kill_parent(price_xml, tmpnode)) return NULL; } typestr = gnc_price_get_typestr(price); if (typestr && (strlen(typestr) != 0)) { tmpnode = text_to_dom_tree("price:type", typestr); if (!add_child_or_kill_parent(price_xml, tmpnode)) return NULL; } value = gnc_price_get_value(price); tmpnode = gnc_numeric_to_dom_tree("price:value", &value); if (!add_child_or_kill_parent(price_xml, tmpnode)) return NULL; return price_xml; }
xmlNodePtr gnc_transaction_dom_tree_create(Transaction *trn) { xmlNodePtr ret; gchar *str = NULL; ret = xmlNewNode(NULL, BAD_CAST "gnc:transaction"); xmlSetProp(ret, BAD_CAST "version", BAD_CAST transaction_version_string); xmlAddChild(ret, guid_to_dom_tree("trn:id", xaccTransGetGUID(trn))); xmlAddChild(ret, commodity_ref_to_dom_tree("trn:currency", xaccTransGetCurrency(trn))); str = g_strdup (xaccTransGetNum(trn)); if (str && (g_strcmp0(str, "") != 0)) { xmlNewTextChild(ret, NULL, BAD_CAST "trn:num", checked_char_cast (str)); } g_free (str); add_timespec(ret, "trn:date-posted", xaccTransRetDatePostedTS(trn), TRUE); add_timespec(ret, "trn:date-entered", xaccTransRetDateEnteredTS(trn), TRUE); str = g_strdup (xaccTransGetDescription(trn)); if (str) { xmlNewTextChild(ret, NULL, BAD_CAST "trn:description", checked_char_cast (str)); } g_free (str); { xmlNodePtr kvpnode = kvp_frame_to_dom_tree("trn:slots", xaccTransGetSlots(trn)); if (kvpnode) { xmlAddChild(ret, kvpnode); } } add_trans_splits(ret, trn); return ret; }
xmlNodePtr gnc_book_dom_tree_create(QofBook *book) { xmlNodePtr ret; G_GNUC_UNUSED gboolean allow_incompat = TRUE; ret = xmlNewNode(NULL, BAD_CAST gnc_book_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST gnc_v2_book_version_string); xmlAddChild(ret, guid_to_dom_tree(book_id_string, qof_book_get_guid(book))); if (qof_instance_get_slots (QOF_INSTANCE (book))) { xmlNodePtr kvpnode = kvp_frame_to_dom_tree(book_slots_string, qof_instance_get_slots (QOF_INSTANCE (book))); if (kvpnode) xmlAddChild(ret, kvpnode); } #ifdef IMPLEMENT_BOOK_DOM_TREES_LATER /* theoretically, we should be adding all the below to the book * but in fact, there's enough brain damage in the code already * that we are only going to hand-edit the file at a higher layer. * And that's OK, since its probably a performance boost anyway. */ xmlAddChild(ret, gnc_commodity_dom_tree_create( gnc_commodity_table_get_table(book))); xmlAddChild(ret, gnc_pricedb_dom_tree_create(gnc_pricedb_get_db(book))); if (allow_incompat) { accnode = gnc_account_dom_tree_create(account, FALSE); xmlAddChild (ret, rootAccNode); } append_account_tree (ret, gnc_book_get_root(book)); xaccAccountTreeForEachTransaction (gnc_book_get_root_account(book), traverse_txns, ret); /* xxx FIXME hack alert how are we going to handle * gnc_book_get_template_group handled ??? */ xmlAddChild(ret, gnc_schedXaction_dom_tree_create( gnc_book_get_schedxactions(book))); #endif 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; }
xmlNodePtr gnc_transaction_dom_tree_create (Transaction* trn) { xmlNodePtr ret; gchar* str = NULL; ret = xmlNewNode (NULL, BAD_CAST "gnc:transaction"); xmlSetProp (ret, BAD_CAST "version", BAD_CAST transaction_version_string); xmlAddChild (ret, guid_to_dom_tree ("trn:id", xaccTransGetGUID (trn))); xmlAddChild (ret, commodity_ref_to_dom_tree ("trn:currency", xaccTransGetCurrency (trn))); str = g_strdup (xaccTransGetNum (trn)); if (str && (g_strcmp0 (str, "") != 0)) { xmlNewTextChild (ret, NULL, BAD_CAST "trn:num", checked_char_cast (str)); } g_free (str); add_timespec (ret, "trn:date-posted", xaccTransRetDatePostedTS (trn), TRUE); add_timespec (ret, "trn:date-entered", xaccTransRetDateEnteredTS (trn), TRUE); str = g_strdup (xaccTransGetDescription (trn)); if (str) { xmlNewTextChild (ret, NULL, BAD_CAST "trn:description", checked_char_cast (str)); } g_free (str); /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */ xmlAddChild (ret, qof_instance_slots_to_dom_tree ("trn:slots", QOF_INSTANCE (trn))); add_trans_splits (ret, trn); return ret; }
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 ttentry_dom_tree_create (GncTaxTableEntry *entry) { xmlNodePtr ret; Account *account; gnc_numeric amount; ret = xmlNewNode(NULL, BAD_CAST gnc_taxtableentry_string); account = gncTaxTableEntryGetAccount (entry); if (account) xmlAddChild(ret, guid_to_dom_tree (ttentry_account_string, qof_instance_get_guid (QOF_INSTANCE(account)))); amount = gncTaxTableEntryGetAmount (entry); xmlAddChild (ret, gnc_numeric_to_dom_tree (ttentry_amount_string, &amount)); xmlAddChild(ret, text_to_dom_tree (ttentry_type_string, gncAmountTypeToString ( gncTaxTableEntryGetType (entry)))); 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; }
static xmlNodePtr customer_dom_tree_create (GncCustomer *cust) { xmlNodePtr ret, kvpnode; gnc_numeric num; GncBillTerm *term; GncTaxTable *taxtable; ret = xmlNewNode(NULL, BAD_CAST gnc_customer_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST customer_version_string); xmlAddChild(ret, guid_to_dom_tree(cust_guid_string, qof_instance_get_guid(QOF_INSTANCE(cust)))); xmlAddChild(ret, text_to_dom_tree(cust_name_string, gncCustomerGetName (cust))); xmlAddChild(ret, text_to_dom_tree(cust_id_string, gncCustomerGetID (cust))); xmlAddChild(ret, gnc_address_to_dom_tree(cust_addr_string, gncCustomerGetAddr (cust))); xmlAddChild(ret, gnc_address_to_dom_tree(cust_shipaddr_string, gncCustomerGetShipAddr (cust))); maybe_add_string (ret, cust_notes_string, gncCustomerGetNotes (cust)); term = gncCustomerGetTerms (cust); if (term) xmlAddChild(ret, guid_to_dom_tree(cust_terms_string, qof_instance_get_guid (QOF_INSTANCE(term)))); xmlAddChild(ret, text_to_dom_tree(cust_taxincluded_string, gncTaxIncludedTypeToString ( gncCustomerGetTaxIncluded (cust)))); xmlAddChild(ret, int_to_dom_tree(cust_active_string, gncCustomerGetActive (cust))); num = gncCustomerGetDiscount (cust); xmlAddChild(ret, gnc_numeric_to_dom_tree(cust_discount_string, &num)); num = gncCustomerGetCredit (cust); xmlAddChild(ret, gnc_numeric_to_dom_tree(cust_credit_string, &num)); xmlAddChild (ret, commodity_ref_to_dom_tree(cust_currency_string, gncCustomerGetCurrency (cust))); xmlAddChild (ret, int_to_dom_tree (cust_taxtableoverride_string, gncCustomerGetTaxTableOverride (cust))); taxtable = gncCustomerGetTaxTable (cust); if (taxtable) xmlAddChild (ret, guid_to_dom_tree (cust_taxtable_string, qof_instance_get_guid(QOF_INSTANCE(taxtable)))); kvpnode = kvp_frame_to_dom_tree (cust_slots_string, qof_instance_get_slots (QOF_INSTANCE(cust))); if (kvpnode) xmlAddChild (ret, kvpnode); return ret; }
static xmlNodePtr entry_dom_tree_create (GncEntry *entry) { xmlNodePtr ret; Timespec ts; Account *acc; GncTaxTable *taxtable; GncOrder *order; GncInvoice *invoice; kvp_frame *kf; ret = xmlNewNode(NULL, BAD_CAST gnc_entry_string); xmlSetProp(ret, BAD_CAST "version", BAD_CAST entry_version_string); xmlAddChild(ret, guid_to_dom_tree(entry_guid_string, qof_instance_get_guid(QOF_INSTANCE(entry)))); ts = gncEntryGetDate (entry); xmlAddChild(ret, timespec_to_dom_tree (entry_date_string, &ts)); ts = gncEntryGetDateEntered (entry); xmlAddChild(ret, timespec_to_dom_tree (entry_dateentered_string, &ts)); maybe_add_string (ret, entry_description_string, gncEntryGetDescription (entry)); maybe_add_string (ret, entry_action_string, gncEntryGetAction (entry)); maybe_add_string (ret, entry_notes_string, gncEntryGetNotes (entry)); maybe_add_numeric (ret, entry_qty_string, gncEntryGetQuantity (entry)); /* cust invoice */ acc = gncEntryGetInvAccount (entry); if (acc) xmlAddChild (ret, guid_to_dom_tree (entry_invacct_string, qof_instance_get_guid(QOF_INSTANCE(acc)))); maybe_add_numeric (ret, entry_iprice_string, gncEntryGetInvPrice (entry)); maybe_add_numeric (ret, entry_idiscount_string, gncEntryGetInvDiscount (entry)); invoice = gncEntryGetInvoice (entry); if (invoice) { xmlAddChild (ret, guid_to_dom_tree (entry_invoice_string, qof_instance_get_guid(QOF_INSTANCE(invoice)))); xmlAddChild(ret, text_to_dom_tree(entry_idisctype_string, gncAmountTypeToString ( gncEntryGetInvDiscountType (entry)))); xmlAddChild(ret, text_to_dom_tree(entry_idischow_string, gncEntryDiscountHowToString ( gncEntryGetInvDiscountHow (entry)))); xmlAddChild(ret, int_to_dom_tree(entry_itaxable_string, gncEntryGetInvTaxable (entry))); xmlAddChild(ret, int_to_dom_tree(entry_itaxincluded_string, gncEntryGetInvTaxIncluded (entry))); } taxtable = gncEntryGetInvTaxTable (entry); if (taxtable) xmlAddChild (ret, guid_to_dom_tree (entry_itaxtable_string, qof_instance_get_guid (QOF_INSTANCE(taxtable)))); /* vendor bills */ acc = gncEntryGetBillAccount (entry); if (acc) xmlAddChild (ret, guid_to_dom_tree (entry_billacct_string, qof_instance_get_guid (QOF_INSTANCE(acc)))); maybe_add_numeric (ret, entry_bprice_string, gncEntryGetBillPrice (entry)); invoice = gncEntryGetBill (entry); if (invoice) { GncOwner *owner; xmlAddChild (ret, guid_to_dom_tree (entry_bill_string, qof_instance_get_guid(QOF_INSTANCE(invoice)))); xmlAddChild(ret, int_to_dom_tree(entry_billable_string, gncEntryGetBillable (entry))); owner = gncEntryGetBillTo (entry); if (owner && owner->owner.undefined != NULL) xmlAddChild (ret, gnc_owner_to_dom_tree (entry_billto_string, owner)); xmlAddChild(ret, int_to_dom_tree(entry_btaxable_string, gncEntryGetBillTaxable (entry))); xmlAddChild(ret, int_to_dom_tree(entry_btaxincluded_string, gncEntryGetBillTaxIncluded (entry))); maybe_add_string (ret, entry_billpayment_string, gncEntryPaymentTypeToString (gncEntryGetBillPayment (entry))); } taxtable = gncEntryGetBillTaxTable (entry); if (taxtable) xmlAddChild (ret, guid_to_dom_tree (entry_btaxtable_string, qof_instance_get_guid (QOF_INSTANCE(taxtable)))); /* Other stuff */ order = gncEntryGetOrder (entry); if (order) xmlAddChild (ret, guid_to_dom_tree (entry_order_string, qof_instance_get_guid(QOF_INSTANCE (order)))); kf = qof_instance_get_slots (QOF_INSTANCE(entry)); if (kf) { xmlNodePtr kvpnode = kvp_frame_to_dom_tree(entry_slots_string, kf); 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; }
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; }
xmlNodePtr gnc_schedXaction_dom_tree_create(SchedXaction *sx) { xmlNodePtr ret; const GDate *date; gint instCount; const GncGUID *templ_acc_guid; gboolean allow_2_2_incompat = TRUE; gchar *name = g_strdup (xaccSchedXactionGetName(sx)); templ_acc_guid = xaccAccountGetGUID(sx->template_acct); /* FIXME: this should be the same as the def in io-gncxml-v2.c */ ret = xmlNewNode (NULL, BAD_CAST GNC_SCHEDXACTION_TAG); if (allow_2_2_incompat) xmlSetProp(ret, BAD_CAST "version", BAD_CAST schedxaction_version2_string); else xmlSetProp(ret, BAD_CAST "version", BAD_CAST schedxaction_version_string); xmlAddChild( ret, guid_to_dom_tree(SX_ID, xaccSchedXactionGetGUID(sx)) ); xmlNewTextChild( ret, NULL, BAD_CAST SX_NAME, checked_char_cast (name)); g_free (name); if (allow_2_2_incompat) { xmlNewTextChild( ret, NULL, BAD_CAST SX_ENABLED, BAD_CAST ( sx->enabled ? "y" : "n" ) ); } xmlNewTextChild( ret, NULL, BAD_CAST SX_AUTOCREATE, BAD_CAST ( sx->autoCreateOption ? "y" : "n" ) ); xmlNewTextChild( ret, NULL, BAD_CAST SX_AUTOCREATE_NOTIFY, BAD_CAST ( sx->autoCreateNotify ? "y" : "n" ) ); xmlAddChild(ret, int_to_dom_tree(SX_ADVANCE_CREATE_DAYS, sx->advanceCreateDays)); xmlAddChild(ret, int_to_dom_tree(SX_ADVANCE_REMIND_DAYS, sx->advanceRemindDays)); instCount = gnc_sx_get_instance_count( sx, NULL ); xmlAddChild( ret, int_to_dom_tree( SX_INSTANCE_COUNT, instCount ) ); xmlAddChild( ret, gdate_to_dom_tree( SX_START, xaccSchedXactionGetStartDate(sx) ) ); date = xaccSchedXactionGetLastOccurDate(sx); if ( g_date_valid( date ) ) { xmlAddChild( ret, gdate_to_dom_tree( SX_LAST, date ) ); } if ( xaccSchedXactionHasOccurDef(sx) ) { xmlAddChild(ret, int_to_dom_tree( SX_NUM_OCCUR, xaccSchedXactionGetNumOccur(sx))); xmlAddChild(ret, int_to_dom_tree( SX_REM_OCCUR, xaccSchedXactionGetRemOccur(sx))); } else if ( xaccSchedXactionHasEndDate(sx) ) { xmlAddChild( ret, gdate_to_dom_tree( SX_END, xaccSchedXactionGetEndDate(sx) ) ); } /* output template account GncGUID */ xmlAddChild( ret, guid_to_dom_tree(SX_TEMPL_ACCT, templ_acc_guid)); if (allow_2_2_incompat) { xmlNodePtr schedule_node = xmlNewNode(NULL, BAD_CAST "sx:schedule"); GList *schedule = gnc_sx_get_schedule(sx); for (; schedule != NULL; schedule = schedule->next) { xmlAddChild(schedule_node, recurrence_to_dom_tree("gnc:recurrence", (Recurrence*)schedule->data)); } xmlAddChild(ret, schedule_node); } /* Output deferred-instance list. */ { xmlNodePtr instNode; SXTmpStateData *tsd; GList *l; for ( l = gnc_sx_get_defer_instances( sx ); l; l = l->next ) { tsd = (SXTmpStateData*)l->data; instNode = xmlNewNode( NULL, BAD_CAST SX_DEFER_INSTANCE ); if ( g_date_valid( &tsd->last_date ) ) { xmlAddChild( instNode, gdate_to_dom_tree( SX_LAST, &tsd->last_date ) ); } xmlAddChild( instNode, int_to_dom_tree( SX_REM_OCCUR, tsd->num_occur_rem ) ); xmlAddChild( instNode, int_to_dom_tree( SX_INSTANCE_COUNT, tsd->num_inst ) ); xmlAddChild( ret, instNode ); } } /* output kvp_frame */ { xmlNodePtr kvpnode = kvp_frame_to_dom_tree( SX_SLOTS, xaccSchedXactionGetSlots(sx) ); 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))); } } { xmlNodePtr kvpnode = kvp_frame_to_dom_tree("split:slots", xaccSplitGetSlots(spl)); if (kvpnode) { xmlAddChild(ret, kvpnode); } } return ret; }