Newbie question

davidcullen's Avatar

davidcullen

15 Apr, 2019 03:11 AM

I'm not sure what is going on.
I have the following simple code:

from com.infinitekind.moneydance.model import *
root = moneydance.getCurrentAccount()
book = moneydance.getCurrentAccountBook()
txnset = book.getTransactionSet()
taxRelated = filter(lambda x:x.isTaxRelated() and x.getSubAccountCount() == 0, AccountUtil.getAccountIterator(book))
for a in taxRelated:
  b = root.getAccountByName(str(a)) 
  print a,b, a.class.name, b.class.name, a == b
  tA = book.getTransactionSet().getTransactionsForAccount(a)
  tB = book.getTransactionSet().getTransactionsForAccount(b)
  print tA,tB, tA.class.name, tB.class.name, tA == tB
The first test shows that a and b are identical - both of class name "Account" with comparison "True".
However, the second test shows that tA and tB are both of clay name "TxnSet" but the comparison shows that they are not identical even though the arguments in book.getTransactionSet().getTransactionsForAccount() are identical.
What am I missing?
  1. 1 Posted by hleofxquotes on 15 Apr, 2019 05:05 AM

    hleofxquotes's Avatar

    Purely guessing here ... (not knowing the code) .. I think I can see a case where tA and tB are NOT the same.

    Let's suppose getTransactionsForAccount(a) create a new list because it simply iterates the transactionSet and select only txn with txn.account == a. Something like

      list = new list
      for txn in txns
        if txn.account == a
           list.append(txn)
      return list
    

    then tA and tB will have the same list of txn's but tA != tB

  2. 2 Posted by davidcullen on 20 Apr, 2019 05:31 AM

    davidcullen's Avatar

    Thanks. Understand.

  3. davidcullen closed this discussion on 20 Apr, 2019 05:31 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