jgnash.engine
Class TransactionFactory

java.lang.Object
  extended by jgnash.engine.TransactionFactory

public class TransactionFactory
extends java.lang.Object

Transaction Factory

Version:
$Id$
Author:
Craig Cavanaugh

Constructor Summary
private TransactionFactory()
           
 
Method Summary
private static java.lang.String buildPayee(java.lang.String wordProperty, SecurityNode node, java.math.BigDecimal price, java.math.BigDecimal quantity)
           
static InvestmentTransaction generateAddXTransaction(Account investmentAccount, SecurityNode node, java.math.BigDecimal price, java.math.BigDecimal quantity, java.util.Date date, java.lang.String memo, boolean reconciled)
          Create an AddX investment transaction
static InvestmentTransaction generateBuyXTransaction(Account account, Account investmentAccount, SecurityNode node, java.math.BigDecimal price, java.math.BigDecimal quantity, java.math.BigDecimal exchangeRate, java.util.Date date, java.lang.String memo, boolean reconciled, java.util.Collection<TransactionEntry> fees)
          Create a buy security transaction
static InvestmentTransaction generateDividendXTransaction(Account incomeAccount, Account investmentAccount, Account cashAccount, SecurityNode node, java.math.BigDecimal dividend, java.math.BigDecimal incomeExchangedAmount, java.math.BigDecimal cashExchangedAmount, java.util.Date date, java.lang.String memo, boolean reconciled)
          Create a Dividend transaction
static Transaction generateDoubleEntryTransaction(Account creditAccount, Account debitAccount, java.math.BigDecimal creditAmount, java.math.BigDecimal debitAmount, java.util.Date date, java.lang.String memo, java.lang.String payee, java.lang.String number)
          Generate a double entry transaction with exchange rate
static Transaction generateDoubleEntryTransaction(Account creditAccount, Account debitAccount, java.math.BigDecimal amount, java.util.Date date, java.lang.String memo, java.lang.String payee, java.lang.String number)
          Generate a double entry transaction
static InvestmentTransaction generateMergeXTransaction(Account investmentAccount, SecurityNode node, java.math.BigDecimal price, java.math.BigDecimal quantity, java.util.Date date, java.lang.String memo, boolean reconciled)
          Create a Split investment transaction
static InvestmentTransaction generateReinvDividendXTransaction(Account investmentAccount, SecurityNode node, java.math.BigDecimal price, java.math.BigDecimal quantity, java.util.Date date, java.lang.String memo, boolean reconciled, java.util.Collection<TransactionEntry> fees, java.util.Collection<TransactionEntry> gains)
          Create a Reinvested Dividend transaction
static InvestmentTransaction generateRemoveXTransaction(Account investmentAccount, SecurityNode node, java.math.BigDecimal price, java.math.BigDecimal quantity, java.util.Date date, java.lang.String memo, boolean reconciled)
          Create a RemoveX investment transaction
static InvestmentTransaction generateRocXTransaction(Account incomeAccount, Account investmentAccount, Account cashAccount, SecurityNode node, java.math.BigDecimal dividend, java.math.BigDecimal incomeExchangedAmount, java.math.BigDecimal cashExchangedAmount, java.util.Date date, java.lang.String memo, boolean reconciled)
          Create a Return of Capital transaction
static InvestmentTransaction generateSellXTransaction(Account account, Account investmentAccount, SecurityNode node, java.math.BigDecimal price, java.math.BigDecimal quantity, java.math.BigDecimal exchangeRate, java.util.Date date, java.lang.String memo, boolean reconciled, java.util.Collection<TransactionEntry> fees, java.util.Collection<TransactionEntry> gains)
          Create a sell security transaction
static Transaction generateSingleEntryTransaction(Account account, java.math.BigDecimal amount, java.util.Date date, boolean reconciled, java.lang.String memo, java.lang.String payee, java.lang.String number)
          Create a single entry transaction
