示例#1
0
文件: Scrub.c 项目: Bob-IT/gnucash
static gint
commodity_equal (gconstpointer a, gconstpointer b)
{
    CommodityCount *cc = (CommodityCount*)a;
    gnc_commodity *com = (gnc_commodity*)b;
    if ( cc == NULL || cc->commodity == NULL ||
         !GNC_IS_COMMODITY( cc->commodity ) ) return -1;
    if ( com == NULL || !GNC_IS_COMMODITY( com ) ) return 1;
    if ( gnc_commodity_equal(cc->commodity, com) )
        return 0;
    return 1;
}
示例#2
0
static gboolean
commit_commodity( GncSqlBackend* be, QofInstance* inst )
{
    g_return_val_if_fail( be != NULL, FALSE );
    g_return_val_if_fail( inst != NULL, FALSE );
    g_return_val_if_fail( GNC_IS_COMMODITY(inst), FALSE );

    return do_commit_commodity( be, inst, FALSE );
}
示例#3
0
文件: Scrub.c 项目: Bob-IT/gnucash
static gint
commodity_compare( gconstpointer a, gconstpointer b)
{
    CommodityCount *ca = (CommodityCount*)a, *cb = (CommodityCount*)b;
    if (ca == NULL || ca->commodity == NULL ||
        !GNC_IS_COMMODITY( ca->commodity ) )
    {
        if (cb == NULL || cb->commodity == NULL ||
            !GNC_IS_COMMODITY( cb->commodity ) )
            return 0;
        return -1;
    }
    if (cb == NULL || cb->commodity == NULL ||
        !GNC_IS_COMMODITY( cb->commodity ) )
        return 1;
    if (ca->count == cb->count)
        return 0;
    return ca->count > cb->count ? 1 : -1;
}
示例#4
0
/** Returns a list of my type of object which refers to an object.  For example, when called as
        qof_instance_get_typed_referring_object_list(taxtable, account);
    it will return the list of taxtables which refer to a specific account.  The result should be the
    same regardless of which taxtable object is used.  The list must be freed by the caller but the
    objects on the list must not.
 */
static GList*
impl_get_typed_referring_object_list(const QofInstance* inst, const QofInstance* ref)
{
    if (!GNC_IS_COMMODITY(ref) && !GNC_IS_ACCOUNT(ref))
    {
        return NULL;
    }

    return qof_instance_get_referring_object_list_from_collection(qof_instance_get_collection(inst), ref);
}
示例#5
0
static /*@ dependent @*//*@ null @*/ gpointer
get_quote_source_name( gpointer pObject )
{
    const gnc_commodity* pCommodity;

    g_return_val_if_fail( pObject != NULL, NULL );
    g_return_val_if_fail( GNC_IS_COMMODITY(pObject), NULL );

    pCommodity = GNC_COMMODITY(pObject);
    return (gpointer)gnc_quote_source_get_internal_name(
               gnc_commodity_get_quote_source(pCommodity));
}
示例#6
0
static void
set_quote_source_name( gpointer pObject, gpointer pValue )
{
    gnc_commodity* pCommodity;
    const gchar* quote_source_name = (const gchar*)pValue;
    gnc_quote_source* quote_source;

    g_return_if_fail( pObject != NULL );
    g_return_if_fail( GNC_IS_COMMODITY(pObject) );

    if ( pValue == NULL ) return;

    pCommodity = GNC_COMMODITY(pObject);
    quote_source = gnc_quote_source_lookup_by_internal( quote_source_name );
    gnc_commodity_set_quote_source( pCommodity, quote_source );
}
示例#7
0
/** Does this object refer to a specific object */
static gboolean
impl_refers_to_object(const QofInstance* inst, const QofInstance* ref)
{
    GncEmployee* emp;

    g_return_val_if_fail(inst != NULL, FALSE);
    g_return_val_if_fail(GNC_IS_EMPLOYEE(inst), FALSE);

    emp = GNC_EMPLOYEE(inst);

    if (GNC_IS_COMMODITY(ref))
    {
        return (emp->currency == GNC_COMMODITY(ref));
    }
    else if (GNC_IS_ACCOUNT(ref))
    {
        return (emp->ccard_acc == GNC_ACCOUNT(ref));
    }

    return FALSE;
}