MIFOSX-867 - Fixed disbursement or submit date after repayment startdate by adding validations

This commit is contained in:
Sander van der Heyden
2014-02-11 11:00:30 +01:00
parent ac932974f3
commit a889dbdd2f
2 changed files with 22 additions and 1 deletions
@@ -1649,6 +1649,14 @@ public class Loan extends AbstractPersistable<Long> {
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.before.approval.date", errorMessage, disbursedOn, throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.before.approval.date", errorMessage, disbursedOn,
getApprovedOnDate()); getApprovedOnDate());
} }
if(getExpectedFirstRepaymentOnDate() != null && disbursedOn.isAfter(getExpectedFirstRepaymentOnDate()))
{
final String errorMessage = "submittedOnDate cannot be after the loans expectedFirstRepaymentOnDate: " + getExpectedFirstRepaymentOnDate().toString();
throw new InvalidLoanStateTransitionException("disbursal", "cannot.be.after.expected.first.repayment.date", errorMessage, disbursedOn,
getExpectedFirstRepaymentOnDate());
}
validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_DISBURSED, disbursedOn); validateActivityNotBeforeClientOrGroupTransferDate(LoanEvent.LOAN_DISBURSED, disbursedOn);
@@ -2923,6 +2931,8 @@ public class Loan extends AbstractPersistable<Long> {
} }
} }
} }
public Group group() { public Group group() {
return this.group; return this.group;
@@ -300,7 +300,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
if (changes.containsKey("expectedDisbursementDate")) { if (changes.containsKey("expectedDisbursementDate")) {
this.loanAssembler.validateExpectedDisbursementForHolidayAndNonWorkingDay(existingLoanApplication); this.loanAssembler.validateExpectedDisbursementForHolidayAndNonWorkingDay(existingLoanApplication);
} }
final String clientIdParamName = "clientId"; final String clientIdParamName = "clientId";
if (changes.containsKey(clientIdParamName)) { if (changes.containsKey(clientIdParamName)) {
final Long clientId = command.longValueOfParameterNamed(clientIdParamName); final Long clientId = command.longValueOfParameterNamed(clientIdParamName);
@@ -712,6 +712,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
private void validateSubmittedOnDate(final Loan loan) { private void validateSubmittedOnDate(final Loan loan) {
final LocalDate startDate = loan.loanProduct().getStartDate(); final LocalDate startDate = loan.loanProduct().getStartDate();
final LocalDate closeDate = loan.loanProduct().getCloseDate(); final LocalDate closeDate = loan.loanProduct().getCloseDate();
final LocalDate expectedFirstRepaymentOnDate = loan.getExpectedFirstRepaymentOnDate();
final LocalDate submittedOnDate = loan.getSubmittedOnDate(); final LocalDate submittedOnDate = loan.getSubmittedOnDate();
String defaultUserMessage = ""; String defaultUserMessage = "";
@@ -726,7 +727,17 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
throw new LoanApplicationDateException("submitted.on.date.cannot.be.after.the.loan.product.close.date", defaultUserMessage, throw new LoanApplicationDateException("submitted.on.date.cannot.be.after.the.loan.product.close.date", defaultUserMessage,
submittedOnDate.toString(), closeDate.toString()); submittedOnDate.toString(), closeDate.toString());
} }
if(expectedFirstRepaymentOnDate != null && submittedOnDate.isAfter(expectedFirstRepaymentOnDate))
{
defaultUserMessage = "submittedOnDate cannot be after the loans expectedFirstRepaymentOnDate.";
throw new LoanApplicationDateException("submitted.on.date.cannot.be.after.the.loan.expected.first.repayment.date", defaultUserMessage,
submittedOnDate.toString(), expectedFirstRepaymentOnDate.toString());
}
} }
private void checkClientOrGroupActive(final Loan loan) { private void checkClientOrGroupActive(final Loan loan) {
final Client client = loan.client(); final Client client = loan.client();