mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-26 02:40:43 -06:00
1238b9d8cd
This will avoid a ninja-build from picking up a config.h generated by the autotools build (in the root build directory). Picking up the wrong config.h may lead to all kinds of subtle issues if the autotools run was done with different options than the cmake run.
100 lines
2.9 KiB
C
100 lines
2.9 KiB
C
/*
|
|
* 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"
|
|
#include "gncOwner.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;
|
|
}
|
|
|
|
static void get_ownerlist_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))
|
|
{
|
|
GncOwner *owner = gncOwnerNew();
|
|
qofOwnerSetEntity(owner, inst);
|
|
data->result = g_list_prepend(data->result, owner);
|
|
}
|
|
}
|
|
|
|
GList * gncBusinessGetOwnerList (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_ownerlist_cb, &data);
|
|
|
|
return data.result;
|
|
}
|
|
|
|
gboolean gncBusinessIsPaymentAcctType (GNCAccountType type)
|
|
{
|
|
if (xaccAccountIsAssetLiabType(type) ||
|
|
xaccAccountIsEquityType(type))
|
|
return TRUE;
|
|
else
|
|
return FALSE;
|
|
}
|