Selecting and Sorting Transactions
Hi
I have an extension that displays transactions. I only want a subset of them (by date and account) but I want both sides of the transaction. I can search through the transaction set for the file but as time goes by the number of transactions will increase and thus the time to extract the transactions you want will increase. Is there a mechanism that retrieves a subset of transactions that does not involve reading through every transaction?
Once I have the transactions I wish them to be in the sequence they were entered. What fields within a transaction can be used to do the sorting?
Regards
Mike
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 03 Jun, 2015 03:25 PM
Hi Mike,
There are built-in methods for selecting a subset of transactions such as TransactionSet.getTransactions(TxnSearch) as well as a couple of static methods in TxnUtil for getting a search object for an account and/or date range. That is probably the fastest method although that doesn't use indexes and still just iterates over the set of transactions, so you'll want to make any searches pretty efficient.
You can sort by the static AccountUtil.sortTransactions(TxnSet, int sortField) method. The fields are defined as static ints in the AccountUtil class. With more recent builds you can use the *_COMPARATOR static comparators in the TxnUtil class.
Thanks!
Sean
2 Posted by Mike Bray (Quot... on 03 Jun, 2015 06:54 PM
Thanks Sean, I am still using 1204 so I will upgrade when you put out 2015.4. I will then look at the Comparator.
Regards
Mike
Ethan closed this discussion on 04 Jun, 2015 12:57 PM.