Пример #1
0
  private PieChartModel getPieChartModel(final List<BaseEntry> entries) {
    PieChartModel pieModel = new PieChartModel();

    Collections.sort(entries, new BaseEntryComparator());

    for (BaseEntry entry : entries) {
      pieModel.set(entry.getName(), entry.getInitialAmount());
    }

    return pieModel;
  }
Пример #2
0
  public List<BigDecimal> getEntriesForBaseEntry(final BaseEntry baseEntry) {
    List<BigDecimal> entryAmounts = new ArrayList<>();

    for (Statement statement : statements) {
      List<Entry> entries = new ArrayList<>();
      entries.addAll(statement.getIncomes());
      entries.addAll(statement.getExpences());
      boolean amountForCurrentEntrySet = false;

      for (Entry entry : entries) {
        if (entry.getBaseEntry().getName().equals(baseEntry.getName())) {
          entryAmounts.add(entry.getAmount());
          amountForCurrentEntrySet = true;
          continue;
        }
      }
      if (!amountForCurrentEntrySet) {
        entryAmounts.add(null);
      }
    }

    return entryAmounts;
  }
Пример #3
0
 public void saveEntries() {
   for (BaseEntry baseEntry : incomeEntries) {
     if (baseEntry.isSelected()) {
       Entry entry = new Entry();
       entry.setBaseEntry(baseEntry);
       entry.setAmount(baseEntry.getInitialAmount());
       entryRepository.saveEntry(entry);
       statement.getEntries().add(entry);
     }
   }
   statementRepository.saveStatement(statement);
   for (BaseEntry baseEntry : expenceEntries) {
     if (baseEntry.isSelected()) {
       Entry entry = new Entry();
       entry.setBaseEntry(baseEntry);
       entry.setAmount(baseEntry.getInitialAmount());
       entryRepository.saveEntry(entry);
       statement.getEntries().add(entry);
     }
   }
   statementRepository.saveStatement(statement);
 }