コード例 #1
0
ファイル: import-utilities.c プロジェクト: KhazMcdust/gnucash
/* Not actually used */
void gnc_import_set_trans_online_id(Transaction * transaction,
                                    const gchar * string_value)
{
    kvp_frame * frame;
    xaccTransBeginEdit (transaction);
    frame = xaccTransGetSlots(transaction);
    kvp_frame_set_str (frame, "online_id", string_value);
    qof_instance_set_dirty (QOF_INSTANCE (transaction));
    xaccTransCommitEdit (transaction);
}
コード例 #2
0
ファイル: gnc-transaction-xml-v2.c プロジェクト: 573/gnucash
static gboolean
trn_slots_handler(xmlNodePtr node, gpointer trans_pdata)
{
    struct trans_pdata *pdata = trans_pdata;
    Transaction *trn = pdata->trans;
    gboolean successful;

    successful = dom_tree_to_kvp_frame_given(node, xaccTransGetSlots(trn));

    g_return_val_if_fail(successful, FALSE);

    return TRUE;
}
コード例 #3
0
ファイル: gnc-transaction-xml-v2.c プロジェクト: 573/gnucash
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;
}
コード例 #4
0
static gchar*
node_and_transaction_equal(xmlNodePtr node, Transaction *trn)
{
    xmlNodePtr mark;

    while (safe_strcmp ((char*)node->name, "text") == 0)
        node = node->next;

    if (!check_dom_tree_version(node, "2.0.0"))
    {
        return "version wrong.  Not 2.0.0 or not there";
    }

    if (!node->name || safe_strcmp((char*)node->name, "gnc:transaction"))
    {
        return "Name of toplevel node is bad";
    }

    for (mark = node->xmlChildrenNode; mark; mark = mark->next)
    {
        if (safe_strcmp((char*)mark->name, "text") == 0)
        {
        }
        else if (safe_strcmp((char*)mark->name, "trn:id") == 0)
        {
            if (!equals_node_val_vs_guid(mark, xaccTransGetGUID(trn)))
            {
                return "ids differ";
            }
        }

        /* This test will fail for many splits where the transaction has
         * splits in different commodities -- eg, buying or selling a
         * stock. jralls 2010-11-02 */
        else if (safe_strcmp((char*)mark->name, "trn:currency") == 0)
        {
#if 0
            if (!equals_node_val_vs_commodity(
                        mark, xaccTransGetCurrency(trn), xaccTransGetBook(trn)))
            {
                return g_strdup("currencies differ");
            }
#endif
        }
        else if (safe_strcmp((char*)mark->name, "trn:num") == 0)
        {
            if (!equals_node_val_vs_string(mark, xaccTransGetNum(trn)))
            {
                return "nums differ";
            }
        }
        else if (safe_strcmp((char*)mark->name, "trn:date-posted") == 0)
        {
            if (!equals_node_val_vs_date(mark, xaccTransRetDatePostedTS(trn)))
            {
                return "posted dates differ";
            }
        }
        else if (safe_strcmp((char*)mark->name, "trn:date-entered") == 0)
        {
            if (!equals_node_val_vs_date(mark, xaccTransRetDateEnteredTS(trn)))
            {
                return "entered dates differ";
            }
        }
        else if (safe_strcmp((char*)mark->name, "trn:description") == 0)
        {
            if (!equals_node_val_vs_string(mark, xaccTransGetDescription(trn)))
            {
                return "descriptions differ";
            }
        }
        else if (safe_strcmp((char*)mark->name, "trn:slots") == 0)
        {
            if (!equals_node_val_vs_kvp_frame(mark, xaccTransGetSlots(trn)))
            {
                return "slots differ";
            }
        }
        else if (safe_strcmp((char*)mark->name, "trn:splits") == 0)
        {
            char *msg = equals_node_val_vs_splits (mark, trn);
            if (msg != NULL)
            {
                return msg;
            }
        }
        else
        {
            return "unknown node";
        }
    }

    return NULL;
}
コード例 #5
0
ファイル: import-utilities.c プロジェクト: KhazMcdust/gnucash
const gchar * gnc_import_get_trans_online_id(Transaction * transaction)
{
    kvp_frame * frame;
    frame = xaccTransGetSlots(transaction);
    return kvp_frame_get_string(frame, "online_id");
}