static InvestmentTransaction generateSplitXTransaction(Account investmentAccount, SecurityNode node, java.math.BigDecimal price, java.math.BigDecimal quantity, java.util.Date date, java.lang.String memo, boolean reconciled)
          Create a Split investment transaction
static InvestmentTransaction import1xBuyXTransaction(Account account, Account investmentAccount, SecurityNode node, java.math.BigDecimal price, java.math.BigDecimal quantity, java.math.BigDecimal exchangeRate, java.math.BigDecimal fee, java.util.Date date, java.lang.String memo)
          Import a jGnash 1.x buy security transaction.
static InvestmentTransaction import1xSellXTransaction(Account account, Account investmentAccount, SecurityNode node, java.math.BigDecimal price, java.math.BigDecimal quantity, java.math.BigDecimal exchange, java.math.BigDecimal fee, java.util.Date date, java.lang.String memo)
          Import a jGnash 1.x a sell security transaction Should not be used for new transactions.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransactionFactory

private TransactionFactory()
Method Detail

generateAddXTransaction

public static InvestmentTransaction generateAddXTransaction(Account investmentAccount,
                                                            SecurityNode node,
                                                            java.math.BigDecimal price,
                                                            java.math.BigDecimal quantity,
                                                            java.util.Date date,
                                                            java.lang.String memo,
                                                            boolean reconciled)
Create an AddX investment transaction

Parameters:
investmentAccount - Investment account
node - Security to add
price - Price of each share
quantity - Number of shares
date - Transaction date
memo - Transaction memo
reconciled - Reconciled status
Returns:
new Investment Transaction

import1xBuyXTransaction

public static InvestmentTransaction import1xBuyXTransaction(Account account,
                                                            Account investmentAccount,
                                                            SecurityNode node,
                                                            java.math.BigDecimal price,
                                                            java.math.BigDecimal quantity,
                                                            java.math.BigDecimal exchangeRate,
                                                            java.math.BigDecimal fee,
                                                            java.util.Date date,
                                                            java.lang.String memo)
Import a jGnash 1.x buy security transaction. Should not be used for new transactions.

Parameters:
account - Account to buy against (can be the same investment account)
investmentAccount - Investment account
node - Security to buy
price - Price of each share
quantity - Number of shares
exchangeRate - Exchange rate (Can be BigDecimal.ONE, cannot be null)
fee - Purchase fee
date - Transaction date
memo - Transaction memo
Returns:
new Transaction

generateBuyXTransaction

public static InvestmentTransaction generateBuyXTransaction(Account account,
                                                            Account investmentAccount,
                                                            SecurityNode node,
                                                            java.math.BigDecimal price,
                                                            java.math.BigDecimal quantity,
                                                            java.math.BigDecimal exchangeRate,
                                                            java.util.Date date,
                                                            java.lang.String memo,
                                                            boolean reconciled,
                                                            java.util.Collection<TransactionEntry> fees)
Create a buy security transaction

Parameters:
account - Account to buy against (can be the same investment account)
investmentAccount - Investment account
node - Security to buy
price - Price of each share
quantity - Number of shares
exchangeRate - Exchange rate (Can be BigDecimal.ONE, cannot be null)
date - Transaction date
memo - Transaction memo
reconciled - Reconciled status
fees - List of transaction fees
Returns:
new Transaction

generateDividendXTransaction

public static InvestmentTransaction generateDividendXTransaction(Account incomeAccount,
                                                                 Account investmentAccount,
                                                                 Account cashAccount,
                                                                 SecurityNode node,
                                                                 java.math.BigDecimal dividend,
                                                                 java.math.BigDecimal incomeExchangedAmount,
                                                                 java.math.BigDecimal cashExchangedAmount,
                                                                 java.util.Date date,
                                                                 java.lang.String memo,
                                                                 boolean reconciled)
Create a Dividend transaction

