support change of dates when modify loan application.

This commit is contained in:
Keith Woodlock
2012-09-06 23:12:45 +01:00
parent a3eed0fdc2
commit 5bc6b5f664
2 changed files with 38 additions and 2 deletions
@@ -247,4 +247,16 @@ public class LoanApplicationCommand {
public boolean isSubmittedOnDateChanged() { public boolean isSubmittedOnDateChanged() {
return this.modifiedParameters.contains("submittedOnDate"); return this.modifiedParameters.contains("submittedOnDate");
} }
public boolean isExpectedDisbursementDateChanged() {
return this.modifiedParameters.contains("expectedDisbursementDate");
}
public boolean isRepaymentsStartingFromDateChanged() {
return this.modifiedParameters.contains("repaymentsStartingFromDate");
}
public boolean isInterestChargedFromDateChanged() {
return this.modifiedParameters.contains("interestChargedFromDate");
}
} }
@@ -226,6 +226,30 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
this.submittedOnDate = command.getSubmittedOnDate().toDate(); this.submittedOnDate = command.getSubmittedOnDate().toDate();
} }
if (command.isExpectedDisbursementDateChanged()) {
if (command.getExpectedDisbursementDate() != null) {
this.expectedDisbursedOnDate = command.getExpectedDisbursementDate().toDate();
} else {
this.expectedDisbursedOnDate = null;
}
}
if (command.isRepaymentsStartingFromDateChanged()) {
if (command.getRepaymentsStartingFromDate() != null) {
this.expectedFirstRepaymentOnDate = command.getRepaymentsStartingFromDate().toDate();
} else {
this.expectedFirstRepaymentOnDate = null;
}
}
if (command.isInterestChargedFromDateChanged()) {
if (command.getInterestChargedFromDate() != null) {
this.interestChargedFromDate = command.getInterestChargedFromDate().toDate();
} else {
this.interestChargedFromDate = null;
}
}
this.loanRepaymentScheduleDetail.update(command.toLoanProductCommand()); this.loanRepaymentScheduleDetail.update(command.toLoanProductCommand());
// FIXME - rewrite over loan schedule by default for now but worth putting in check to see if required // FIXME - rewrite over loan schedule by default for now but worth putting in check to see if required
@@ -474,7 +498,7 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
if (loanTransactionDate.isAfter(new LocalDate())) { if (loanTransactionDate.isAfter(new LocalDate())) {
final String errorMessage = "The transaction date cannot be in the future."; final String errorMessage = "The transaction date cannot be in the future.";
throw new InvalidLoanStateTransitionException("waive", throw new InvalidLoanStateTransitionException("waive",
"cannot.be.a.futre.date", errorMessage, loanTransactionDate); "cannot.be.a.future.date", errorMessage, loanTransactionDate);
} }
if (getTotalOutstanding().isGreaterThan(this.getInArrearsTolerance())) { if (getTotalOutstanding().isGreaterThan(this.getInArrearsTolerance())) {
@@ -534,7 +558,7 @@ public class Loan extends AbstractAuditableCustom<AppUser, Long> {
if (loanTransactionDate.isAfter(new LocalDate())) { if (loanTransactionDate.isAfter(new LocalDate())) {
final String errorMessage = "The transaction date cannot be in the future."; final String errorMessage = "The transaction date cannot be in the future.";
throw new InvalidLoanStateTransitionException("repayment", throw new InvalidLoanStateTransitionException("repayment",
"cannot.be.a.futre.date", errorMessage, loanTransactionDate); "cannot.be.a.future.date", errorMessage, loanTransactionDate);
} }
List<LoanTransaction> repaymentsOrWaivers = new ArrayList<LoanTransaction>(); List<LoanTransaction> repaymentsOrWaivers = new ArrayList<LoanTransaction>();