FINERACT-1971: Installment level delinquency for loan modification

This commit is contained in:
Ruchi Dhamankar
2024-05-15 15:04:38 +02:00
committed by Adam Saghy
parent 582742d2ef
commit 8b2c9da804
6 changed files with 170 additions and 1 deletions
@@ -1372,6 +1372,8 @@ final class LoansApiResourceSwagger {
public List<PutLoansLoanIdDisbursementData> disbursementData;
@Schema(example = "HORIZONTAL")
public String loanScheduleProcessingType;
@Schema(example = "false")
public Boolean enableInstallmentLevelDelinquency;
static final class PutLoansLoanIdChanges {
@@ -71,7 +71,7 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper {
LoanApiConstants.repaymentFrequencyDayOfWeekTypeParameterName, LoanApiConstants.isTopup, LoanApiConstants.loanIdToClose,
LoanApiConstants.datatables, LoanApiConstants.isEqualAmortizationParam, LoanProductConstants.RATES_PARAM_NAME,
LoanApiConstants.daysInYearTypeParameterName, LoanApiConstants.fixedPrincipalPercentagePerInstallmentParamName,
LoanProductConstants.FIXED_LENGTH));
LoanProductConstants.FIXED_LENGTH, LoanProductConstants.ENABLE_INSTALLMENT_LEVEL_DELINQUENCY));
private final FromJsonHelper fromApiJsonHelper;
@@ -1134,6 +1134,20 @@ public final class LoanApplicationCommandFromApiJsonHelper {
advancedPaymentAllocationsValidator.checkGroupingOfAllocationRules(allocationRules);
}
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.ENABLE_INSTALLMENT_LEVEL_DELINQUENCY, element)) {
final Boolean isEnableInstallmentLevelDelinquency = this.fromApiJsonHelper
.extractBooleanNamed(LoanProductConstants.ENABLE_INSTALLMENT_LEVEL_DELINQUENCY, element);
baseDataValidator.reset().parameter(LoanProductConstants.ENABLE_INSTALLMENT_LEVEL_DELINQUENCY)
.value(isEnableInstallmentLevelDelinquency).validateForBooleanValue();
if (loanProduct.getDelinquencyBucket() == null) {
if (isEnableInstallmentLevelDelinquency) {
baseDataValidator.reset().parameter(LoanProductConstants.ENABLE_INSTALLMENT_LEVEL_DELINQUENCY).failWithCode(
"can.be.enabled.for.loan.with.loan.product.having.valid.delinquency.bucket",
"Installment level delinquency cannot be enabled for a loan if Delinquency bucket is not configured for loan product");
}
}
}
if (!dataValidationErrors.isEmpty()) {
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.",
dataValidationErrors);
@@ -970,6 +970,14 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
existingLoanApplication.updateLoanCharges(possiblyModifedLoanCharges);
}
// update installment level delinquency
if (command.isChangeInBooleanParameterNamed(LoanProductConstants.ENABLE_INSTALLMENT_LEVEL_DELINQUENCY,
existingLoanApplication.isEnableInstallmentLevelDelinquency())) {
final Boolean enableInstallmentLevelDelinquency = command
.booleanObjectValueOfParameterNamed(LoanProductConstants.ENABLE_INSTALLMENT_LEVEL_DELINQUENCY);
existingLoanApplication.updateEnableInstallmentLevelDelinquency(enableInstallmentLevelDelinquency);
}
if (changes.containsKey("recalculateLoanSchedule")) {
changes.remove("recalculateLoanSchedule");