Parameters:
incomeAccount - Income source account for the cash dividend
investmentAccount - Investment account
cashAccount - The account receiving the cash dividend. May be the same investment account.
node - Security for dividend
dividend - Cash dividend
incomeExchangedAmount - Income account exchanged amount (Can be the same as dividend, cannot be null)
cashExchangedAmount - The exchanged amount for the cash account (Can be the same as dividend, cannot be null)
date - Transaction date
memo - Transaction memo
reconciled - Reconciled status
Returns:
new InvestmentTransaction

generateRocXTransaction

public static InvestmentTransaction generateRocXTransaction(Account incomeAccount,
                                                            Account investmentAccount,
                                                            Account cashAccount,
                                                            SecurityNode node,
                                                            java.math.BigDecimal dividend,
                                                            java.math.BigDecimal incomeExchangedAmount,
                                                            java.math.BigDecimal cashExchangedAmount,
                                                            java.util.Date date,
                                                            java.lang.String memo,
                                                            boolean reconciled)
Create a Return of Capital transaction

Parameters:
incomeAccount - Income source account for the cash dividend
investmentAccount - Investment account
cashAccount - The account receiving the cash dividend. May be the same investment account.
node - Security for dividend
dividend - Cash dividend
incomeExchangedAmount - Income account exchanged amount (Can be the same as dividend, cannot be null)
cashExchangedAmount - The exchanged amount for the cash account (Can be the same as dividend, cannot be null)
date - Transaction date
memo - Transaction memo
reconciled - Reconciled status
Returns:
new InvestmentTransaction

generateDoubleEntryTransaction

public static Transaction generateDoubleEntryTransaction(Account creditAccount,
                                                         Account debitAccount,
                                                         java.math.BigDecimal creditAmount,
                                                         java.math.BigDecimal debitAmount,
                                                         java.util.Date date,
                                                         java.lang.String memo,
                                                         java.lang.String payee,
                                                         java.lang.String number)
Generate a double entry transaction with exchange rate

Parameters:
creditAccount - Credit account
debitAccount - Debit account
creditAmount - Transaction credit amount
debitAmount - Transaction credit amount
date - Transaction date
memo - Transaction memo
payee - Transaction payee
number - Transaction number
Returns:
new Transaction

generateDoubleEntryTransaction

public static Transaction generateDoubleEntryTransaction(Account creditAccount,
                                                         Account debitAccount,
                                                         java.math.BigDecimal amount,
                                                         java.util.Date date,
                                                         java.lang.String memo,
                                                         java.lang.String payee,
                                                         java.lang.String number)
Generate a double entry transaction

Parameters:
creditAccount - Credit account
debitAccount - Debit account
amount - Transaction amount
date - Transaction date
memo - Transaction memo
payee - Transaction payee
number - Transaction number
Returns:
new Transaction

generateMergeXTransaction

public static InvestmentTransaction generateMergeXTransaction(Account investmentAccount,
                                                              SecurityNode node,
                                                              java.math.BigDecimal price,
                                                              java.math.BigDecimal quantity,
                                                              java.util.Date date,
                                                              java.lang.String memo,
                                                              boolean reconciled)
Create a Split investment transaction

Parameters:
investmentAccount - Investment account
node - Security that merged
price - Price of each share
quantity - Number of shares
date - Transaction date
memo - Transaction memo
reconciled - Reconciled status
Returns:
new Investment Transaction

generateReinvDividendXTransaction

public static InvestmentTransaction generateReinvDividendXTransaction(Account investmentAccount,
                                                                      SecurityNode node,
                                                                      java.math.BigDecimal price,
                                                                      java.math.BigDecimal quantity,
                                                                      java.util.Date date,
                                                                      java.lang.String memo,
                                                                      boolean reconciled,
                                                                      java.util.Collection<TransactionEntry> fees,
                                                                      java.util.Collection<TransactionEntry> gains)
Create a Reinvested Dividend transaction

