예제 #1
0
  public Map<LocalDate, BigDecimal> getIncomePerDay(
      LocalDate dateFrom, LocalDate dateTo, List<Account> accounts, List<Category> categories) {
    Map<LocalDate, BigDecimal> income = new TreeMap<>(Collections.reverseOrder());
    List<ExternalTransaction> transactions =
        getTransactions(dateFrom, dateTo, accounts, categories);
    for (LocalDate iterDate = dateTo;
        iterDate.isAfter(dateFrom.minusDays(1));
        iterDate = iterDate.minusDays(1)) {
      List<ExternalTransaction> transactionList = new LinkedList<>();
      for (ExternalTransaction transaction : transactions) {
        if ((compareDates(transaction.dateProperty().get(), iterDate.minusDays(1)) == 1)
            && (compareDates(transaction.dateProperty().get(), iterDate.plusDays(1)) == -1)) {
          transactionList.add(transaction);
        }
      }
      BigDecimal value =
          transactionList
              .stream()
              .filter(a -> a.deltaProperty().get().compareTo(BigDecimal.ZERO) == 1)
              .map(a -> a.deltaProperty().get().abs())
              .reduce(BigDecimal.ZERO, BigDecimal::add);

      if (value.compareTo(BigDecimal.ZERO) > 0) income.put(iterDate, value);
    }

    return income;
  }
예제 #2
0
  public List<ExternalTransaction> getTransactions(
      LocalDate dateFrom, LocalDate dateTo, List<Account> accounts, List<Category> categories) {

    String date =
        "2016-" + new DecimalFormat("00").format(1) + "-" + new DecimalFormat("00").format(25);
    ExternalTransaction tr =
        new ExternalTransaction(
            "asdasda", accounts.get(0), (new BigDecimal(232)), org.joda.time.LocalDate.parse(date));
    tr.setCategory(new ArrayList<>(getCategories().get(0).subCategoriesObservableSet()).get(0));
    tr.setId(a++);
    LinkedList<ExternalTransaction> list = new LinkedList<>();
    list.add(tr);

    return list;
  }