From 7c003f23e4350f089fdb8ae47fbf32ad82f18834 Mon Sep 17 00:00:00 2001 From: Mike Evans Date: Sun, 1 Jun 2014 13:24:20 +0100 Subject: [PATCH] Bug 730255 - Python bindings: Assigns bill entries to non-existant invoice. Add type checking to ensure entry type matches invoice (or bill) type. --- src/optional/python-bindings/gnucash_business.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/optional/python-bindings/gnucash_business.py b/src/optional/python-bindings/gnucash_business.py index e3b39480c2..930c6d83c8 100644 --- a/src/optional/python-bindings/gnucash_business.py +++ b/src/optional/python-bindings/gnucash_business.py @@ -217,7 +217,15 @@ class Entry(GnuCashCoreClass): if invoice != None: invoice.AddEntry(self) else: - GnuCashCoreClass.__init__(self, instance=instance) + + GnuCashCoreClass.__init__(self, instance=instance) + + def test_type(self, invoice): + if invoice.GetTypeString() == "Invoice" and self.GetInvoice() == None: + raise Exception("Entry type error. Check that Entry type matches Invoice.") + if invoice.GetTypeString() == "Bill" and self.GetBill() == None: + raise Exception("Entry type error. Check that Entry type matches Bill.") + # Owner GnuCashBusinessEntity.add_methods_with_prefix('gncOwner')