FINERACT-2081: loan validation code improvements
This commit is contained in:
committed by
Adam Saghy
parent
81bf50d29e
commit
26388ea518
+1
-1
@@ -616,7 +616,7 @@ public class LoanScheduleAssembler {
|
||||
|
||||
private void validateRepaymentsStartDateWithMeetingDates(final LocalDate repaymentsStartingFromDate, final Calendar calendar,
|
||||
boolean isSkipRepaymentOnFirstDayOfMonth, final Integer numberOfDays) {
|
||||
if (repaymentsStartingFromDate != null && !CalendarUtils.isValidRedurringDate(calendar.getRecurrence(),
|
||||
if (repaymentsStartingFromDate != null && !CalendarUtils.isValidRecurringDate(calendar.getRecurrence(),
|
||||
calendar.getStartDateLocalDate(), repaymentsStartingFromDate, isSkipRepaymentOnFirstDayOfMonth, numberOfDays)) {
|
||||
final String errorMessage = "First repayment date '" + repaymentsStartingFromDate + "' do not fall on a meeting date";
|
||||
throw new LoanApplicationDateException("first.repayment.date.do.not.match.meeting.date", errorMessage,
|
||||
|
||||
+7
-8
@@ -1784,7 +1784,6 @@ public final class LoanApplicationValidator {
|
||||
}
|
||||
|
||||
public void checkForProductMixRestrictions(final JsonElement element) {
|
||||
|
||||
final List<Long> activeLoansLoanProductIds;
|
||||
final Long productId = this.fromApiJsonHelper.extractLongNamed(LoanApiConstants.productIdParameterName, element);
|
||||
final Long groupId = this.fromApiJsonHelper.extractLongNamed(LoanApiConstants.groupIdParameterName, element);
|
||||
@@ -1869,17 +1868,17 @@ public final class LoanApplicationValidator {
|
||||
Group group = groupRepository.findOneWithNotFoundDetection(groupId);
|
||||
|
||||
if (group != null && group.isActivatedAfter(submittedOnDate)) {
|
||||
final String errorMessage = "The date on which a loan is submitted cannot be earlier than groups's activation date.";
|
||||
final String errorMessage = "The date on which a loan is submitted cannot be earlier than group's activation date.";
|
||||
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.before.group.activation.date", errorMessage,
|
||||
submittedOnDate, group.getActivationDate());
|
||||
}
|
||||
}
|
||||
|
||||
if (DateUtils.isAfter(submittedOnDate, expectedDisbursementDate)) {
|
||||
final String errorMessage = "The date on which a loan is submitted cannot be after its expected disbursement date: "
|
||||
+ expectedDisbursementDate;
|
||||
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.after.expected.disbursement.date", errorMessage,
|
||||
submittedOnDate, expectedDisbursementDate);
|
||||
}
|
||||
if (DateUtils.isAfter(submittedOnDate, expectedDisbursementDate)) {
|
||||
final String errorMessage = "The date on which a loan is submitted cannot be after its expected disbursement date: "
|
||||
+ expectedDisbursementDate;
|
||||
throw new InvalidLoanStateTransitionException("submittal", "cannot.be.after.expected.disbursement.date", errorMessage,
|
||||
submittedOnDate, expectedDisbursementDate);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -442,7 +442,7 @@ public final class LoanTransactionValidator {
|
||||
final Calendar calendar = calendarInstance.getCalendar();
|
||||
if (calendar != null && repaymentDate != null) {
|
||||
// Disbursement date should fall on a meeting date
|
||||
if (!CalendarUtils.isValidRedurringDate(calendar.getRecurrence(), calendar.getStartDateLocalDate(), repaymentDate)) {
|
||||
if (!CalendarUtils.isValidRecurringDate(calendar.getRecurrence(), calendar.getStartDateLocalDate(), repaymentDate)) {
|
||||
final String errorMessage = "Transaction date '" + repaymentDate.toString() + "' does not fall on a meeting date.";
|
||||
throw new NotValidRecurringDateException("loan.transaction.date", errorMessage, repaymentDate.toString(),
|
||||
calendar.getTitle());
|
||||
|
||||
+2
-10
@@ -1942,11 +1942,8 @@ public final class LoanProductDataValidator {
|
||||
|
||||
public void validateMinMaxConstraints(final JsonElement element, final DataValidatorBuilder baseDataValidator,
|
||||
final LoanProduct loanProduct) {
|
||||
|
||||
validatePrincipalMinMaxConstraint(element, loanProduct, baseDataValidator);
|
||||
|
||||
validateNumberOfRepaymentsMinMaxConstraint(element, loanProduct, baseDataValidator);
|
||||
|
||||
validateNominalInterestRatePerPeriodMinMaxConstraint(element, loanProduct, baseDataValidator);
|
||||
}
|
||||
|
||||
@@ -2029,7 +2026,6 @@ public final class LoanProductDataValidator {
|
||||
|
||||
private void validatePrincipalMinMaxConstraint(final JsonElement element, final LoanProduct loanProduct,
|
||||
final DataValidatorBuilder baseDataValidator) {
|
||||
|
||||
boolean principalUpdated = false;
|
||||
boolean minPrincipalUpdated = false;
|
||||
boolean maxPrincipalUpdated = false;
|
||||
@@ -2555,11 +2551,7 @@ public final class LoanProductDataValidator {
|
||||
}
|
||||
}
|
||||
|
||||
private Integer defaultToZeroIfNull(final Integer value) {
|
||||
Integer result = value;
|
||||
if (value == null) {
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
private Integer defaultToZeroIfNull(Integer value) {
|
||||
return value != null ? value : 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user