tag:infinitekind.tenderapp.com,2009-01-14:/discussions/moneydance-development/3075-how-do-i-construct-a-filter-for-txnset-gettransactionstxnsearch-filterInfinite Kind: Discussion 2020-09-27T18:46:00Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/486680162020-09-27T13:05:33Z2020-09-27T13:05:33ZHow do I construct a filter for ’TxnSet getTransactions(TxnSearch filter)’?<div><p>Hi Stuart,</p>
<p>The idea with TxnSearch is that it is an interface that is implemented by specific searches, ... or filters really, as they work the same way as AcctFilter. It might be tricky to implement java interfaces on the python side, but I <em>think</em> you can do something like:</p>
<pre>
<code>class MyTxnSearch(TxnSearch):
account = None
def matchesAll(self):
return False
def boolean matches(self, txn):
return txn.getAccount().isDescendantOf(account)</code>
</pre>
<p>There are a few classes that implement TxnSearch which you are welcome to use. They weren't previously in the API docs for some reason, but they've been around forever. I've just updated the api docs on the web site and they appear there now. One of them is <a href="https://infinitekind.com/dev/apidoc/com/infinitekind/moneydance/model/GenericTxnSearch.html">GenericTxnSearch</a> which lets you search for specific fields or <a href="https://infinitekind.com/dev/apidoc/com/infinitekind/moneydance/model/AggregateTxnSearch.html">AggregateTxnSearch</a> which makes it easier to combine multiple criteria (possibly multiple GenericTxnSearch instances).</p>
<p>Hope this helps!<br>
Sean</p>
<p>--<br>
Sean Reilly<br>
Developer, The Infinite Kind<br>
<a href="https://infinitekind.com">https://infinitekind.com</a></p></div>Sean Reillytag:infinitekind.tenderapp.com,2009-01-14:Comment/486680162020-09-27T13:13:21Z2020-09-27T13:13:21ZHow do I construct a filter for ’TxnSet getTransactions(TxnSearch filter)’?<div><p>Thanks. I’ll have a play with your example class below… Regarding GenericTxnSearch() etc - thanks, but I may be missing the obvious but I cannot think how to use them…. Sorry for the followup question, but can you provide an example of how to use this? Once I can see that I will understand how to do it differently.</p>
<p>Can you see my other support question regarding the Account Filter too - Thanks</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/486680162020-09-27T18:45:57Z2020-09-27T18:45:57ZHow do I construct a filter for ’TxnSet getTransactions(TxnSearch filter)’?<div><p>Thanks. You've told me that: 'you can use it on the TransactionSet object, so accountBook.getTransactionSet().getTransactions(TxnSearch).'</p>
<p>This works with my self constructed class - as you said above.....</p></div>Stuart Beesley (Mr Toolbox)