mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add wrapper for obtaining a list of business objects as list of owners, and add SWIG wrappers so that scheme can use it.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19625 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
382d6733d7
commit
1f2994b1d3
@ -78,6 +78,7 @@ static GncEmployee * gncEmployeeLookupFlip(GncGUID g, QofBook *b)
|
|||||||
|
|
||||||
GLIST_HELPER_INOUT(EntryList, SWIGTYPE_p__gncEntry);
|
GLIST_HELPER_INOUT(EntryList, SWIGTYPE_p__gncEntry);
|
||||||
GLIST_HELPER_INOUT(GncTaxTableEntryList, SWIGTYPE_p__gncTaxTableEntry);
|
GLIST_HELPER_INOUT(GncTaxTableEntryList, SWIGTYPE_p__gncTaxTableEntry);
|
||||||
|
GLIST_HELPER_INOUT(OwnerList, SWIGTYPE_p__gncOwner);
|
||||||
|
|
||||||
%typemap(in) GncAccountValue * "$1 = gnc_scm_to_account_value_ptr($input);"
|
%typemap(in) GncAccountValue * "$1 = gnc_scm_to_account_value_ptr($input);"
|
||||||
%typemap(out) GncAccountValue * "$result = gnc_account_value_ptr_to_scm($1);"
|
%typemap(out) GncAccountValue * "$result = gnc_account_value_ptr_to_scm($1);"
|
||||||
@ -115,6 +116,7 @@ GLIST_HELPER_INOUT(GncTaxTableEntryList, SWIGTYPE_p__gncTaxTableEntry);
|
|||||||
/* Parse the header files to generate wrappers */
|
/* Parse the header files to generate wrappers */
|
||||||
%include <gncAddress.h>
|
%include <gncAddress.h>
|
||||||
%include <gncBillTerm.h>
|
%include <gncBillTerm.h>
|
||||||
|
%include <gncBusiness.h>
|
||||||
%include <gncCustomer.h>
|
%include <gncCustomer.h>
|
||||||
%include <gncEmployee.h>
|
%include <gncEmployee.h>
|
||||||
%include <gncEntry.h>
|
%include <gncEntry.h>
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "gncBusiness.h"
|
#include "gncBusiness.h"
|
||||||
|
#include "engine/gncOwner.h"
|
||||||
|
|
||||||
/* The initialization of the business objects is done in
|
/* The initialization of the business objects is done in
|
||||||
* cashobjects_register() of <engine/cashobjects.h>. */
|
* cashobjects_register() of <engine/cashobjects.h>. */
|
||||||
@ -40,6 +41,7 @@ static void get_list_cb (QofInstance *inst, gpointer user_data)
|
|||||||
data->result = g_list_prepend(data->result, inst);
|
data->result = g_list_prepend(data->result, inst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GList * gncBusinessGetList (QofBook *book, const char *type_name,
|
GList * gncBusinessGetList (QofBook *book, const char *type_name,
|
||||||
gboolean all_including_inactive)
|
gboolean all_including_inactive)
|
||||||
{
|
{
|
||||||
@ -57,3 +59,32 @@ GList * gncBusinessGetList (QofBook *book, const char *type_name,
|
|||||||
|
|
||||||
return data.result;
|
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 = gncOwnerCreate();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
@ -64,8 +64,21 @@
|
|||||||
|
|
||||||
/** Returns a GList of all objects of the given type_name in the given
|
/** Returns a GList of all objects of the given type_name in the given
|
||||||
* book. */
|
* book. */
|
||||||
GList * gncBusinessGetList (QofBook *book, const char *type_name,
|
GList * gncBusinessGetList (QofBook *book, QofIdTypeConst type_name,
|
||||||
gboolean all_including_inactive);
|
gboolean all_including_inactive);
|
||||||
|
|
||||||
|
/** For SWIG: A GList containing GncOwner. */
|
||||||
|
typedef GList OwnerList;
|
||||||
|
|
||||||
|
/** Returns a GList of all objects of the given type_name in the given
|
||||||
|
* book, but each object is wrapped in a GncOwner object.
|
||||||
|
*
|
||||||
|
* The wrapping was done by qofOwnerSetEntity(), hence the owner will
|
||||||
|
* contain data only for {CUSTOMER, JOB, VERNDOR, EMPLOYEE}, otherwise
|
||||||
|
* the owner will be of type GNC_OWNER_NONE and not contain the
|
||||||
|
* original data. */
|
||||||
|
OwnerList * gncBusinessGetOwnerList (QofBook *book, QofIdTypeConst type_name,
|
||||||
|
gboolean all_including_inactive);
|
||||||
|
|
||||||
|
|
||||||
#endif /* GNC_BUSINESS_H_ */
|
#endif /* GNC_BUSINESS_H_ */
|
||||||
|
@ -102,13 +102,16 @@ GncOwnerType gncOwnerGetType (const GncOwner *owner)
|
|||||||
return owner->type;
|
return owner->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
QofIdType
|
QofIdTypeConst
|
||||||
qofOwnerGetType(const GncOwner *owner)
|
qofOwnerGetType(const GncOwner *owner)
|
||||||
{
|
{
|
||||||
QofIdType type;
|
return gncOwnerTypeToQofIdType(owner->type);
|
||||||
|
}
|
||||||
|
|
||||||
type = NULL;
|
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t)
|
||||||
switch (owner->type)
|
{
|
||||||
|
QofIdTypeConst type = NULL;
|
||||||
|
switch (t)
|
||||||
{
|
{
|
||||||
case GNC_OWNER_NONE :
|
case GNC_OWNER_NONE :
|
||||||
{
|
{
|
||||||
|
@ -62,12 +62,16 @@ to QOF as they can be used by objects like GncInvoice.
|
|||||||
@{
|
@{
|
||||||
*/
|
*/
|
||||||
/** return the type for the collection. */
|
/** return the type for the collection. */
|
||||||
QofIdType qofOwnerGetType(const GncOwner *owner);
|
QofIdTypeConst qofOwnerGetType(const GncOwner *owner);
|
||||||
/** return the owner itself as an entity. */
|
/** return the owner itself as an entity. */
|
||||||
QofInstance* qofOwnerGetOwner (const GncOwner *owner);
|
QofInstance* qofOwnerGetOwner (const GncOwner *owner);
|
||||||
/** set the owner from the entity. */
|
/** set the owner from the entity. */
|
||||||
void qofOwnerSetEntity (GncOwner *owner, QofInstance *ent);
|
void qofOwnerSetEntity (GncOwner *owner, QofInstance *ent);
|
||||||
|
|
||||||
|
/** Returns the QofIdType of the given GncOwnerType, or NULL if no
|
||||||
|
* suitable one exists. */
|
||||||
|
QofIdTypeConst gncOwnerTypeToQofIdType(GncOwnerType t);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gncOwnerRegister(void);
|
gncOwnerRegister(void);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user