private CurrencyExchangeRateMap exchangeRateMap;
private BigDecimal amount;
private String query;
public TxactionList build(Collection<Txaction> txactions) {
TxactionList txactionList = new TxactionList();
// remove disabled, deleted, etc, sort them in reverse chronological order
final List<Txaction> resultTxactions = sort(filter(txactions));
// set the total count to all the ones that could ever be shown
txactionList.setTotalCount(resultTxactions.size());
if (resultTxactions.isEmpty()) {
return txactionList;
}
// hack of the end of the list since they are not useful in balance calculation
applyLimit(resultTxactions);
for (Txaction txaction : resultTxactions) {
txactionList.add(new TxactionListItem(txaction));
}
if (tags.isEmpty() && merchantNames.isEmpty() && calculateBalances) {
// calculate balances before removing the offset as those Txactions may affect the balances
txactionList.calculateRunningTotalBalances(accounts, currency, exchangeRateMap);
}
// hack off the front of the list we were asked to hide
applyOffset(txactionList);