Exemple #1
0
void
xaccAccountScrubKvp (Account *account)
{
    const gchar *str;
    gchar *str2;
    KvpFrame *frame;

    if (!account) return;

    str = kvp_frame_get_string(account->inst.kvp_data, "notes");
    if (str)
    {
        str2 = g_strstrip(g_strdup(str));
        if (strlen(str2) == 0)
            kvp_frame_set_slot_nc (account->inst.kvp_data, "notes", NULL);
        g_free(str2);
    }

    str = kvp_frame_get_string(account->inst.kvp_data, "placeholder");
    if (str && strcmp(str, "false") == 0)
        kvp_frame_set_slot_nc (account->inst.kvp_data, "placeholder", NULL);

    frame = kvp_frame_get_frame(account->inst.kvp_data, "hbci");
    if (frame && kvp_frame_is_empty(frame))
    {
        kvp_frame_set_frame_nc(account->inst.kvp_data, "hbci", NULL);
    }
}
Exemple #2
0
/* This function implements a custom mapping between an owner's KVP
 * and the cell renderer's 'text' property. */
static void
owner_cell_kvp_data_func (GtkTreeViewColumn *tree_column,
                          GtkCellRenderer *cell,
                          GtkTreeModel *s_model,
                          GtkTreeIter *s_iter,
                          gpointer key)
{
    GncOwner *owner;
    kvp_frame * frame;

    g_return_if_fail (GTK_IS_TREE_MODEL_SORT (s_model));
    owner = gnc_tree_view_owner_get_owner_from_iter(s_model, s_iter);
    frame = gncOwnerGetSlots(owner);

    g_object_set (G_OBJECT (cell),
                  "text", kvp_frame_get_string(frame, (gchar *)key),
                  "xalign", 0.0,
                  NULL);

}
Exemple #3
0
const char*
qof_book_get_string_option(const QofBook* book, const char* opt_name)
{
    return kvp_frame_get_string(qof_book_get_slots(book), opt_name);
}
Exemple #4
0
void
xaccLotScrubDoubleBalance (GNCLot *lot)
{
    gnc_commodity *currency = NULL;
    SplitList *snode;
    GList *node;
    gnc_numeric zero = gnc_numeric_zero();
    gnc_numeric value = zero;

    if (!lot) return;

    ENTER ("lot=%s", kvp_frame_get_string (gnc_lot_get_slots (lot), "/title"));

    for (snode = gnc_lot_get_split_list(lot); snode; snode = snode->next)
    {
        Split *s = snode->data;
        xaccSplitComputeCapGains (s, NULL);
    }

    /* We double-check only closed lots */
    if (FALSE == gnc_lot_is_closed (lot)) return;

    for (snode = gnc_lot_get_split_list(lot); snode; snode = snode->next)
    {
        Split *s = snode->data;
        Transaction *trans = s->parent;

        /* Check to make sure all splits in the lot have a common currency */
        if (NULL == currency)
        {
            currency = trans->common_currency;
        }
        if (FALSE == gnc_commodity_equiv (currency, trans->common_currency))
        {
            /* This lot has mixed currencies. Can't double-balance.
             * Silently punt */
            PWARN ("Lot with multiple currencies:\n"
                   "\ttrans=%s curr=%s", xaccTransGetDescription(trans),
                   gnc_commodity_get_fullname(trans->common_currency));
            break;
        }

        /* Now, total up the values */
        value = gnc_numeric_add (value, xaccSplitGetValue (s),
                                 GNC_DENOM_AUTO, GNC_HOW_DENOM_EXACT);
        PINFO ("Split=%p value=%s Accum Lot value=%s", s,
               gnc_num_dbg_to_string (s->value),
               gnc_num_dbg_to_string (value));

    }

    if (FALSE == gnc_numeric_equal (value, zero))
    {
        /* Unhandled error condition. Not sure what to do here,
         * Since the ComputeCapGains should have gotten it right.
         * I suppose there might be small rounding errors, a penny or two,
         * the ideal thing would to figure out why there's a rounding
         * error, and fix that.
         */
        PERR ("Closed lot fails to double-balance !! lot value=%s",
              gnc_num_dbg_to_string (value));
        for (node = gnc_lot_get_split_list(lot); node; node = node->next)
        {
            Split *s = node->data;
            PERR ("s=%p amt=%s val=%s", s,
                  gnc_num_dbg_to_string(s->amount),
                  gnc_num_dbg_to_string(s->value));
        }
    }

    LEAVE ("lot=%s", kvp_frame_get_string (gnc_lot_get_slots (lot), "/title"));
}
Exemple #5
0
/* Set the option with the default KvpValue,
manipulate the option in the supplied callback routine
then set the value of the option into the KvpValue
in the configuration frame. */
static void
config_foreach_cb (const char *key, KvpValue *value, gpointer data)
{
    QofBackendOption option;
    gint64 int64;
    double db;
    gnc_numeric num;
    Timespec ts;
    gchar *parent;
    struct config_iterate *helper;

    g_return_if_fail(key || value || data);
    helper = (struct config_iterate*)data;
    if (!helper->recursive)
    {
        PERR (" no parent frame");
        return;
    }
    // skip the presets.
    if (0 == safe_strcmp(key, QOF_CONFIG_DESC))
    {
        return;
    }
    if (0 == safe_strcmp(key, QOF_CONFIG_TIP))
    {
        return;
    }
    ENTER (" key=%s", key);
    option.option_name = key;
    option.type = kvp_value_get_type(value);
    if (!option.type)
    {
        return;
    }
    switch (option.type)
    {
        /* set the KvpFrame value into the option */
    case KVP_TYPE_GINT64   :
    {
        int64 = kvp_value_get_gint64(value);
        option.value = (gpointer) & int64;
        break;
    }
    case KVP_TYPE_DOUBLE   :
    {
        db = kvp_value_get_double(value);
        option.value = (gpointer) & db;
        break;
    }
    case KVP_TYPE_NUMERIC  :
    {
        num = kvp_value_get_numeric(value);
        option.value = (gpointer) & num;
        break;
    }
    case KVP_TYPE_STRING   :
    {
        option.value = (gpointer)kvp_value_get_string(value);
        break;
    }
    case KVP_TYPE_TIMESPEC :
    {
        ts = kvp_value_get_timespec(value);
        option.value = (gpointer) & ts;
        break;
    }
    case KVP_TYPE_GUID     :
    {
        break;  /* unsupported */
    }
    case KVP_TYPE_BINARY   :
    {
        break;  /* unsupported */
    }
    case KVP_TYPE_GLIST    :
    {
        break;  /* unsupported */
    }
    case KVP_TYPE_FRAME    :
    {
        break;  /* unsupported */
    }
    case KVP_TYPE_GDATE    :
    {
        break;  /* unsupported */
    }
    }
    parent = g_strdup_printf("/%s/%s", QOF_CONFIG_DESC, key);
    option.description = kvp_frame_get_string(helper->recursive, parent);
    g_free(parent);
    parent = g_strdup_printf("/%s/%s", QOF_CONFIG_TIP, key);
    option.tooltip = kvp_frame_get_string(helper->recursive, parent);
    g_free(parent);
    helper->count++;
    /* manipulate the option */
    helper->fcn (&option, helper->data);
    switch (option.type)
    {
        /* set the option value into the KvpFrame */
    case KVP_TYPE_GINT64   :
    {
        kvp_frame_set_gint64(helper->recursive, key,
                             (*(gint64*)option.value));
        break;
    }
    case KVP_TYPE_DOUBLE   :
    {
        kvp_frame_set_double(helper->recursive, key,
                             (*(double*)option.value));
        break;
    }
    case KVP_TYPE_NUMERIC  :
    {
        kvp_frame_set_numeric(helper->recursive, key,
                              (*(gnc_numeric*)option.value));
        break;
    }
    case KVP_TYPE_STRING   :
    {
        kvp_frame_set_string(helper->recursive, key,
                             (gchar*)option.value);
        break;
    }
    case KVP_TYPE_TIMESPEC :
    {
        kvp_frame_set_timespec(helper->recursive, key,
                               (*(Timespec*)option.value));
        break;
    }
    case KVP_TYPE_GUID     :
    {
        break;  /* unsupported */
    }
    case KVP_TYPE_BINARY   :
    {
        break;  /* unsupported */
    }
    case KVP_TYPE_GLIST    :
    {
        break;  /* unsupported */
    }
    case KVP_TYPE_FRAME    :
    {
        break;  /* unsupported */
    }
    case KVP_TYPE_GDATE    :
    {
        break;  /* unsupported */
    }
    }
    LEAVE (" ");
}
const gchar * gnc_import_get_split_online_id(Split * split)
{
    kvp_frame * frame;
    frame = xaccSplitGetSlots(split);
    return kvp_frame_get_string(frame, "online_id");
}
const gchar * gnc_import_get_trans_online_id(Transaction * transaction)
{
    kvp_frame * frame;
    frame = xaccTransGetSlots(transaction);
    return kvp_frame_get_string(frame, "online_id");
}
const gchar * gnc_import_get_acc_online_id(Account * account)
{
    kvp_frame * frame;
    frame = xaccAccountGetSlots(account);
    return kvp_frame_get_string(frame, "online_id");
}