Ejemplo n.º 1
0
  private void flag() {
    Set<Transaction.FraudStatus> permittedFlags = EnumSet.allOf(Transaction.FraudStatus.class);
    if (controller.getCurrentUser().getRole() != User.Role.AUDITOR) {
      permittedFlags.remove(Transaction.FraudStatus.REVERSED);
    }

    Transaction.FraudStatus status =
        (Transaction.FraudStatus)
            JOptionPane.showInputDialog(
                this,
                "Flag as:",
                "Flag",
                JOptionPane.QUESTION_MESSAGE,
                null,
                permittedFlags.toArray(),
                Transaction.FraudStatus.NOT_FLAGGED);
    if (status == null) {
      return;
    }
    try {
      Transaction transaction = account.getHistory().get(historyTable.getSelectedRow());
      transaction.setFraudStatus(status, account);
      update();
    } catch (InvalidInputException iix) {
      controller.handleException(this, iix);
    } catch (InsufficientFundsException ifx) {
      controller.handleException(this, ifx);
    }
  }
Ejemplo n.º 2
0
  public void update() {
    infoPanel.update();

    Object[][] history = new Object[account.getHistory().size()][5];
    int i = 0;
    for (Transaction t : account.getHistory()) {
      history[i][0] = t.getType();
      BigDecimal amount;
      BigDecimal balance;
      if (account.getType().isLoan()) {
        amount = (t.getType().isPositive() ? t.getAmount().negate() : t.getAmount());
        balance = t.getBalance().negate();
      } else {
        amount = (t.getType().isPositive() ? t.getAmount() : t.getAmount().negate());
        balance = t.getBalance();
      }
      history[i][1] = FORMATTER.valueToString(amount);
      history[i][2] = FORMATTER.valueToString(balance);
      history[i][3] = t.getTimestamp();
      history[i][4] = t.getFraudStatus();
      i++;
    }
    historyTable.setModel(
        new javax.swing.table.DefaultTableModel(
            history, new String[] {"Type", "Amount", "Balance", "Month", "Flag"}) {
          @Override
          public boolean isCellEditable(int rowIndex, int columnIndex) {
            return false;
          }
        });
    historyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    historyTable.revalidate();
  }