From 698a1dc6ac874fddc45efdebb989ed6f21e291c8 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Thu, 29 Sep 2011 11:00:06 +0000 Subject: [PATCH] Added bindings for Employee, Job and Owner types. Patch by Hendrik van Antwerpen git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@21362 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/base-typemaps.i | 6 ++++ .../python-bindings/gnucash_business.py | 29 +++++++++++++------ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/base-typemaps.i b/src/base-typemaps.i index 7ec6f976fb..87d67cd6c8 100644 --- a/src/base-typemaps.i +++ b/src/base-typemaps.i @@ -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 diff --git a/src/optional/python-bindings/gnucash_business.py b/src/optional/python-bindings/gnucash_business.py index bc1eae2071..2c248e9121 100644 --- a/src/optional/python-bindings/gnucash_business.py +++ b/src/optional/python-bindings/gnucash_business.py @@ -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')