davidcullen's Avatar


19 Apr, 2019 03:59 AM

Excuse me if this is obvious....
I saw a comment in the discussions: There are built-in methods for selecting a subset of transactions such as TransactionSet.getTransactions(TxnSearch).
However, I can see no guidance on how to properly construct the TxnSearch argument.
Could someone please give a detailed example, say the Transactions to be searched is txnset and I want to search for txns DateInt() == 20191231; I would have thought that q = txnset.getTransactions(txnset.getDateInt() == 20191231) would work.

  1. 1 Posted by hleofxquotes on 19 Apr, 2019 03:49 PM

    hleofxquotes's Avatar

    TxnSearch is an interface. To search for date, you probably need to use TxnDateSearch which implements TxnSearch.

    In Java,

            TransactionSet transactionSet = book.getTransactionSet();
            int date = 20191231;
            TxnSearch txnSearch = new TxnDateSearch(date);
            TxnSet transactions = transactionSet.getTransactions(txnSearch);
  2. 2 Posted by davidcullen on 20 Apr, 2019 06:09 AM

    davidcullen's Avatar

    Thanks, but I am not fully comfortable with java. I'm using jython. I solved the problem using

      for row in readCSV:
        found = filter(lambda == "SplitTxn" and x.getDateInt() == int(row["DateInt"]) and str(x.getAccount()) == row["Account"] and str(x.getParentTxn().getAccount()) == row["ParentAccount"] and int(x.getValue()) == int(row["Value"]), txnset)
    but wondered if there was a better way.
  3. davidcullen closed this discussion on 29 Apr, 2019 12:27 AM.

  4. Sean Reilly re-opened this discussion on 29 Apr, 2019 08:19 AM

  5. Support Staff 3 Posted by Sean Reilly on 29 Apr, 2019 08:19 AM

    Sean Reilly's Avatar

    Hi David,

    If I understand correctly you could do something like this in python:

    found = txnset.getTransactions(TxnDateSearch(20191231))


    Sean Reilly
    Developer, The Infinite Kind

  6. 4 Posted by davidcullen on 29 Apr, 2019 08:36 AM

    davidcullen's Avatar

    Thanks, Sean. This helps a little but what I was really trying to do was to get transactions which have specificitied other criteria instead of date. I am using python (I do not understand fully java.

    I am currently getting tens using filter:

    txns = filter(lambda x:x.x.__class__.__name__ ) == “SplitTxn” and x.getKeywords().size() > 1, txnset)

    but wondered if there was a better way.

    Kind regards,)

    David Cullen
    [email blocked]
    44 Bell Street
    Rockingham WA 6168
    Home: 089 527 1815

  7. Support Staff 5 Posted by Sean Reilly on 29 Apr, 2019 10:03 AM

    Sean Reilly's Avatar

    Hi David,

    Ah, I see now. Yes, if you'd like to filter for very specific things or want to do it in the most python-y way then you've got it. Moneydance has the built-in filter classes, but those don't include the keywords/tags filter and it's less elegant to make a python subclass of the TxnFilter java interface.


  8. 6 Posted by davidcullen on 29 Apr, 2019 02:32 PM

    davidcullen's Avatar

    Thanks. Your answer makes sense. I will keep using Filter.

  9. davidcullen closed this discussion on 29 Apr, 2019 02:32 PM.

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