getTxnsForAccount() error

davidcullen's Avatar


24 Apr, 2021 04:38 AM

I don't know much java, so please excuse my ignorance.

I recently played around in the MoneyBot, running the following:

#-- coding: UTF-8 --
from com.infinitekind.moneydance.model import *
ROOT = moneydance.getCurrentAccount()
BOOK = moneydance.getCurrentAccountBook()
TXNSET = BOOK.getTransactionSet()
z = TXNSET.getTxnsForAccount​(emAcc)
This produces an error:
Error running script: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value

What am I doing wrong?

  1. 1 Posted by davidcullen on 24 Apr, 2021 07:59 AM

    davidcullen's Avatar

    I'm still exploring, but when I change z to

    z = TXNSET.getTransactionsForAccount(emAcc)
    I don't get an error, and things seem to work.....
  2. 2 Posted by davidcullen on 24 Apr, 2021 08:15 AM

    davidcullen's Avatar

    It seems that .getTxnsForAccount produces an ArrayList but .getTransactionsForAccount produces a TxnSet
    I want a TxnSet.

  3. 3 Posted by davidcullen on 24 Apr, 2021 08:45 AM

    davidcullen's Avatar

    Further to the above, I have the following (partial) code:

    b1 = AccountUtil.getBalanceAsOfDate(BOOK, emAcc, START)
    b2 = TXNSET.getTransactionsForAccount(emAcc).getBalanceAt(START)
    I expected both values to be equal, but when they run, b1 gives the expected account balance, but b2 gives zero.
    I'm not sure what is going on.
  4. 4 Posted by Stuart Beesley ... on 24 Apr, 2021 09:23 AM

    Stuart Beesley (Mr Toolbox)'s Avatar

    I cannot reproduce your error. Your initial code runs OK for me. What line did the code actually error on?

    Yes. getTransactionsForAccount() return an array[] and getTxnsForAccount() returns a TxnSet. The underlying code is identical and both will return the same actual data..

    Whilst your code seems to work, I'm not entirely sure you should call the unbound class. The normal usage I have seen would be as follows:

    acctTxns = BOOK.getTransactionSet().getTransactionsForAccount(emAcc)

    and then you call the methods on

    However, both methods return the same data, so hey.... whatever...

    Given you want a TxnSet and you got a TxnSet, what is the issue?

    As for your b2 example, I don't see how / why b2 would work as you want. When you use .getBalanceAt( i ), then i is meant to be an index into TxnSet - i.e. position i. Further, you get this to work you have to use .setHoldBalances​(), .recalcBalances() etc... Just wondering if you have see the API Doc? I've never used these, so you would have to play...

    Perhaps if you explain what you are trying to do, we can comment with the best way to do this?

    You can see an example of data extract (etc) by looking at my extract_data script:

    (not support, just a fellow user)

  5. 5 Posted by davidcullen on 24 Apr, 2021 11:10 AM

    davidcullen's Avatar

    Thanks very much for taking the time to send this.
    I had thought that the int i in .getBalaceAt(i) was a date, not a position. Now I understand.
    I will explore with interest the various links you sent in your message.
    Things are now working fine for what I am needing to do. I’m still not sure why I got the Java string error, but since I can now get the Txnset I am after, I will not worry about it.

    , Stuart Beesley - JUST A FELLOW USER <[email blocked]> wrote:

  6. davidcullen closed this discussion on 25 Apr, 2021 03:53 AM.

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

Keyboard shortcuts


? 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