Skip to content

Commit

Permalink
Added Javadoc comments to AmortizationService class.
Browse files Browse the repository at this point in the history
  • Loading branch information
austenjt committed Dec 23, 2015
1 parent 99565c8 commit b784024
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public String calculatePayments(@ModelAttribute MonthlyAmortizationSchedule mont
{
System.out.println( "There are errors! " + bindingResult.getAllErrors().toString() );
}
amortizationService.initMonthlyAmortizationSchedule(monthlyAmortizationSchedule);
amortizationService.initializeUnknownFields(monthlyAmortizationSchedule);
model.addAttribute(monthlyAmortizationSchedule);

return "schedule";
Expand Down
23 changes: 14 additions & 9 deletions src/main/java/app/finance/core/service/AmortizationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public class AmortizationService
private PaymentService paymentService;

/**
* Modifies reference to monthlyAmortizationSchedule before passing that model to redirected template.
* @param monthlyAmortizationSchedule
* Modifies reference to monthlyAmortizationSchedule to resolve values of empty fields.
* @param monthlyAmortizationSchedule object containing all required loan parameters and calculations
*/
public void initMonthlyAmortizationSchedule(MonthlyAmortizationSchedule monthlyAmortizationSchedule)
public void initializeUnknownFields(MonthlyAmortizationSchedule monthlyAmortizationSchedule)
{
// extract required parameters
Date startDate = monthlyAmortizationSchedule.getStartDate();
Expand All @@ -43,12 +43,12 @@ public void initMonthlyAmortizationSchedule(MonthlyAmortizationSchedule monthlyA

/**
* Calculates the monthly payment and the list of payments given parameters.
* @param startDate
* @param initialBalance
* @param durationInMonths
* @param paymentType
* @param interestRate
* @param futureValue
* @param startDate loan start date
* @param initialBalance loan initial balance
* @param durationInMonths loan duration in months
* @param paymentType loan payment type
* @param interestRate loan interest rate
* @param futureValue loan expected future value
* @return List of payments and the monthly payment amount
*/
public List<Payment> calculatePaymentList(Date startDate, double initialBalance, int durationInMonths, int paymentType, double interestRate, double futureValue)
Expand Down Expand Up @@ -80,6 +80,11 @@ public List<Payment> calculatePaymentList(Date startDate, double initialBalance,
return paymentList;
}

/**
* Adds a month to a date, for purposes of putting a date on each Payment object.
* @param date any arbitrary date
* @return Date a date one month later
*/
private Date addOneMonth(Date date)
{
Calendar cal = Calendar.getInstance();
Expand Down

0 comments on commit b784024

Please sign in to comment.