Parameters:
investmentAccount - Investment account
node - Security for dividend
price - Share price
quantity - Quantity of shares reinvested
date - Date of transaction
memo - Transaction memo
reconciled - Reconciled status
fees - Fee entry(s)
gains - Gain/Loss entry(s)
Returns:
new InvestmentTransaction

generateRemoveXTransaction

public static InvestmentTransaction generateRemoveXTransaction(Account investmentAccount,
                                                               SecurityNode node,
                                                               java.math.BigDecimal price,
                                                               java.math.BigDecimal quantity,
                                                               java.util.Date date,
                                                               java.lang.String memo,
                                                               boolean reconciled)
Create a RemoveX investment transaction

Parameters:
investmentAccount - Investment account
node - Security to remove
price - Price of each share
quantity - Number of shares
date - Transaction date
memo - Transaction memo
reconciled - Reconciled status
Returns:
new Investment Transaction

import1xSellXTransaction

public static InvestmentTransaction import1xSellXTransaction(Account account,
                                                             Account investmentAccount,
                                                             SecurityNode node,
                                                             java.math.BigDecimal price,
                                                             java.math.BigDecimal quantity,
                                                             java.math.BigDecimal exchange,
                                                             java.math.BigDecimal fee,
                                                             java.util.Date date,
                                                             java.lang.String memo)
Import a jGnash 1.x a sell security transaction Should not be used for new transactions.

Parameters:
account - Account to buy against (can be the same investment account)
investmentAccount - Investment account
node - Security to sell
price - Price of each share
quantity - Number of shares
exchange - Exchange rate (Can be BigDecimal.ONE, cannot be null)
fee - Purchase fee
date - Transaction date
memo - Transaction memo
Returns:
new Transaction

generateSellXTransaction

public static InvestmentTransaction generateSellXTransaction(Account account,
                                                             Account investmentAccount,
                                                             SecurityNode node,
                                                             java.math.BigDecimal price,
                                                             java.math.BigDecimal quantity,
                                                             java.math.BigDecimal exchangeRate,
                                                             java.util.Date date,
                                                             java.lang.String memo,
                                                             boolean reconciled,
                                                             java.util.Collection<TransactionEntry> fees,
                                                             java.util.Collection<TransactionEntry> gains)
Create a sell security transaction

Parameters:
account - Account receive sale profits or loss. May be the same as the investment account (Cash balance)
investmentAccount - Investment account
node - Security to sell
price - Price of each share
quantity - Number of shares
exchangeRate - Exchanged amount (cannot be null)
date - Transaction date
memo - Transaction memo
reconciled - Reconciled status
fees - Purchase fee
gains - Gains/Loss entries
Returns:
new Transaction

generateSingleEntryTransaction

public static Transaction generateSingleEntryTransaction(Account account,
                                                         java.math.BigDecimal amount,
                                                         java.util.Date date,
                                                         boolean reconciled,
                                                         java.lang.String memo,
                                                         java.lang.String payee,
                                                         java.lang.String number)
Create a single entry transaction

Parameters:
account - Destination account
amount - Transaction amount
date - Transaction date
reconciled - Reconciled state
memo - Transaction memo
payee - Transaction payee
number - Transaction number
Returns:
new Transaction

generateSplitXTransaction

public static InvestmentTransaction generateSplitXTransaction(Account investmentAccount,
                                                              SecurityNode node,
                                                              java.math.BigDecimal price,
                                                              java.math.BigDecimal quantity,
                                                              java.util.Date date,
                                                              java.lang.String memo,
                                                              boolean reconciled)
Create a Split investment transaction

Parameters:
investmentAccount - Investment account
node - Security that split
price - Price of each share
quantity - Number of shares
date - Transaction date
memo - Transaction memo
reconciled - Reconciled status
Returns:
new Investment Transaction

buildPayee

private static java.lang.String buildPayee(java.lang.String wordProperty,
                                           SecurityNode node,
                                           java.math.BigDecimal price,
                                           java.math.BigDecimal quantity)