mirror of
https://github.com/Gnucash/gnucash.git
synced 2026-09-03 20:53:02 -05:00
Add a function gncBusinessGetList() that existed previously until r6680 so that a list of all customers can be obtained.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19624 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -110,7 +110,6 @@ test_customer (void)
|
||||
gncCustomerSetGUID (customer, &guid);
|
||||
do_test (guid_equal (&guid, gncCustomerGetGUID (customer)), "guid compare");
|
||||
}
|
||||
#if 0
|
||||
{
|
||||
GList *list;
|
||||
|
||||
@@ -124,7 +123,6 @@ test_customer (void)
|
||||
do_test (g_list_length (list) == 1, "correct length: active");
|
||||
g_list_free (list);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
const char *str = get_random_string();
|
||||
const char *res;
|
||||
|
||||
@@ -114,7 +114,6 @@ test_employee (void)
|
||||
gncEmployeeSetGUID (employee, &guid);
|
||||
do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(employee))), "guid compare");
|
||||
}
|
||||
#if 0
|
||||
{
|
||||
GList *list;
|
||||
|
||||
@@ -128,7 +127,6 @@ test_employee (void)
|
||||
do_test (g_list_length (list) == 1, "correct length: active");
|
||||
g_list_free (list);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
const char *str = get_random_string();
|
||||
const char *res;
|
||||
|
||||
@@ -115,7 +115,6 @@ test_vendor (void)
|
||||
gncVendorSetGUID (vendor, &guid);
|
||||
do_test (guid_equal (&guid, qof_instance_get_guid(QOF_INSTANCE(vendor))), "guid compare");
|
||||
}
|
||||
#if 0
|
||||
{
|
||||
GList *list;
|
||||
|
||||
@@ -129,7 +128,6 @@ test_vendor (void)
|
||||
do_test (g_list_length (list) == 1, "correct length: active");
|
||||
g_list_free (list);
|
||||
}
|
||||
#endif
|
||||
{
|
||||
const char *str = get_random_string();
|
||||
const char *res;
|
||||
|
||||
@@ -45,6 +45,7 @@ libgncmod_engine_la_SOURCES = \
|
||||
policy.c \
|
||||
swig-business-core.c \
|
||||
gncBusGuile.c \
|
||||
gncBusiness.c \
|
||||
gncAddress.c \
|
||||
gncBillTerm.c \
|
||||
gncCustomer.c \
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* gncBusiness.c -- Business helper functions
|
||||
* Copyright (C) 2010 Christian Stimming
|
||||
* Author: Christian Stimming <christian@cstimming.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, contact:
|
||||
*
|
||||
* Free Software Foundation Voice: +1-617-542-5942
|
||||
* 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
|
||||
* Boston, MA 02110-1301, USA gnu@gnu.org
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gncBusiness.h"
|
||||
|
||||
/* The initialization of the business objects is done in
|
||||
* cashobjects_register() of <engine/cashobjects.h>. */
|
||||
|
||||
struct _get_list_userdata
|
||||
{
|
||||
GList *result;
|
||||
QofAccessFunc is_active_accessor_func;
|
||||
};
|
||||
static void get_list_cb (QofInstance *inst, gpointer user_data)
|
||||
{
|
||||
struct _get_list_userdata* data = user_data;
|
||||
if (!data->is_active_accessor_func || data->is_active_accessor_func(inst, NULL))
|
||||
data->result = g_list_prepend(data->result, inst);
|
||||
}
|
||||
|
||||
GList * gncBusinessGetList (QofBook *book, const char *type_name,
|
||||
gboolean all_including_inactive)
|
||||
{
|
||||
struct _get_list_userdata data;
|
||||
data.result = NULL;
|
||||
data.is_active_accessor_func = NULL;
|
||||
|
||||
if (!all_including_inactive)
|
||||
{
|
||||
data.is_active_accessor_func =
|
||||
qof_class_get_parameter_getter(type_name, QOF_PARAM_ACTIVE);
|
||||
}
|
||||
|
||||
qof_object_foreach(type_name, book, &get_list_cb, &data);
|
||||
|
||||
return data.result;
|
||||
}
|
||||
@@ -34,6 +34,8 @@
|
||||
#ifndef GNC_BUSINESS_H_
|
||||
#define GNC_BUSINESS_H_
|
||||
|
||||
#include <glib.h>
|
||||
#include "qof.h"
|
||||
|
||||
/* @deprecated backwards-compat definitions */
|
||||
#define GNC_BILLTERM_MODULE_NAME GNC_ID_BILLTERM
|
||||
@@ -60,4 +62,10 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/** Returns a GList of all objects of the given type_name in the given
|
||||
* book. */
|
||||
GList * gncBusinessGetList (QofBook *book, const char *type_name,
|
||||
gboolean all_including_inactive);
|
||||
|
||||
|
||||
#endif /* GNC_BUSINESS_H_ */
|
||||
|
||||
Reference in New Issue
Block a user