jgnash.engine
Class TransactionEntry

java.lang.Object
  extended by jgnash.engine.TransactionEntry
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable<TransactionEntry>
Direct Known Subclasses:
AbstractInvestmentTransactionEntry

public class TransactionEntry
extends java.lang.Object
implements java.lang.Comparable<TransactionEntry>, java.lang.Cloneable

Transaction Entry

Each Transaction entry has an amount for the credit and debit side of the transaction. When the debit and credit account has the same currency, one amount will be the negated value of the other. If the credit and debit accounts do not have the same currency then the amounts will be different to represent the exchanged value at the time of the transaction.

If the entry is to be used as an "single entry / adjustment" transaction, then the credit and debit account must be set to the same account and the credit and debit amounts must be set to the same value.

Version:
$Id$
Author:
Craig Cavanaugh

Field Summary
private  TransactionTag cachedTransactionTag
           
private  Account creditAccount
          Account with balance being increased
private  java.math.BigDecimal creditAmount
           
private  ReconciledState creditReconciled
          Reconciled state of the transaction
private  Account debitAccount
          Account with balance being decreased
private  java.math.BigDecimal debitAmount
           
private  ReconciledState debitReconciled
          Reconciled state of the debit side of the transaction
private  java.lang.String memo
          Memo for this entry
private  java.lang.String transactionTag
           
 
Constructor Summary
  TransactionEntry()
          Public constructor
protected TransactionEntry(Account creditAccount, Account debitAccount, java.math.BigDecimal amount)
          Simple constructor for a double entry transaction
protected TransactionEntry(Account creditAccount, Account debitAccount, java.math.BigDecimal creditAmount, java.math.BigDecimal debitAmount)
          Simple constructor for a double entry transaction with exchange rate
  TransactionEntry(Account account, java.math.BigDecimal amount)
          Simple constructor for a single entry transaction
 
Method Summary
 java.lang.Object clone()
           
 int compareTo(TransactionEntry entry)
           
 boolean equals(java.lang.Object entry)
           
(package private)  boolean equals(TransactionEntry entry)
          Reconciled state is ignored
 java.math.BigDecimal getAmount(Account account)
           
 Account getCreditAccount()
           
 java.math.BigDecimal getCreditAmount()
           
(package private)  ReconciledState getCreditReconciled()
           
 Account getDebitAccount()
           
 java.math.BigDecimal getDebitAmount()
           
(package private)  ReconciledState getDebitReconciled()
           
 java.lang.String getMemo()
           
 ReconciledState getReconciled(Account account)
           
 TransactionTag getTransactionTag()
           
 int hashCode()
           
 boolean isSingleEntry()
          Check to determine is this is a single entry transaction
 void setAmount(java.math.BigDecimal amount)
          Shortcut method to set credit and debit amounts
 void setCreditAccount(Account creditAccount)
           
 void setCreditAmount(java.math.BigDecimal amount)
           
(package private)  void setCreditReconciled(ReconciledState creditReconciled)
           
 void setDebitAccount(Account debitAccount)
           
 void setDebitAmount(java.math.BigDecimal debitAmount)
           
(package private)  void setDebitReconciled(ReconciledState debitReconciled)
           
 void setMemo(java.lang.String memo)
          Sets the memo for the entry
 void setReconciled(Account account, ReconciledState reconciled)
           
 void setTransactionTag(TransactionTag transactionTag)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

transactionTag

private java.lang.String transactionTag

cachedTransactionTag

private transient TransactionTag cachedTransactionTag

debitAccount

private Account debitAccount
Account with balance being decreased


creditAccount

private Account creditAccount
Account with balance being increased


creditAmount

private java.math.BigDecimal creditAmount

debitAmount

private java.math.BigDecimal debitAmount

creditReconciled

private ReconciledState creditReconciled
Reconciled state of the transaction


debitReconciled

private ReconciledState debitReconciled
Reconciled state of the debit side of the transaction


memo

private java.lang.String memo
Memo for this entry

Constructor Detail

TransactionEntry

public TransactionEntry()
Public constructor


TransactionEntry

public TransactionEntry(Account account,
                        java.math.BigDecimal amount)
Simple constructor for a single entry transaction

Parameters:
account - account for the transaction
amount - amount for the transaction

TransactionEntry

protected TransactionEntry(Account creditAccount,
                           Account debitAccount,
                           java.math.BigDecimal amount)
Simple constructor for a double entry transaction

Parameters:
creditAccount - credit account for the transaction
debitAccount - debit account for the transaction
amount - amount for the transaction

TransactionEntry

protected TransactionEntry(Account creditAccount,
                           Account debitAccount,
                           java.math.BigDecimal creditAmount,
                           java.math.BigDecimal debitAmount)
Simple constructor for a double entry transaction with exchange rate

Parameters:
creditAccount - credit account for the transaction
debitAccount - debit account for the transaction
creditAmount - amount for the transaction
debitAmount - amount for the transaction
Method Detail

getCreditAmount

public java.math.BigDecimal getCreditAmount()

getAmount

public java.math.BigDecimal getAmount(Account account)

setAmount

public void setAmount(java.math.BigDecimal amount)
Shortcut method to set credit and debit amounts

Parameters:
amount - credit amount of the transaction

getCreditAccount

public Account getCreditAccount()

getCreditReconciled

ReconciledState getCreditReconciled()

getDebitAccount

public Account getDebitAccount()

getDebitReconciled

ReconciledState getDebitReconciled()

getMemo

public java.lang.String getMemo()

getReconciled

public ReconciledState getReconciled(Account account)

setCreditAmount

public void setCreditAmount(java.math.BigDecimal amount)

setCreditAccount

public void setCreditAccount(Account creditAccount)

setCreditReconciled

void setCreditReconciled(ReconciledState creditReconciled)

setDebitAccount

public void setDebitAccount(Account debitAccount)

setDebitReconciled

void setDebitReconciled(ReconciledState debitReconciled)

setMemo

public void setMemo(java.lang.String memo)
Sets the memo for the entry

Parameters:
memo - new memo

setReconciled

public void setReconciled(Account account,
                          ReconciledState reconciled)

getDebitAmount

public java.math.BigDecimal getDebitAmount()

setDebitAmount

public void setDebitAmount(java.math.BigDecimal debitAmount)

compareTo

public int compareTo(TransactionEntry entry)
Specified by:
compareTo in interface java.lang.Comparable<TransactionEntry>

equals

public boolean equals(java.lang.Object entry)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

boolean equals(TransactionEntry entry)
Reconciled state is ignored

Parameters:
entry - transaction entry to compare
Returns:
true if equal

isSingleEntry

public boolean isSingleEntry()
Check to determine is this is a single entry transaction

Returns:
true if this is a single entry TransactionEntry

setTransactionTag

public void setTransactionTag(TransactionTag transactionTag)

getTransactionTag

public TransactionTag getTransactionTag()

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object