tag:infinitekind.tenderapp.com,2009-01-14:/discussions/moneydance-development/3073-how-does-accountutilallmatchesforsearchbook-myfilter-actually-workInfinite Kind: Discussion 2020-09-28T17:14:48Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/486680142020-09-27T12:30:25Z2020-09-27T12:30:25ZHow does AccountUtil.allMatchesForSearch(book, myFilter ) actually work?<div><p>OK, I know what it does, and I know how to use it...... Specifically, how does the Filter work and how is it constructed?<br>
I am using AcctFilter.ACTIVE_ACCOUNTS_FILTER and AcctFilter.ALL_ACCOUNTS_FILTER and I need to reproduce the active filter with my own logic for Investment accounts and Securities.</p>
<p>Thus far I have this code which seems to reproduce the active filter:<br>
- Filter using AcctFilter.ACTIVE_ACCOUNTS_FILTER - Iterate the result - select only where account: not acct.getAccountOrParentIsInactive() - Select where account is AccountType.INVESTMENT or AccountType.SECURITY - and if it's a security, then only select where acct.getCurrentBalance()<>0 (but don't do this check on Investment Accounts).</p>
<p>I seem to be getting the same results, but I need to know what the logic filter actually contains. (or find out how to look into the filter and find this out myself?)</p>
<p>ALSO: Is there a way I can build/set my own filter? If so, how? Thanks</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/486680142020-09-27T13:15:31Z2020-09-27T13:15:31ZHow does AccountUtil.allMatchesForSearch(book, myFilter ) actually work?<div><p>Hi Stuart,</p>
<p>The AcctFilter instances are actually really simple in that various iterators call the .matches(Account) method on whatever kind of AcctFilter is used. If you have multiple criteria you can use the <a href="https://infinitekind.com/dev/apidoc/com/infinitekind/moneydance/model/CombinedAccountFilter.html">CombinedAccountFilter</a> class which is the AcctFilter equivalent of the AggregateTxnSearch class.</p>
<p>You're on the right track in using some of the prebuilt filters like ACTIVE_ACCOUNTS_FILTER. You can also easily get an account type filter by calling .filter() on the <a href="https://infinitekind.com/dev/apidoc/com/infinitekind/moneydance/model/Account.AccountType.html">AccountType</a> object. Using these and combining them together should make it much easier to build complex account filters that only require one iteration over the set of accounts.</p>
<p>Of course you can also implement your own in python using code similar to that posted in response to your TxnSearch comment.</p>
<p>Thanks!<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/486680142020-09-27T13:31:26Z2020-09-27T13:31:26ZHow does AccountUtil.allMatchesForSearch(book, myFilter ) actually work?<div><p>Hi Sean,</p>
<p>Thanks again. Sorry, but I still don’t understand how to get exactly what filters ACTIVE_ACCOUNTS_FILTER is applying…? I can’t find anyway to make it disclose what it’s actually filtering…. Can you give me an example of what code to run to make it show me what logic it’s using..?</p>
<p>Do you mean you call .filter() to disclose the logic it’s using, or call it in some way, with something as an argument, to then select that account? Again, not sure how to actually use it..?</p>
<p>Sorry if I’m being thick!!</p>
<p>Thanks</p></div>Stuart Beesley (Mr Toolbox)tag:infinitekind.tenderapp.com,2009-01-14:Comment/486680142020-09-27T13:35:19Z2020-09-27T13:35:19ZHow does AccountUtil.allMatchesForSearch(book, myFilter ) actually work?<div><p>Oh no, I'm the one being thick! Here's the implementation of the filter method for ACTIVE_ACCOUNTS_FILTER:</p>
<pre>
<code> public boolean matches(Account acct) {
if(acct.getAccountOrParentIsInactive()) return false;
if(acct.getHideOnHomePage() && acct.getBalance()==0) return false;
return true;
}</code>
</pre>
<p>It doesn't filter on account type, but otherwise would be used to show accounts that are useful to the user based on their home page settings.</p>
<p>Cheers,<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/486680142020-09-27T18:44:47Z2020-09-27T18:44:47ZHow does AccountUtil.allMatchesForSearch(book, myFilter ) actually work?<div><p>Thx!!</p></div>Stuart Beesley (Mr Toolbox)