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
@@ -1650,6 +1650,14 @@ public class Loan extends AbstractPersistable<Long> {
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);
if (disbursedOn.isAfter(new LocalDate())) { if (disbursedOn.isAfter(new LocalDate())) {
@@ -2924,6 +2932,8 @@ public class Loan extends AbstractPersistable<Long> {
} }
} }
public Group group() { public Group group() {
return this.group; return this.group;
} }
@@ -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,8 +727,18 @@ 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();
if (client != null) { if (client != null) {