r20433 - gnucash/trunk/src/engine - Add some convenience getter functions to gncOwner.
Geert Janssens
gjanssens at code.gnucash.org
Sun Mar 20 15:33:55 EDT 2011
Author: gjanssens
Date: 2011-03-20 15:33:55 -0400 (Sun, 20 Mar 2011)
New Revision: 20433
Trac: http://svn.gnucash.org/trac/changeset/20433
Modified:
gnucash/trunk/src/engine/gncOwner.c
gnucash/trunk/src/engine/gncOwner.h
Log:
Add some convenience getter functions to gncOwner.
Modified: gnucash/trunk/src/engine/gncOwner.c
===================================================================
--- gnucash/trunk/src/engine/gncOwner.c 2011-03-20 19:17:11 UTC (rev 20432)
+++ gnucash/trunk/src/engine/gncOwner.c 2011-03-20 19:33:55 UTC (rev 20433)
@@ -299,6 +299,26 @@
return (a->owner.undefined == b->owner.undefined);
}
+const char * gncOwnerGetID (const GncOwner *owner)
+{
+ if (!owner) return NULL;
+ switch (owner->type)
+ {
+ case GNC_OWNER_NONE:
+ case GNC_OWNER_UNDEFINED:
+ default:
+ return NULL;
+ case GNC_OWNER_CUSTOMER:
+ return gncCustomerGetID (owner->owner.customer);
+ case GNC_OWNER_JOB:
+ return gncJobGetID (owner->owner.job);
+ case GNC_OWNER_VENDOR:
+ return gncVendorGetID (owner->owner.vendor);
+ case GNC_OWNER_EMPLOYEE:
+ return gncEmployeeGetID (owner->owner.employee);
+ }
+}
+
const char * gncOwnerGetName (const GncOwner *owner)
{
if (!owner) return NULL;
@@ -319,6 +339,25 @@
}
}
+GncAddress * gncOwnerGetAddr (const GncOwner *owner)
+{
+ if (!owner) return NULL;
+ switch (owner->type)
+ {
+ case GNC_OWNER_NONE:
+ case GNC_OWNER_UNDEFINED:
+ case GNC_OWNER_JOB:
+ default:
+ return NULL;
+ case GNC_OWNER_CUSTOMER:
+ return gncCustomerGetAddr (owner->owner.customer);
+ case GNC_OWNER_VENDOR:
+ return gncVendorGetAddr (owner->owner.vendor);
+ case GNC_OWNER_EMPLOYEE:
+ return gncEmployeeGetAddr (owner->owner.employee);
+ }
+}
+
gnc_commodity * gncOwnerGetCurrency (const GncOwner *owner)
{
if (!owner) return NULL;
@@ -339,6 +378,27 @@
}
}
+gboolean gncOwnerGetActive (const GncOwner *owner)
+{
+ if (!owner) return FALSE;
+ switch (owner->type)
+ {
+ case GNC_OWNER_NONE:
+ case GNC_OWNER_UNDEFINED:
+ default:
+ return FALSE;
+ case GNC_OWNER_CUSTOMER:
+ return gncCustomerGetActive (owner->owner.customer);
+ case GNC_OWNER_VENDOR:
+ return gncVendorGetActive (owner->owner.vendor);
+ case GNC_OWNER_EMPLOYEE:
+ return gncEmployeeGetActive (owner->owner.employee);
+ /* Jobs don't really have an active status, so we consider them always active */
+ case GNC_OWNER_JOB:
+ return TRUE;
+ }
+}
+
const GncGUID * gncOwnerGetGUID (const GncOwner *owner)
{
if (!owner) return NULL;
Modified: gnucash/trunk/src/engine/gncOwner.h
===================================================================
--- gnucash/trunk/src/engine/gncOwner.h 2011-03-20 19:17:11 UTC (rev 20432)
+++ gnucash/trunk/src/engine/gncOwner.h 2011-03-20 19:33:55 UTC (rev 20433)
@@ -119,7 +119,10 @@
gboolean gncOwnerEqual (const GncOwner *a, const GncOwner *b);
int gncOwnerCompare (const GncOwner *a, const GncOwner *b);
+const char * gncOwnerGetID (const GncOwner *owner);
const char * gncOwnerGetName (const GncOwner *owner);
+GncAddress * gncOwnerGetAddr (const GncOwner *owner);
+gboolean gncOwnerGetActive (const GncOwner *owner);
gnc_commodity * gncOwnerGetCurrency (const GncOwner *owner);
/** Get the GncGUID of the immediate owner */
More information about the gnucash-changes
mailing list