Traversing the Account Tree
I have hit an issue with traversing the tree of accounts. I thought that if you took the root account and traversed the tree by using:
loadAccounts(Main.context.getRootAccount());
private void loadAccounts(Account parentAcct) {
int sz = parentAcct.getSubAccountCount();
for(int i=0; i<sz; i++) {
Account acct = parentAcct.getSubAccount(i);
..........
loadAccounts(acct);
}
You would eventually load every account in the file. This does not seem to be happening. I have added a Security and it is not appearing in the hierarchy. Is there a different way of traversing the tree?
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 09 May, 2018 09:23 AM
Hi Mike,
That does look like it should work, but only if the security was added to an investment account. If you'd like a list of all securities you can get them from the AccountBook's CurrencyTable. A security is only represented by an account if it is used by one or more investment accounts.
Another way to iterate over all accounts is using the AccountIterator (https://infinitekind.com/dev/apidoc/com/infinitekind/moneydance/mod...). The account iterator or functions such as AccountUtil.allMatchesForSearch() would be a bit faster as it doesn't rely on traversing the account hierarchy.
Thanks!
Sean Reilly
Developer, The Infinite Kind
http://infinitekind.com
2 Posted by Mike Bray (Quot... on 09 May, 2018 03:45 PM
Thanks Sean for the pointers. I will update my extensions accordingly.
Mike
Mike Bray (Quote Loader Author) closed this discussion on 15 Jun, 2018 02:34 PM.