Ejemplo n.º 1
0
  private void registerListeners() {
    FocusListener focusListener =
        new FocusAdapter() {

          @Override
          public void focusLost(final FocusEvent evt) {
            updateTotalField();
          }
        };

    feePanel.addFocusListener(focusListener);

    feePanel.addActionListener(this);
    gainsPanel.addActionListener(this);

    quantityField.addFocusListener(focusListener);
    priceField.addFocusListener(focusListener);

    datePanel.getDateField().addKeyListener(keyListener);
    feePanel.addKeyListener(keyListener);
    memoField.addKeyListener(keyListener);
    priceField.addKeyListener(keyListener);
    quantityField.addKeyListener(keyListener);
    securityCombo.addKeyListener(keyListener);
    reconciledButton.addKeyListener(keyListener);
  }
Ejemplo n.º 2
0
  @Override
  public void modifyTransaction(final Transaction tran) {
    if (!(tran instanceof InvestmentTransaction)) {
      throw new IllegalArgumentException("bad tranType");
    }
    clearForm();

    datePanel.setDate(tran.getDate());

    List<TransactionEntry> entries = tran.getTransactionEntries();

    feePanel.setTransactionEntries(((InvestmentTransaction) tran).getInvestmentFeeEntries());

    gainsPanel.setTransactionEntries(((InvestmentTransaction) tran).getInvestmentGainLossEntries());

    for (TransactionEntry e : entries) {
      if (e instanceof TransactionEntrySellX) {
        AbstractInvestmentTransactionEntry entry = (AbstractInvestmentTransactionEntry) e;

        memoField.setText(e.getMemo());
        priceField.setDecimal(entry.getPrice());
        quantityField.setDecimal(entry.getQuantity());
        securityCombo.setSelectedNode(entry.getSecurityNode());

        accountExchangePanel.setSelectedAccount(entry.getDebitAccount());
        accountExchangePanel.setExchangedAmount(entry.getDebitAmount().abs());
      }
    }

    updateTotalField();

    modTrans = tran;

    reconciledButton.setSelected(tran.getReconciled(getAccount()) == ReconciledState.RECONCILED);
  }
Ejemplo n.º 3
0
  @Override
  public void clearForm() {
    super.clearForm();

    accountExchangePanel.setSelectedAccount(getAccount());
    feePanel.clearForm();
    gainsPanel.clearForm();
    updateTotalField();
  }
Ejemplo n.º 4
0
  void updateTotalField() {
    BigDecimal fee = feePanel.getDecimal();
    BigDecimal quantity = quantityField.getDecimal();
    BigDecimal price = priceField.getDecimal();

    BigDecimal value = quantity.multiply(price);

    value = value.subtract(fee);

    totalField.setDecimal(value);
  }
Ejemplo n.º 5
0
  @Override
  public Transaction buildTransaction() {
    BigDecimal exchangeRate = accountExchangePanel.getExchangeRate();

    Collection<TransactionEntry> fees = feePanel.getTransactions();

    Collection<TransactionEntry> gains = gainsPanel.getTransactions();

    return TransactionFactory.generateSellXTransaction(
        accountExchangePanel.getSelectedAccount(),
        getAccount(),
        securityCombo.getSelectedNode(),
        priceField.getDecimal(),
        quantityField.getDecimal(),
        exchangeRate,
        datePanel.getDate(),
        memoField.getText(),
        reconciledButton.isSelected(),
        fees,
        gains);
  }