Source:
<code>private CategoryDataset setupMonthlyDataset() { SimpleDateFormat df = new SimpleDateFormat("MMM-yyyy"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); ArrayList<Transaction> transactions = getCampaign().getFinances().getAllTransactions(); Calendar cal = Calendar.getInstance(); String pastMonthYear = ""; Money monthlyRevenue = Money.zero(); Money monthlyExpenditures = Money.zero(); for (int i = 0; i < transactions.size(); i++) { cal.setTime(transactions.get(i).getDate()); if (pastMonthYear.equals(df.format(cal.getTime()))) { if (transactions.get(i).getAmount().isPositive()) { monthlyRevenue = monthlyRevenue.plus(transactions.get(i).getAmount()); } else { <START> monthlyExpenditures = monthlyExpenditures.plus(transactions.get(i).getAmount()); <END> } } else { if (i != 0) { dataset.addValue(monthlyRevenue.getAmount().doubleValue(), resourceMap.getString("graphMonthlyRevenue.text"), pastMonthYear); dataset.addValue(monthlyExpenditures.getAmount().doubleValue(), resourceMap.getString("graphMonthlyExpenditures.text"), pastMonthYear); monthlyRevenue = Money.zero(); monthlyExpenditures = Money.zero(); } pastMonthYear = df.format(cal.getTime()); if (transactions.get(i).getAmount().isPositive()) { monthlyRevenue = transactions.get(i).getAmount(); } else { monthlyExpenditures = transactions.get(i).getAmount(); } } if (i == transactions.size()-1) { dataset.addValue(monthlyRevenue.getAmount().doubleValue(), resourceMap.getString("graphMonthlyRevenue.text"), pastMonthYear); dataset.addValue(monthlyExpenditures.getAmount().doubleValue(), resourceMap.getString("graphMonthlyExpenditures.text"), pastMonthYear); } } return dataset; }</code><technical_language>Missing Math.abs(). this if...else get rolled if getAbsoluteAmount() Money class</technical_language>

Target:
private CategoryDataset setupMonthlyDataset() { SimpleDateFormat df = new SimpleDateFormat("MMM-yyyy"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); ArrayList<Transaction> transactions = getCampaign().getFinances().getAllTransactions(); Calendar cal = Calendar.getInstance(); String pastMonthYear = ""; Money monthlyRevenue = Money.zero(); Money monthlyExpenditures = Money.zero(); for (int i = 0; i < transactions.size(); i++) { cal.setTime(transactions.get(i).getDate()); if (pastMonthYear.equals(df.format(cal.getTime()))) { if (transactions.get(i).getAmount().isPositive()) { monthlyRevenue = monthlyRevenue.plus(transactions.get(i).getAmount()); } else { monthlyExpenditures = monthlyExpenditures.plus(transactions.get(i).getAmount().absolute()); } } else { if (i != 0) { dataset.addValue(monthlyRevenue.getAmount().doubleValue(), resourceMap.getString("graphMonthlyRevenue.text"), pastMonthYear); dataset.addValue(monthlyExpenditures.getAmount().doubleValue(), resourceMap.getString("graphMonthlyExpenditures.text"), pastMonthYear); monthlyRevenue = Money.zero(); monthlyExpenditures = Money.zero(); } pastMonthYear = df.format(cal.getTime()); if (transactions.get(i).getAmount().isPositive()) { monthlyRevenue = transactions.get(i).getAmount(); } else { monthlyExpenditures = transactions.get(i).getAmount().absolute(); } } if (i == transactions.size()-1) { dataset.addValue(monthlyRevenue.getAmount().doubleValue(), resourceMap.getString("graphMonthlyRevenue.text"), pastMonthYear); dataset.addValue(monthlyExpenditures.getAmount().doubleValue(), resourceMap.getString("graphMonthlyExpenditures.text"), pastMonthYear); } } return dataset; }