com.moneydance.apps.md.model
Class AbstractTxn

java.lang.Object
  extended by com.moneydance.apps.md.model.AbstractTxn
All Implemented Interfaces:
Txn
Direct Known Subclasses:
ParentTxn, SplitTxn

public abstract class AbstractTxn
extends java.lang.Object
implements Txn

This is the base class for all types of transactions. Each transaction is assigned to one account and has an amount that adds to, or subtracts from the value of the account. Each transaction can also have an associated set of 'tags'. Tags are arbitrary key-value pairs of String objects. Typically a transaction will have two sides 1) a "parent" transaction, and 2) one or more "split" transactions. The value of the parent transaction is defined by the sum of the values of the split transactions (possibly adjusted by the rate of each of the split transactions).


Field Summary
static int BANK_TRANSACTION_TYPE
           
static int SPLIT_TRANSACTION_TYPE
           
static byte STATUS_CLEARED
           
static byte STATUS_RECONCILING
           
static byte STATUS_UNRECONCILED
           
static java.lang.String TAG_FI_ID
           
static java.lang.String TAG_FITID_PREFIX
           
static java.lang.String TAG_INVST_SPLIT_EXP
           
static java.lang.String TAG_INVST_SPLIT_FEE
           
static java.lang.String TAG_INVST_SPLIT_INC
           
static java.lang.String TAG_INVST_SPLIT_SEC
           
static java.lang.String TAG_INVST_SPLIT_TYPE
           
static java.lang.String TAG_INVST_SPLIT_XFR
           
static java.lang.String TAG_IS_NEW_TXN
           
static java.lang.String TAG_ONLINE_PMT_ID
           
static java.lang.String TAG_QIF_IMPORT_SESSION
           
static java.lang.String TAG_QIF_INVST_ACTION
           
static java.lang.String TAG_RECON_ASOFDT
           
static java.lang.String TAG_RECON_DATE
           
static java.lang.String TAG_SPLIT_ADDED
           
static java.lang.String TAG_SPLIT_AMOUNT
           
static java.lang.String TAG_SPLIT_CALC
           
static java.lang.String TAG_SPLIT_PAIR
           
static java.lang.String TRANSFER_TYPE_BANK
           
static java.lang.String TRANSFER_TYPE_BUYSELL
           
static java.lang.String TRANSFER_TYPE_BUYSELLXFR
           
static java.lang.String TRANSFER_TYPE_DIVIDEND
           
static java.lang.String TRANSFER_TYPE_DIVIDENDXFR
           
static java.lang.String TRANSFER_TYPE_MISCINCEXP
           
static java.lang.String TRANSFER_TYPE_SHORTCOVER
           
 
Constructor Summary
AbstractTxn(Account account, java.lang.String description, long txnId, byte status)
          Construct a transaction with the given account, description, transaction ID (-1 for a new transaction) and status.
 
