|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjgnash.engine.AmortizeObject
public class AmortizeObject
This class is used to calculate loan payments.
Because BigDecimal is lacking methods of exponentials, calculations are performed using StrictMath to maintain portability. Results are returned as doubles. Results will need to be scaled and rounded.
| Field Summary | |
|---|---|
private Account |
bankAccount
|
private java.util.Date |
date
origination date |
private java.math.BigDecimal |
daysPerYear
the number of days per year for daily periodic rate |
private java.math.BigDecimal |
fees
PMI, escrow, etc |
private Account |
feesAccount
|
private Account |
interestAccount
|
private java.math.BigDecimal |
interestRate
annual interest rate, APR (ex 6.75) |
private int |
length
length of loan in months |
private java.lang.String |
memo
the memo to use |
private int |
numCompPeriods
the number of compounding periods per year |
private int |
numPayments
the number of payments per year |
private java.math.BigDecimal |
originalBalance
original balance of the loan |
private java.lang.String |
payee
the payee to use |
private boolean |
useDailyRate
calculate interest based on daily periodic rate |
| Constructor Summary | |
|---|---|
AmortizeObject()
Empty constructor to keep reflection happy |
|
| Method Summary | |
|---|---|
Account |
getBankAccount()
Returns the id of the principal account |
(package private) double |
getDailyPeriodicInterestRate()
Calculates the daily interest rate. This works for US, can't find any information on Canada |
java.util.Date |
getDate()
|
java.math.BigDecimal |
getDaysPerYear()
Returns the number of days per year used to calculate a daily periodic interest rate. |
(package private) double |
getEffectiveInterestRate()
Calculates the effective interest rate. Ie = (1 + i/m)^(m/n) - 1 n = payments per period m = number of times compounded per period |
java.math.BigDecimal |
getFees()
|
Account |
getFeesAccount()
Returns the id of the fees account |
Account |
getInterestAccount()
Returns the id of the interest account |
int |
getInterestPeriods()
|
double |
getIPayment(java.math.BigDecimal balance)
Calculates the interest portion of the next loan payment given the remaining loan balance |
double |
getIPayment(java.math.BigDecimal balance,
java.util.Date start,
java.util.Date end)
Calculates the interest portion of the next loan payment given the remaining loan balance and the dates between payments |
int |
getLength()
Gets the length of the loan in months |
java.lang.String |
getMemo()
|
java.lang.String |
getPayee()
|
double |
getPayment()
Calculates the principal and interest plus finance charges |
int |
getPaymentPeriods()
|
(package private) double |
getPIPayment()
Calculates the principal and interest payment of an equal payment series M = P * ( Ie / (1 - (1 + Ie) ^ -N)) N = total number of periods the loan is amortized over |
double |
getPPayment(java.math.BigDecimal balance)
Calculates the principal portion of the next loan payment given the remaining loan balance |
java.math.BigDecimal |
getPrincipal()
|
java.math.BigDecimal |
getRate()
|
(package private) double |
getSumWithInterest()
Calculates the sum of compounded interest and principal S = P(1+Ie)^n*term |
double |
getTotalInterestPaid()
|
boolean |
getUseDailyRate()
Returns how interest will be calculated. |
void |
setBankAccount(Account id)
Set the id of the principal account |
void |
setDate(java.util.Date date)
|
void |
setDaysPerYear(java.math.BigDecimal days)
Sets the number of days per year used to calculate the daily periodic interest rate. |
void |
setFees(java.math.BigDecimal fees)
|
void |
setFeesAccount(Account id)
Set the id of the fees account |
void |
setInterestAccount(Account id)
Set the id of the interest account |
void |
setInterestPeriods(int periods)
|
void |
setLength(int months)
Sets the length of the loan (in months) |
void |
setMemo(java.lang.String memo)
|
void |
setPayee(java.lang.String payee)
|
void |
setPaymentPeriods(int periods)
|
void |
setPrincipal(java.math.BigDecimal principal)
|
void |
setRate(java.math.BigDecimal rate)
|
void |
setUseDailyRate(boolean daily)
Determines if interest will be calculate based on a daily periodic rate, or if it is assumed that the interest is paid exactly on the due date. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private Account interestAccount
private Account bankAccount
private Account feesAccount
private int numPayments
private int length
private int numCompPeriods
private java.math.BigDecimal interestRate
private java.math.BigDecimal originalBalance
private java.math.BigDecimal fees
private java.lang.String payee
private java.lang.String memo
private java.util.Date date
private boolean useDailyRate
private java.math.BigDecimal daysPerYear
| Constructor Detail |
|---|
public AmortizeObject()
| Method Detail |
|---|
public void setDate(java.util.Date date)
public java.util.Date getDate()
public void setPaymentPeriods(int periods)
public int getPaymentPeriods()
public void setLength(int months)
months - length of loanpublic int getLength()
public void setUseDailyRate(boolean daily)
daily - true if interest should be calculated using a daily ratepublic boolean getUseDailyRate()
public void setDaysPerYear(java.math.BigDecimal days)
days - The number of days in a yearpublic java.math.BigDecimal getDaysPerYear()
public void setRate(java.math.BigDecimal rate)
public java.math.BigDecimal getRate()
public void setPrincipal(java.math.BigDecimal principal)
public java.math.BigDecimal getPrincipal()
public void setInterestPeriods(int periods)
public int getInterestPeriods()
public void setFees(java.math.BigDecimal fees)
public java.math.BigDecimal getFees()
public void setInterestAccount(Account id)
id - the id of the interest accountpublic Account getInterestAccount()
public void setBankAccount(Account id)
id - the id of the principal accountpublic Account getBankAccount()
public void setFeesAccount(Account id)
id - the id of the fees accountpublic Account getFeesAccount()
public void setPayee(java.lang.String payee)
public java.lang.String getPayee()
public void setMemo(java.lang.String memo)
public java.lang.String getMemo()
double getEffectiveInterestRate()
double getDailyPeriodicInterestRate()
double getSumWithInterest()
public double getTotalInterestPaid()
double getPIPayment()
public double getPayment()
public double getIPayment(java.math.BigDecimal balance)
balance - remaining balance
public double getIPayment(java.math.BigDecimal balance,
java.util.Date start,
java.util.Date end)
balance - balancestart - start dateend - end date
public double getPPayment(java.math.BigDecimal balance)
balance - balance
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||