class ReportsService {

	public ExpensesByCategoryReport expensesByCategory() {
		ExpensesByCategoryReport report = new ExpensesByCategoryReport();

		Set<Long> yearMonths = new HashSet<>();

		Transactions transactions = transactionsService.retrieve();
		for (Transaction transaction : transactions.getTransactions()) {
			Long yearMonth = yearMonth(transaction.getDate());
			yearMonths.add(yearMonth);
		}
		List<Long> sortedMonths = new ArrayList<>(yearMonths);
		Collections.sort(sortedMonths);
		for (final Long yearMonth : sortedMonths) {
			report.add(detailsForMonth(yearMonth));
		}

		return report;
	}

	@Inject  ReportsService(TransactionsService transactionsService);

}