r21362 - gnucash/trunk/src - Added bindings for Employee, Job and Owner types.

Geert Janssens gjanssens at code.gnucash.org
Thu Sep 29 07:00:07 EDT 2011


Author: gjanssens
Date: 2011-09-29 07:00:06 -0400 (Thu, 29 Sep 2011)
New Revision: 21362
Trac: http://svn.gnucash.org/trac/changeset/21362

Modified:
   gnucash/trunk/src/base-typemaps.i
   gnucash/trunk/src/optional/python-bindings/gnucash_business.py
Log:
Added bindings for Employee, Job and Owner types.
Patch by Hendrik van Antwerpen <hendrik at van-antwerpen.net>

Modified: gnucash/trunk/src/base-typemaps.i
===================================================================
--- gnucash/trunk/src/base-typemaps.i	2011-09-29 10:06:11 UTC (rev 21361)
+++ gnucash/trunk/src/base-typemaps.i	2011-09-29 11:00:06 UTC (rev 21362)
@@ -188,6 +188,12 @@
             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

Modified: gnucash/trunk/src/optional/python-bindings/gnucash_business.py
===================================================================
--- gnucash/trunk/src/optional/python-bindings/gnucash_business.py	2011-09-29 10:06:11 UTC (rev 21361)
+++ gnucash/trunk/src/optional/python-bindings/gnucash_business.py	2011-09-29 11:00:06 UTC (rev 21362)
@@ -75,19 +75,15 @@
             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 @@
         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')
 



More information about the gnucash-changes mailing list