|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.mov.portfolio.Transaction
public class Transaction
Representation of a single transaction on the portfolio. A transaction is ANY kind of financial action from trading a stock to receiving credit interest. Transactions are used to build up a portfolio, the user does not enter how many shares they own but rather their share transactions and their current total is calculated from that.
Field Summary | |
---|---|
static int |
ACCUMULATE
Accumulate (buy) shares |
static int |
DEPOSIT
Deposit cash |
static int |
DIVIDEND
Dividend |
static int |
DIVIDEND_DRP
Dividend DRP (Dividend Reinvestment Programme) |
static int |
FEE
Fee (FID, TAX etc) |
static int |
INTEREST
Credit/Debit interest |
static int |
REDUCE
Reduce (sell) shares |
static int |
TRANSFER
Transfer money between two cash accounts |
static int |
WITHDRAWAL
Withdrawl cash |
Constructor Summary | |
---|---|
Transaction(int type,
TradingDate date,
Money amount,
Symbol symbol,
int shares,
Money tradeCost,
CashAccount cashAccount,
CashAccount cashAccount2,
ShareAccount shareAccount)
Create a new generic transaction. |
Method Summary | |
---|---|
java.lang.Object |
clone()
|
int |
compareTo(java.lang.Object object)
Compare this transaction to another one. |
boolean |
equals(java.lang.Object object)
Compares this transaction to another. |
Money |
getAmount()
Return the amount of this transaction if applicable. |
CashAccount |
getCashAccount()
Return the associated cash account if any. |
CashAccount |
getCashAccount2()
Return the second associated cash account if any. |
TradingDate |
getDate()
Return the date this transaction occured on. |
ShareAccount |
getShareAccount()
Return the associated share account if any. |
int |
getShares()
Return the shares traded if this transaction was a share transaction. |
Symbol |
getSymbol()
Return the symbol traded if this transaction was a share transaction. |
Money |
getTradeCost()
Return the cost of the trade if this transaction was a share transaction. |
int |
getType()
Return the type of this transaction. |
static Transaction |
newAccumulate(TradingDate date,
Money amount,
Symbol symbol,
int shares,
Money tradeCost,
CashAccount cashAccount,
ShareAccount shareAccount)
Create a new accumulate transaction. |
static Transaction |
newDeposit(TradingDate date,
Money amount,
CashAccount account)
Create a new deposit transaction. |
static Transaction |
newDividend(TradingDate date,
Money amount,
Symbol symbol,
CashAccount cashAccount,
ShareAccount shareAccount)
Create a new dividend transaction. |
static Transaction |
newDividendDRP(TradingDate date,
Symbol symbol,
int shares,
ShareAccount shareAccount)
Create a new dividend transaction. |
static Transaction |
newFee(TradingDate date,
Money amount,
CashAccount account)
Create a new fee transaction. |
static Transaction |
newInterest(TradingDate date,
Money amount,
CashAccount account)
Create a new interest transaction. |
static Transaction |
newReduce(TradingDate date,
Money amount,
Symbol symbol,
int shares,
Money tradeCost,
CashAccount cashAccount,
ShareAccount shareAccount)
Create a new reduce transaction. |
static Transaction |
newTransfer(TradingDate date,
Money amount,
CashAccount cashAccount,
CashAccount cashAccount2)
Create a new transfer transaction. |
static Transaction |
newWithdrawal(TradingDate date,
Money amount,
CashAccount account)
Create a new withdrawal transaction. |
void |
setCashAccount(CashAccount cashAccount)
Set the associated cash account. |
void |
setCashAccount2(CashAccount cashAccount2)
Set the secondary associated cash account. |
void |
setShareAccount(ShareAccount shareAccount)
Set the associated share account. |
static int |
stringToType(java.lang.String type)
Convert between a transaction type string and its transaction type. |
java.lang.String |
toString()
Convert this transaction to a tab-separated value string. |
static java.lang.String |
typeToString(int type)
Convert between a given transaction type and a text string. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int WITHDRAWAL
public static final int DEPOSIT
public static final int INTEREST
public static final int FEE
public static final int ACCUMULATE
public static final int REDUCE
public static final int DIVIDEND
public static final int DIVIDEND_DRP
public static final int TRANSFER
Constructor Detail |
---|
public Transaction(int type, TradingDate date, Money amount, Symbol symbol, int shares, Money tradeCost, CashAccount cashAccount, CashAccount cashAccount2, ShareAccount shareAccount)
type
- type of the transaction, e.g. INTEREST
date
- date the transaction took placeamount
- the amount/value/cost of the transactionsymbol
- for share trades and dividends, the symbol tradedshares
- for share trades and dividend DRPs, the number of
symbols bought/solded/re-investedtradeCost
- for shares trades, the cost of the trade
including any GST, Stamp Duty, Taxes etccashAccount
- related cash account (if any)cashAccount2
- second related cash account (if any)shareAccount
- related share account (if any)Method Detail |
---|
public static Transaction newWithdrawal(TradingDate date, Money amount, CashAccount account)
CashAccount
.
date
- date the transaction took placeamount
- the amount withdrawnaccount
- cash accountpublic static Transaction newDeposit(TradingDate date, Money amount, CashAccount account)
CashAccount
.
date
- date the transaction took placeamount
- the amount depositedaccount
- cash accountpublic static Transaction newInterest(TradingDate date, Money amount, CashAccount account)
CashAccount
has
received credit interest.
date
- date the transaction took placeamount
- the amount depositedaccount
- cash accountpublic static Transaction newFee(TradingDate date, Money amount, CashAccount account)
CashAccount
has been
debited with some sort of fee.
date
- date the transaction took placeamount
- the amount withdrawnaccount
- cash accountpublic static Transaction newAccumulate(TradingDate date, Money amount, Symbol symbol, int shares, Money tradeCost, CashAccount cashAccount, ShareAccount shareAccount)
date
- date the transaction took placeamount
- the cost of the shares (not including trade cost)symbol
- the symbol tradedshares
- number of shares tradedtradeCost
- for shares trades, the cost of the trade
including any GST, Stamp Duty, Taxes etcshareAccount
- share accountcashAccount
- cash accountpublic static Transaction newReduce(TradingDate date, Money amount, Symbol symbol, int shares, Money tradeCost, CashAccount cashAccount, ShareAccount shareAccount)
date
- date the transaction took placeamount
- the value of the shares (not including trade cost)symbol
- the symbol tradedshares
- number of shares tradedtradeCost
- for shares trades, the cost of the trade
including any GST, Stamp Duty, Taxes etcshareAccount
- share accountcashAccount
- cash accountpublic static Transaction newDividend(TradingDate date, Money amount, Symbol symbol, CashAccount cashAccount, ShareAccount shareAccount)
date
- date the transaction took placeamount
- the value of the dividendsymbol
- the stock paying the dividendshareAccount
- share accountcashAccount
- cash accountpublic static Transaction newDividendDRP(TradingDate date, Symbol symbol, int shares, ShareAccount shareAccount)
date
- date the transaction took placesymbol
- the stock paying the dividendshares
- the number of shares gainedshareAccount
- share accountpublic static Transaction newTransfer(TradingDate date, Money amount, CashAccount cashAccount, CashAccount cashAccount2)
date
- date the transaction took placeamount
- the value of the transfercashAccount
- source cash accountcashAccount2
- destination cash accountpublic static java.lang.String typeToString(int type)
type
- the transaction type
public static int stringToType(java.lang.String type)
type
- string representation of the transaction
public int compareTo(java.lang.Object object)
compareTo
in interface java.lang.Comparable
object
- other transaction object
-1
if this transaction is before;
0
if they fall on the same date;
1
if this transaction is afterpublic boolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- another transaction
true
if the transactions are equal; false
otherwisepublic java.lang.Object clone()
clone
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public int getType()
public TradingDate getDate()
public Money getAmount()
public Symbol getSymbol()
null
if this transaction was not a
share transactionpublic int getShares()
0
if this transaction was
not a share transactionpublic Money getTradeCost()
0
if this transaction was
not a share transactionpublic CashAccount getCashAccount()
null
if no cash account
associated with this transactionCashAccount
public CashAccount getCashAccount2()
null
if only zero or
one cash accounts are associated with this transactionCashAccount
public ShareAccount getShareAccount()
null
if no cash account
associated with this transactionShareAccount
public void setCashAccount(CashAccount cashAccount)
cashAccount
- the new cash accountCashAccount
public void setCashAccount2(CashAccount cashAccount2)
cashAccount2
- the new secondary cash accountCashAccount
public void setShareAccount(ShareAccount shareAccount)
shareAccount
- the new share accountShareAccount
|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |