tag:infinitekind.tenderapp.com,2009-01-14:/discussions/moneydance-development/2093-nameerror-global-name-getparenttxn-is-not-definedInfinite Kind: Discussion 2018-06-14T11:50:24Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/449100282018-03-15T08:57:51Z2018-03-15T08:57:51ZNameError: global name 'getParentTxn' is not defined<div><p>I'm not sure if I am doing something incorrectly? I'm now using md 3017.7 (16680 on my mac.<br>
The docs suggest that getParentTxn is a function but I get "NameError: global name 'getParentTxn' is not defined" as an error message.<br>
Here is my code:<br></p>
<pre>
<code>from com.infinitekind.moneydance.model import *
import java.util.ArrayList
import sys
book = moneydance.getCurrentAccountBook()
txnset = book.getTransactionSet()
#get all Accounts with Comment which includes 'RentalPropertyAgent'
rentalPropertyAgentAccounts = filter(lambda x:'RentalPropertyAgent' in x.comment, AccountUtil.getAccountIterator(book))
for account in rentalPropertyAgentAccounts:
for txn in txnset.getTransactionsForAccount(account):
for i in range(getParentTxn(txn).getOtherTxnCount()):
if isinstance(getParentTxn(txn).getSplit(i), ParentTxn):
print "p"
else:
print "s"</code>
</pre></div>davidcullentag:infinitekind.tenderapp.com,2009-01-14:Comment/449100282018-03-15T11:43:30Z2018-03-15T11:43:30ZNameError: global name 'getParentTxn' is not defined<div><p>Hi David,</p>
<p>I think the issue is that getParentTxn() is an instance method, so you should be calling txn.getParentTxn(). Also instead of using isinstance() you could use txn.getParentTxn()==txn</p>
<p>Thanks,<br>
Sean</p></div>Sean Reilly