Example #1
0
  /**
   * Clones a <code>List</code> of <code>TransactionEntry(s)</code>
   *
   * @param fees <code>List</code> of fees to clone
   */
  public void setTransactionEntries(final List<TransactionEntry> fees) {
    feeList = new ArrayList<>();

    if (fees.size() == 1) {
      TransactionEntry e = fees.get(0);

      if (e.getCreditAccount().equals(e.getDebitAccount())) {
        feeField.setDecimal(e.getAmount(account).abs());
      } else {
        try {
          feeList.add((TransactionEntry) e.clone()); // copy over the provided set's entry
        } catch (CloneNotSupportedException e1) {
          Logger.getLogger(FeePanel.class.getName())
              .log(Level.SEVERE, e1.getLocalizedMessage(), e1);
        }
        feeField.setDecimal(sumFees().abs());
      }
    } else {
      for (TransactionEntry entry : fees) { // clone the provided set's entries
        try {
          feeList.add((TransactionEntry) entry.clone());
        } catch (CloneNotSupportedException e) {
          Logger.getLogger(FeePanel.class.getName()).log(Level.SEVERE, e.toString(), e);
        }
      }

      feeField.setDecimal(sumFees().abs());
    }

    feeField.setEditable(feeList.size() < 1);
  }
Example #2
0
  private BigDecimal sumFees() {
    BigDecimal sum = BigDecimal.ZERO;

    for (TransactionEntry entry : feeList) {
      sum = sum.add(entry.getAmount(account));
    }

    return sum;
  }