Method Summary
 Account getAccount()
          Get the account associated with this transaction.
 int getCheckNumAsInt()
          Get the check number as an integer (returns 0 if it's not an integer)
abstract  java.lang.String getCheckNumber()
          Get the checknumber associated with this transaction.
abstract  long getDate()
          Deprecated. use getDateInt() instead
abstract  long getDateEntered()
          Get the date that this transaction was entered.
abstract  int getDateInt()
          Get the date of this transaction
 java.lang.String getDescription()
          Get the description associated with this transaction.
 java.lang.String getFIID()
          Returns the identifier for the financial institution from which this transaction was downloaded, or null if no financial institution information has been provided.
 java.lang.String getFiTxnId(int protocolId)
          Return the ID that the financial institution uses to identify this transaction.
abstract  AbstractTxn getOtherTxn(int i)
          Get the transaction that make up the other side of this transaction at the specified index.
abstract  int getOtherTxnCount()
          Get the number of transactions from the "other side" of this transaction.
abstract  ParentTxn getParentTxn()
          Get the ParentTxn of this transfer.
 byte getStatus()
          Get the status associated with this transaction.
 char getStatusChar()
          Get a character that indicates the status of this transaction
 java.lang.String getTag(java.lang.String key)
          Get the value associated with the given key (if any) in this transaction's set of tags.
 java.lang.String getTag(java.lang.String key, java.lang.String defaultVal)
          Get the value associated with the given key in this transactions set of tags.
 TagSet getTags()
           
abstract  long getTaxDate()
          Deprecated. use getTaxDateInt() instead
abstract  int getTaxDateInt()
          Get the date of this transaction for tax purposes.
abstract  java.lang.String getTransferType()
          Get the type of transaction.
 long getTxnId()
          Get the transaction ID.
abstract  long getValue()
          Get the value of this transaction, in the currency assigned to the account for this transaction.
 boolean isDirty()
          Returns true if this transaction has been modified since it was last saved.
 boolean isNew()
          Returns whether or not this transaction should be considered "unread" since having been downloaded
abstract  boolean isTransferTo(Account acct)
          Check whether or not this transaction includes a transfer to the given account.
 boolean needsToBePrinted()
          Returns true if this transaction has been marked as to-be-printed.
 void removeTag(java.lang.String key)
          Remove the key-value pair with the given key from the set of tags.
 void resetDirty()
          Mark this transaction as unmodified.
 void setAccount(Account newAccount)
          Set the account associated with this transaction.
 void setDescription(java.lang.String newDescription)
          Set the description associated with this transaction.
 void setDirty()
          Mark this transaction as modified, and needing to be saved.
 void setFIID(java.lang.String fiID)
          Sets the identifier for the financial institution from which this transaction was downloaded.
 void setFiTxnId(int protocolId, java.lang.String fitid)
          Set the ID that the financial institution uses to identify this transaction.
 void setIsNew(boolean isNew)
          Sets whether or not this transaction should be considered "unread" since having been downloaded
 void setStatus(byte newStatus)
          Set the status associated with this transaction.
 void setTag(java.lang.String key, java.lang.String value)
          Set the value associated with the specified key in this reminders set of tags.
 void setTags(TagSet newTags)
          Set the TagSet associated with this object.
 boolean wasDownloaded()
          Return true iff this transaction has a FI transaction ID associated with it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STATUS_CLEARED

public static final byte STATUS_CLEARED
See Also:
Constant Field Values

STATUS_RECONCILING

public static final byte STATUS_RECONCILING
See Also:
Constant Field Values

STATUS_UNRECONCILED

public static final byte STATUS_UNRECONCILED
See Also:
Constant Field Values

BANK_TRANSACTION_TYPE

public static final int BANK_TRANSACTION_TYPE
See Also:
Constant Field Values

SPLIT_TRANSACTION_TYPE

public static final int SPLIT_TRANSACTION_TYPE
See Also:
Constant Field Values

TRANSFER_TYPE_BANK

public static final java.lang.String TRANSFER_TYPE_BANK
See Also:
Constant Field Values

TRANSFER_TYPE_BUYSELL

public static final java.lang.String TRANSFER_TYPE_BUYSELL
See Also:
Constant Field Values

TRANSFER_TYPE_SHORTCOVER

public static final java.lang.String TRANSFER_TYPE_SHORTCOVER
See Also:
Constant Field Values

TRANSFER_TYPE_BUYSELLXFR

public static final java.lang.String TRANSFER_TYPE_BUYSELLXFR
See Also:
Constant Field Values

TRANSFER_TYPE_DIVIDEND

public static final java.lang.String TRANSFER_TYPE_DIVIDEND
See Also:
Constant Field Values

TRANSFER_TYPE_DIVIDENDXFR

public static final java.lang.String TRANSFER_TYPE_DIVIDENDXFR
See Also:
Constant Field Values

TRANSFER_TYPE_MISCINCEXP

public static final java.lang.String TRANSFER_TYPE_MISCINCEXP
See Also:
Constant Field Values

TAG_FITID_PREFIX

public static final java.lang.String TAG_FITID_PREFIX
See Also:
Constant Field Values

TAG_FI_ID

public static final java.lang.String TAG_FI_ID
See Also:
Constant Field Values

TAG_ONLINE_PMT_ID

public static final java.lang.String TAG_ONLINE_PMT_ID
See Also:
Constant Field Values

TAG_QIF_IMPORT_SESSION

public static final java.lang.String TAG_QIF_IMPORT_SESSION
See Also:
Constant Field Values

TAG_QIF_INVST_ACTION

public static final java.lang.String TAG_QIF_INVST_ACTION
See Also:
Constant Field Values

TAG_SPLIT_CALC

public static final java.lang.String TAG_SPLIT_CALC
See Also:
Constant Field Values

TAG_SPLIT_ADDED

public static final java.lang.String TAG_SPLIT_ADDED
See Also:
Constant Field Values

TAG_SPLIT_AMOUNT

public static final java.lang.String TAG_SPLIT_AMOUNT
See Also:
Constant Field Values

TAG_SPLIT_PAIR

public static final java.lang.String TAG_SPLIT_PAIR
See Also:
Constant Field Values

TAG_IS_NEW_TXN

public static final java.lang.String TAG_IS_NEW_TXN
See Also:
Constant Field Values

TAG_INVST_SPLIT_TYPE

public static final java.lang.String TAG_INVST_SPLIT_TYPE
See Also:
Constant Field Values

TAG_INVST_SPLIT_FEE

public static final java.lang.String TAG_INVST_SPLIT_FEE
See Also:
Constant Field Values

TAG_INVST_SPLIT_SEC

public static final java.lang.String TAG_INVST_SPLIT_SEC
See Also:
Constant Field Values

TAG_INVST_SPLIT_XFR

public static final java.lang.String TAG_INVST_SPLIT_XFR
See Also:
Constant Field Values

TAG_INVST_SPLIT_EXP

public static final java.lang.String TAG_INVST_SPLIT_EXP
See Also:
Constant Field Values

TAG_INVST_SPLIT_INC

public static final java.lang.String TAG_INVST_SPLIT_INC
See Also:
Constant Field Values

TAG_RECON_DATE

public static final java.lang.String TAG_RECON_DATE
See Also:
Constant Field Values

TAG_RECON_ASOFDT

public static final java.lang.String TAG_RECON_ASOFDT
See Also:
Constant Field Values
Constructor Detail

AbstractTxn

public AbstractTxn(Account account,
                   java.lang.String description,
                   long txnId,
                   byte status)
Construct a transaction with the given account, description, transaction ID (-1 for a new transaction) and status.

Method Detail

getDate

public abstract long getDate()
Deprecated. use getDateInt() instead

Get the date of this transaction


getDateEntered

public abstract long getDateEntered()
Get the date that this transaction was entered.

Specified by:
getDateEntered in interface Txn

getTaxDate

public abstract long getTaxDate()
Deprecated. use getTaxDateInt() instead

Get the date of this transaction for tax purposes.


getDateInt

public abstract int getDateInt()
Get the date of this transaction

Specified by:
getDateInt in interface Txn

getTaxDateInt

public abstract int getTaxDateInt()
Get the date of this transaction for tax purposes.

Specified by:
getTaxDateInt in interface Txn

getValue

public abstract long getValue()
Get the value of this transaction, in the currency assigned to the account for this transaction.

Specified by:
getValue in interface Txn

getParentTxn

public abstract ParentTxn getParentTxn()
Get the ParentTxn of this transfer.

Specified by:
getParentTxn in interface Txn

getOtherTxnCount

public abstract int getOtherTxnCount()
Get the number of transactions from the "other side" of this transaction. For splits, this will always be 1. For ParentTxns, this will be the number of splits.

Specified by:
getOtherTxnCount in interface Txn

getOtherTxn

public abstract AbstractTxn getOtherTxn(int i)
Get the transaction that make up the other side of this transaction at the specified index. For SplitTxns, this index should always be 0 because there is only one "other transaction". for ParentTxns, this will return the split at the specified index.

Specified by:
getOtherTxn in interface Txn

isTransferTo

public abstract boolean isTransferTo(Account acct)
Check whether or not this transaction includes a transfer to the given account.

Specified by:
isTransferTo in interface Txn

getTransferType

public abstract java.lang.String getTransferType()
Get the type of transaction. Usually only used in the investment register to differentiate between buy, sell, and stock split transactions.

Specified by:
getTransferType in interface Txn

getTxnId

public final long getTxnId()
Get the transaction ID. The transaction ID must be unique within each Moneydance file.

Specified by:
getTxnId in interface Txn

getAccount

public final Account getAccount()
Get the account associated with this transaction.

Specified by:
getAccount in interface Txn

setAccount

public final void setAccount(Account newAccount)
Set the account associated with this transaction.


getDescription

public final java.lang.String getDescription()
Get the description associated with this transaction.

Specified by:
getDescription in interface Txn

setDescription

public final void setDescription(java.lang.String newDescription)
Set the description associated with this transaction.


getStatusChar

public final char getStatusChar()
Get a character that indicates the status of this transaction

Specified by:
getStatusChar in interface Txn

getStatus

public final byte getStatus()
Get the status associated with this transaction.

Specified by:
getStatus in interface Txn

setStatus

public final void setStatus(byte newStatus)
Set the status associated with this transaction.

Specified by:
setStatus in interface Txn

getCheckNumber

public abstract java.lang.String getCheckNumber()
Get the checknumber associated with this transaction.

Specified by:
getCheckNumber in interface Txn

getCheckNumAsInt

public int getCheckNumAsInt()
Get the check number as an integer (returns 0 if it's not an integer)

Specified by:
getCheckNumAsInt in interface Txn

getFiTxnId

public final java.lang.String getFiTxnId(int protocolId)
Return the ID that the financial institution uses to identify this transaction. Specific to the protocolId which is defined in OnlineTxn.


setFiTxnId

public final void setFiTxnId(int protocolId,
                             java.lang.String fitid)
Set the ID that the financial institution uses to identify this transaction. The TID is specific to the protocol type which is defined in OnlineTxn.


getFIID

public final java.lang.String getFIID()
Returns the identifier for the financial institution from which this transaction was downloaded, or null if no financial institution information has been provided.


setFIID

public final void setFIID(java.lang.String fiID)
Sets the identifier for the financial institution from which this transaction was downloaded. If null is provided then the FI ID is removed from this tranaction.


wasDownloaded

public final boolean wasDownloaded()
Return true iff this transaction has a FI transaction ID associated with it. This method is only avaialable as of build 551

Specified by:
wasDownloaded in interface Txn

isNew

public boolean isNew()
Returns whether or not this transaction should be considered "unread" since having been downloaded

Specified by:
isNew in interface Txn

setIsNew

public void setIsNew(boolean isNew)
Sets whether or not this transaction should be considered "unread" since having been downloaded


isDirty

public final boolean isDirty()
Returns true if this transaction has been modified since it was last saved.


setDirty

public final void setDirty()
Mark this transaction as modified, and needing to be saved.


resetDirty

public final void resetDirty()
Mark this transaction as unmodified. This should be called only after being saved.


getTags

public final TagSet getTags()

getTag

public final java.lang.String getTag(java.lang.String key)
Get the value associated with the given key (if any) in this transaction's set of tags.

Specified by:
getTag in interface Txn

getTag

public final java.lang.String getTag(java.lang.String key,
                                     java.lang.String defaultVal)
Get the value associated with the given key in this transactions set of tags. If there is no value associated with the given key, return the given default value.

Specified by:
getTag in interface Txn

setTag

public final void setTag(java.lang.String key,
                         java.lang.String value)
Set the value associated with the specified key in this reminders set of tags. If there is already a value associated with the given key, it will be replaced.


removeTag

public final void removeTag(java.lang.String key)
Remove the key-value pair with the given key from the set of tags.


setTags

public final void setTags(TagSet newTags)
Set the TagSet associated with this object. This should only be called when initially constructing this object.


needsToBePrinted

public final boolean needsToBePrinted()
Returns true if this transaction has been marked as to-be-printed.