NameError: global name 'getParentTxn' is not defined

davidcullen's Avatar

davidcullen

15 Mar, 2018 08:57 AM

I'm not sure if I am doing something incorrectly? I'm now using md 3017.7 (16680 on my mac.
The docs suggest that getParentTxn is a function but I get "NameError: global name 'getParentTxn' is not defined" as an error message.
Here is my 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"
  1. Support Staff 1 Posted by Sean Reilly on 15 Mar, 2018 11:43 AM

    Sean Reilly's Avatar

    Hi David,

    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

    Thanks,
    Sean

  2. System closed this discussion on 14 Jun, 2018 11:50 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

02 Dec, 2024 01:34 PM
02 Dec, 2024 12:49 PM
02 Dec, 2024 11:29 AM
02 Dec, 2024 08:29 AM
02 Dec, 2024 07:08 AM