Exemplo n.º 1
0
  /** Writes all investment account transactions within the date range */
  private void writeInvestmentTransactions() {
    for (Transaction transaction : account.getTransactions(startDate, endDate)) {
      if (transaction instanceof InvestmentTransaction) {
        InvestmentTransaction invTransaction = (InvestmentTransaction) transaction;

        switch (invTransaction.getTransactionType()) {
          case ADDSHARE:
          case BUYSHARE:
            writeBuyStockTransaction(invTransaction);
            break;
          case REMOVESHARE:
          case SELLSHARE:
            writeSellStockTransaction(invTransaction);
            break;
          case DIVIDEND:
            writeDividendTransaction(invTransaction);
            break;
          case REINVESTDIV:
            writeReinvestStockTransaction(invTransaction);
            break;
          default:
            break;
        }
      } else { // bank transaction, write it
        indentedWriter.println(wrapOpen(INVBANKTRAN), indentLevel++);
        writeBankTransaction(transaction);
        indentedWriter.println(wrapClose(INVBANKTRAN), --indentLevel);
      }
    }
  }
Exemplo n.º 2
0
  /**
   * Reinvested transaction is a two part process. Need to show Income into cash and then the
   * reinvestment from cash
   *
   * @param transaction transaction to write
   */
  private void writeReinvestStockTransaction(final InvestmentTransaction transaction) {

    // Part one, show dividend income to cash
    writeDividendTransaction(transaction);

    // Part two, show reinvest from cash
    indentedWriter.println(wrapOpen(REINVEST), indentLevel++);

    indentedWriter.println(wrapOpen(INVTRAN), indentLevel++);

    // write the FITID
    writeFitID(transaction);

    indentedWriter.println(wrap(DTTRADE, encodeDate(transaction.getDate())), indentLevel);
    indentedWriter.println(wrap(DTSETTLE, encodeDate(transaction.getDate())), indentLevel);
    indentedWriter.println(
        wrap(MEMO, "Distribution reinvestment: " + transaction.getSecurityNode().getSymbol()),
        indentLevel);
    indentedWriter.println(wrapClose(INVTRAN), --indentLevel);

    // write security information
    writeSecID(transaction.getSecurityNode());
    indentedWriter.println(wrap(INCOMETYPE, "DIV"), indentLevel);
    indentedWriter.println(
        wrap(TOTAL, transaction.getTotal(account).abs().negate().toPlainString()), indentLevel);
    indentedWriter.println(wrap(SUBACCTSEC, "CASH"), indentLevel);

    indentedWriter.println(wrap(UNITS, transaction.getQuantity().toPlainString()), indentLevel);
    indentedWriter.println(wrap(UNITPRICE, transaction.getPrice().toPlainString()), indentLevel);
    indentedWriter.println(wrap(COMMISSION, transaction.getFees().toPlainString()), indentLevel);
    indentedWriter.println(wrapClose(REINVEST), --indentLevel);
  }
Exemplo n.º 3
0
  private void writeSellStockTransaction(final InvestmentTransaction transaction) {
    indentedWriter.println(wrapOpen(SELLSTOCK), indentLevel++);
    indentedWriter.println(wrapOpen(INVSELL), indentLevel++);

    indentedWriter.println(wrapOpen(INVTRAN), indentLevel++);

    // write the FITID
    writeFitID(transaction);

    indentedWriter.println(wrap(DTTRADE, encodeDate(transaction.getDate())), indentLevel);
    indentedWriter.println(wrap(DTSETTLE, encodeDate(transaction.getDate())), indentLevel);
    indentedWriter.println(wrapClose(INVTRAN), --indentLevel);

    // write security information
    writeSecID(transaction.getSecurityNode());

    indentedWriter.println(wrap(UNITS, transaction.getQuantity().toPlainString()), indentLevel);
    indentedWriter.println(wrap(UNITPRICE, transaction.getPrice().toPlainString()), indentLevel);
    indentedWriter.println(wrap(COMMISSION, transaction.getFees().toPlainString()), indentLevel);
    indentedWriter.println(wrap(TOTAL, transaction.getTotal(account).toPlainString()), indentLevel);
    indentedWriter.println(wrap(SUBACCTSEC, "CASH"), indentLevel);
    indentedWriter.println(wrap(SUBACCTFUND, "CASH"), indentLevel);

    indentedWriter.println(wrapClose(INVSELL), --indentLevel);
    indentedWriter.println(wrap(SELLTYPE, "SELL"), indentLevel);
    indentedWriter.println(wrapClose(SELLSTOCK), --indentLevel);
  }
Exemplo n.º 4
0
  private void writeDividendTransaction(final InvestmentTransaction transaction) {
    indentedWriter.println(wrapOpen(INCOME), indentLevel++);

    indentedWriter.println(wrapOpen(INVTRAN), indentLevel++);
    writeFitID(transaction); // write the FITID

    indentedWriter.println(wrap(DTTRADE, encodeDate(transaction.getDate())), indentLevel);
    indentedWriter.println(wrap(DTSETTLE, encodeDate(transaction.getDate())), indentLevel);
    indentedWriter.println(
        wrap(MEMO, "Dividend: " + transaction.getSecurityNode().getSymbol()), indentLevel);
    indentedWriter.println(wrapClose(INVTRAN), --indentLevel);

    // write security information
    writeSecID(transaction.getSecurityNode());

    indentedWriter.println(wrap(INCOMETYPE, "DIV"), indentLevel);
    indentedWriter.println(
        wrap(TOTAL, transaction.getTotal(account).abs().toPlainString()), indentLevel);
    indentedWriter.println(wrap(SUBACCTSEC, "CASH"), indentLevel);
    indentedWriter.println(wrap(SUBACCTFUND, "CASH"), indentLevel);
    indentedWriter.println(wrapClose(INCOME), --indentLevel);
  }
  @Override
  public void modifyTransaction(Transaction tran) {

    assert tran instanceof InvestmentTransaction;

    assert tran.getTransactionType() == TransactionType.ADDSHARE
        || tran.getTransactionType() == TransactionType.REMOVESHARE;

    InvestmentTransaction _tran = (InvestmentTransaction) tran;

    clearForm();

    modTrans = tran;

    datePanel.setDate(tran.getLocalDate());
    memoField.setText(tran.getMemo());
    priceField.setDecimal(_tran.getPrice());
    quantityField.setDecimal(_tran.getQuantity());
    securityCombo.setSelectedNode(_tran.getSecurityNode());

    setReconciledState(tran.getReconciled(getAccount()));

    updateTotalField();
  }