Added bindings for Employee, Job and Owner types.

Patch by Hendrik van Antwerpen <hendrik@van-antwerpen.net>

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21362 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Geert Janssens
2011-09-29 11:00:06 +00:00
parent e84d64f303
commit 698a1dc6ac
2 changed files with 26 additions and 9 deletions

View File

@@ -188,6 +188,12 @@ typedef char gchar;
PyList_Append(list, SWIG_NewPointerObj(data, SWIGTYPE_p__gncCustomer, 0));
else if (GNC_IS_VENDOR(data))
PyList_Append(list, SWIG_NewPointerObj(data, SWIGTYPE_p__gncVendor, 0));
else if (GNC_IS_EMPLOYEE(data))
PyList_Append(list, SWIG_NewPointerObj(data, SWIGTYPE_p__gncEmployee, 0));
else if (GNC_IS_JOB(data))
PyList_Append(list, SWIG_NewPointerObj(data, SWIGTYPE_p__gncJob, 0));
else if (GNC_IS_OWNER(data))
PyList_Append(list, SWIG_NewPointerObj(data, SWIGTYPE_p__gncOwner, 0));
else if ($1_descriptor == $descriptor(MonetaryList *))
PyList_Append(list, SWIG_NewPointerObj(data, $descriptor(gnc_monetary *), 0));
else

View File

@@ -75,19 +75,15 @@ class GnuCashBusinessEntity(GnuCashCoreClass):
trans = Transaction(instance=trans)
return trans
class Owner(GnuCashBusinessEntity): pass
class Customer(GnuCashBusinessEntity): pass
class Customer(Owner): pass
class Employee(GnuCashBusinessEntity):
def SetName(self, name):
self.GetAddr().SetName(name)
def GetName(self):
return self.GetAddr().GetName()
class Employee(Owner): pass
class Vendor(GnuCashBusinessEntity): pass
class Vendor(Owner): pass
class Job(GnuCashBusinessEntity):
class Job(Owner):
# override the superclass contructor, as Job doesn't require
# a currency but it does require an owner
def __init__(self, book=None, id=None, owner=None, name=None,
@@ -233,6 +229,21 @@ class Entry(GnuCashCoreClass):
else:
GnuCashCoreClass.__init__(self, instance=instance)
# Owner
Owner.add_constructor_and_methods_with_prefix('gncOwner', 'New')
owner_dict = {
'GetCustomer' : Customer,
'GetVendor' : Vendor,
'GetEmployee' : Employee,
'GetJob' : Job,
'GetAddr' : Address,
'GetCurrency' : GncCommodity,
'GetEndOwner': Owner,
'GetBalanceInCurrency': GncNumeric,
}
methods_return_instance(Owner, owner_dict)
# Customer
Customer.add_constructor_and_methods_with_prefix('gncCustomer', 'Create')