tag:infinitekind.tenderapp.com,2009-01-14:/discussions/moneydance-development/2809-depth-of-getsubaccountsInfinite Kind: Discussion 2020-06-11T05:34:35Ztag:infinitekind.tenderapp.com,2009-01-14:Comment/483765022020-06-02T04:51:08Z2020-06-02T04:51:09ZDepth of getSubAccounts()<div><p><code>getSubAccounts​(AcctFilter search)</code> is <a href="https://infinitekind.com/dev/apidoc/com/infinitekind/moneydance/model/Account.html#getSubAccounts(com.infinitekind.moneydance.model.AcctFilter)">documented</a> as follows:</p>
<blockquote>
<p>Return a list of all accounts under this account matching the given filter. This includes accounts not just direct children but all accounts under this one in the hierarchy.</p>
</blockquote>
<p>It's very reasonable that a filtered query would search the entire tree.</p>
<p><code>getSubAccounts</code> also has a parametrerless overload, which lacks any explicit documentation. As a developer, I'm not confident whether or not the parameterless version will also return all children throughout the hierarchy, or if it will only include immediate children. In my experience, I have seen both approaches to hierarchy APIs.</p>
<p>I experimented on my own, and ended up finding that the parameterless <code>getSubAccounts</code> does indeed only return direct children.</p></div>Max Pixeltag:infinitekind.tenderapp.com,2009-01-14:Comment/483765022020-06-02T09:57:51Z2020-06-02T09:57:51ZDepth of getSubAccounts()<div><p>Hi Max,</p>
<p>As you discovered, the parameter-less getSubAccounts() does only ever return immediate sub-accounts. The getSubAccounts with the filter parameter basically calls through to the AccountUtil.getAccountIterator(...) method. In general, I'd recommend using the AccountUtil.* static methods for querying accounts and account hierarchies. I think those make it a little more explicit what it is that is returned.</p>
<p>Thanks!</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/483765022020-06-02T10:02:31Z2020-06-02T10:02:31ZDepth of getSubAccounts()<div><p>I've also updated the documentation on getSubAccounts(). Thanks for the note!</p>
<p>--<br>
Sean Reilly<br>
Developer, The Infinite Kind<br>
<a href="https://infinitekind.com">https://infinitekind.com</a></p></div>Sean Reilly