How does AccountUtil.allMatchesForSearch(book, myFilter ) actually work?
OK, I know what it does, and I know how to use it...... Specifically, how does the Filter work and how is it constructed?
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.
Thus far I have this code which seems to reproduce the active filter:
- 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).
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?)
ALSO: Is there a way I can build/set my own filter? If so, how? Thanks
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
Support Staff 1 Posted by Sean Reilly on 27 Sep, 2020 01:15 PM
Hi Stuart,
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 CombinedAccountFilter class which is the AcctFilter equivalent of the AggregateTxnSearch class.
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 AccountType 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.
Of course you can also implement your own in python using code similar to that posted in response to your TxnSearch comment.
Thanks!
Sean
--
Sean Reilly
Developer, The Infinite Kind
https://infinitekind.com
2 Posted by Stuart Beesley ... on 27 Sep, 2020 01:31 PM
Hi Sean,
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..?
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..?
Sorry if I’m being thick!!
Thanks
Support Staff 3 Posted by Sean Reilly on 27 Sep, 2020 01:35 PM
Oh no, I'm the one being thick! Here's the implementation of the filter method for ACTIVE_ACCOUNTS_FILTER:
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.
Cheers,
Sean
--
Sean Reilly
Developer, The Infinite Kind
https://infinitekind.com
4 Posted by Stuart Beesley ... on 27 Sep, 2020 06:44 PM
Thx!!
Stuart Beesley (Mr Toolbox) closed this discussion on 28 Sep, 2020 05:14 PM.