Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
xmlNodePtr
gnc_address_to_dom_tree (const char *tag, GncAddress *addr)
{
    xmlNodePtr ret;
    KvpFrame *kf;

    ret = xmlNewNode(NULL, BAD_CAST tag);
    xmlSetProp(ret, BAD_CAST "version", BAD_CAST address_version_string);

    maybe_add_string (ret, addr_name_string, gncAddressGetName (addr));

    maybe_add_string (ret, addr_addr1_string, gncAddressGetAddr1 (addr));
    maybe_add_string (ret, addr_addr2_string, gncAddressGetAddr2 (addr));
    maybe_add_string (ret, addr_addr3_string, gncAddressGetAddr3 (addr));
    maybe_add_string (ret, addr_addr4_string, gncAddressGetAddr4 (addr));

    maybe_add_string (ret, addr_phone_string, gncAddressGetPhone (addr));
    maybe_add_string (ret, addr_fax_string, gncAddressGetFax (addr));
    maybe_add_string (ret, addr_email_string, gncAddressGetEmail (addr));

    kf = qof_instance_get_slots (QOF_INSTANCE(addr));
    if (kf)
    {
        xmlNodePtr kvpnode = kvp_frame_to_dom_tree(addr_slots_string, kf);
        if (kvpnode)
        {
            xmlAddChild(ret, kvpnode);
        }
    }

    return ret;
}
Exemplo n.º 3
0
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;
}
Exemplo n.º 4
0
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;
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
xmlNodePtr
gnc_address_to_dom_tree (const char* tag, GncAddress* addr)
{
    xmlNodePtr ret;

    ret = xmlNewNode (NULL, BAD_CAST tag);
    xmlSetProp (ret, BAD_CAST "version", BAD_CAST address_version_string);

    maybe_add_string (ret, addr_name_string, gncAddressGetName (addr));

    maybe_add_string (ret, addr_addr1_string, gncAddressGetAddr1 (addr));
    maybe_add_string (ret, addr_addr2_string, gncAddressGetAddr2 (addr));
    maybe_add_string (ret, addr_addr3_string, gncAddressGetAddr3 (addr));
    maybe_add_string (ret, addr_addr4_string, gncAddressGetAddr4 (addr));

    maybe_add_string (ret, addr_phone_string, gncAddressGetPhone (addr));
    maybe_add_string (ret, addr_fax_string, gncAddressGetFax (addr));
    maybe_add_string (ret, addr_email_string, gncAddressGetEmail (addr));

    /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */
    xmlAddChild (ret, qof_instance_slots_to_dom_tree (addr_slots_string,
                                                      QOF_INSTANCE (addr)));
    return ret;
}
Exemplo n.º 8
0
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;
}
Exemplo n.º 9
0
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;
}
Exemplo n.º 10
0
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;
}