Exemple #1
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;
  }
 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);
 }