use of jgnash.engine.search.PayeeMatcher in project jgnash by ccavanaugh.
the class PayeePieChart method createPieDataSet.
private PieDataset[] createPieDataSet(final Account a) {
final DefaultPieDataset[] returnValue = new DefaultPieDataset[2];
returnValue[CREDIT] = new DefaultPieDataset();
returnValue[DEBIT] = new DefaultPieDataset();
if (a != null) {
//System.out.print("Account = "); System.out.println(a);
Map<String, BigDecimal> names = new HashMap<>();
List<TranTuple> list = getTransactions(a, new ArrayList<>(), startField.getLocalDate(), endField.getLocalDate());
CurrencyNode currency = a.getCurrencyNode();
for (final TranTuple tranTuple : list) {
Transaction tran = tranTuple.transaction;
Account account = tranTuple.account;
String payee = tran.getPayee();
BigDecimal sum = tran.getAmount(account);
sum = sum.multiply(account.getCurrencyNode().getExchangeRate(currency));
if (useFilters.isSelected()) {
for (String aFilterList : filterList) {
PayeeMatcher pm = new PayeeMatcher(aFilterList, false);
if (pm.matches(tran)) {
payee = aFilterList;
//System.out.println(filterList.get(i));
break;
}
}
}
if (names.containsKey(payee)) {
sum = sum.add(names.get(payee));
}
names.put(payee, sum);
}
for (final Map.Entry<String, BigDecimal> entry : names.entrySet()) {
BigDecimal value = entry.getValue();
if (value.compareTo(BigDecimal.ZERO) == -1) {
value = value.negate();
returnValue[DEBIT].setValue(entry.getKey(), value);
} else {
returnValue[CREDIT].setValue(entry.getKey(), value);
}
}
}
return returnValue;
}
use of jgnash.engine.search.PayeeMatcher in project jgnash by ccavanaugh.
the class FilterDecorator method setFilter.
@Override
public void setFilter(final String filter) {
this.filter = filter;
pm = new PayeeMatcher(filter, false);
updateMatches();
}
Aggregations