Example #1
0
/* ================================================================= */
template<> void
GncSqlColumnTableEntryImpl<CT_LOTREF>::load (const GncSqlBackend* be,
                                                 GncSqlRow& row,
                                                 QofIdTypeConst obj_name,
                                                 gpointer pObject) const noexcept
{
    load_from_guid_ref(row, obj_name, pObject,
                       [be](GncGUID* g){
                           return gnc_lot_lookup(g, be->book());
                       });
}
Example #2
0
static gboolean
invoice_postlot_handler (xmlNodePtr node, gpointer invoice_pdata)
{
    struct invoice_pdata* pdata = static_cast<decltype (pdata)> (invoice_pdata);
    GncGUID* guid;
    GNCLot* lot;

    guid = dom_tree_to_guid (node);
    g_return_val_if_fail (guid, FALSE);
    lot = gnc_lot_lookup (guid, pdata->book);
    g_free (guid);
    g_return_val_if_fail (lot, FALSE);

    gncInvoiceSetPostedLot (pdata->invoice, lot);
    return TRUE;
}
Example #3
0
static gboolean
spl_lot_handler(xmlNodePtr node, gpointer data)
{
    struct split_pdata *pdata = data;
    GncGUID *id = dom_tree_to_guid(node);
    GNCLot *lot;

    g_return_val_if_fail(id, FALSE);

    lot = gnc_lot_lookup (id, pdata->book);
    if (!lot && gnc_transaction_xml_v2_testing &&
            !guid_equal (id, guid_null ()))
    {
        lot = gnc_lot_new (pdata->book);
        gnc_lot_set_guid (lot, *id);
    }

    gnc_lot_add_split (lot, pdata->split);

    g_free(id);

    return TRUE;
}
/* ================================================================= */
static void
load_lot_guid( const GncSqlBackend* be, GncSqlRow* row,
               /*@ null @*/ QofSetterFunc setter, gpointer pObject,
               const GncSqlColumnTableEntry* table_row )
{
    const GValue* val;
    GncGUID guid;
    GNCLot* lot;

    g_return_if_fail( be != NULL );
    g_return_if_fail( row != NULL );
    g_return_if_fail( pObject != NULL );
    g_return_if_fail( table_row != NULL );

    val = gnc_sql_row_get_value_at_col_name( row, table_row->col_name );
    if ( val != NULL && G_VALUE_HOLDS_STRING( val ) && g_value_get_string( val ) != NULL )
    {
        (void)string_to_guid( g_value_get_string( val ), &guid );
        lot = gnc_lot_lookup( &guid, be->book );
        if ( lot != NULL )
        {
            if ( table_row->gobj_param_name != NULL )
            {
                g_object_set( pObject, table_row->gobj_param_name, lot, NULL );
            }
            else
            {
                g_return_if_fail( setter != NULL );
                (*setter)( pObject, (const gpointer)lot );
            }
        }
        else
        {
            PWARN( "Lot ref '%s' not found", g_value_get_string( val ) );
        }
    }
}