FINERACT-821 Made changes to enforce ConstantName Checkstyle (3)

This commit is contained in:
Manthan Surkar
2020-06-11 22:23:26 +02:00
committed by Michael Vorburger ⛑️
parent 52fa7a9832
commit dae424da1a
17 changed files with 384 additions and 384 deletions
@@ -33,8 +33,8 @@ public class CalendarHelper {
private static final String BASE_URL = "/fineract-provider/api/v1/"; private static final String BASE_URL = "/fineract-provider/api/v1/";
private static final String PARENT_ENTITY_NAME = "groups/"; private static final String PARENT_ENTITY_NAME = "groups/";
private static final String ENITY_NAME = "/calendars"; private static final String ENITY_NAME = "/calendars";
private static final String CENTER__ENTITY = "centers/"; private static final String CENTER_ENTITY = "centers/";
private static final String EDIT__CALENDAR = "editcalendarbasedonmeetingdates/"; private static final String EDIT_CALENDAR = "editcalendarbasedonmeetingdates/";
public static Integer createMeetingCalendarForGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec, public static Integer createMeetingCalendarForGroup(final RequestSpecification requestSpec, final ResponseSpecification responseSpec,
final Integer groupId, final String startDate, final String frequency, final String interval, final String repeatsOnDay) { final Integer groupId, final String startDate, final String frequency, final String interval, final String repeatsOnDay) {
@@ -95,7 +95,7 @@ public class CalendarHelper {
LOG.info("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------"); LOG.info("---------------------------------CREATING A MEETING CALENDAR FOR THE GROUP------------------------------");
final String CALENDAR_RESOURCE_URL = BASE_URL + CENTER__ENTITY + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER; final String CALENDAR_RESOURCE_URL = BASE_URL + CENTER_ENTITY + groupId + ENITY_NAME + "?" + Utils.TENANT_IDENTIFIER;
LOG.info("{}",CALENDAR_RESOURCE_URL); LOG.info("{}",CALENDAR_RESOURCE_URL);
@@ -108,7 +108,7 @@ public class CalendarHelper {
LOG.info("---------------------------------UPADATING A MEETING CALENDAR FOR THE CENTER------------------------------"); LOG.info("---------------------------------UPADATING A MEETING CALENDAR FOR THE CENTER------------------------------");
final String CALENDAR_RESOURCE_URL = BASE_URL + CENTER__ENTITY + centerId + ENITY_NAME + "/" + calendarID + "?" final String CALENDAR_RESOURCE_URL = BASE_URL + CENTER_ENTITY + centerId + ENITY_NAME + "/" + calendarID + "?"
+ Utils.TENANT_IDENTIFIER; + Utils.TENANT_IDENTIFIER;
LOG.info("{}",CALENDAR_RESOURCE_URL); LOG.info("{}",CALENDAR_RESOURCE_URL);
@@ -71,11 +71,11 @@ public class ChargesHelper {
private static final Integer CHARGE_FEE_FREQUENCY_MONTHS = 2; private static final Integer CHARGE_FEE_FREQUENCY_MONTHS = 2;
private static final Integer CHARGE_FEE_FREQUENCY_YEARS = 3; private static final Integer CHARGE_FEE_FREQUENCY_YEARS = 3;
private final static boolean active = true; private final static boolean ACTIVE = true;
private final static boolean PENALTY = true; private final static boolean PENALTY = true;
private final static String amount = "100"; private final static String AMOUNT = "100";
private final static String currencyCode = "USD"; private final static String CURRENCY_CODE = "USD";
public final static String feeOnMonthDay = "04 March"; public final static String FEE_ON_MONTH_DAY = "04 March";
private final static String MONTH_DAY_FORMAT = "dd MMM"; private final static String MONTH_DAY_FORMAT = "dd MMM";
public static String getSavingsSpecifiedDueDateJSON() { public static String getSavingsSpecifiedDueDateJSON() {
@@ -88,15 +88,15 @@ public class ChargesHelper {
} }
public static String getSavingsActivationFeeJSON() { public static String getSavingsActivationFeeJSON() {
return getSavingsJSON(amount, currencyCode, ChargeTimeType.SAVINGS_ACTIVATION); return getSavingsJSON(AMOUNT, CURRENCY_CODE, ChargeTimeType.SAVINGS_ACTIVATION);
} }
public static String getSavingsNoActivityFeeJSON() { public static String getSavingsNoActivityFeeJSON() {
return getSavingsJSON(amount, currencyCode, ChargeTimeType.SAVINGS_NOACTIVITY_FEE); return getSavingsJSON(AMOUNT, CURRENCY_CODE, ChargeTimeType.SAVINGS_NOACTIVITY_FEE);
} }
public static String getSavingsWithdrawalFeeJSON() { public static String getSavingsWithdrawalFeeJSON() {
return getSavingsJSON(amount, currencyCode, ChargeTimeType.WITHDRAWAL_FEE); return getSavingsJSON(AMOUNT, CURRENCY_CODE, ChargeTimeType.WITHDRAWAL_FEE);
} }
public static String getSavingsJSON(String amount, String currencyCode, ChargeTimeType timeType) { public static String getSavingsJSON(String amount, String currencyCode, ChargeTimeType timeType) {
@@ -109,7 +109,7 @@ public class ChargesHelper {
public static String getSavingsAnnualFeeJSON() { public static String getSavingsAnnualFeeJSON() {
final HashMap<String, Object> map = populateDefaultsForSavings(); final HashMap<String, Object> map = populateDefaultsForSavings();
map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay); map.put("feeOnMonthDay", ChargesHelper.FEE_ON_MONTH_DAY);
map.put("chargeTimeType", CHARGE_ANNUAL_FEE); map.put("chargeTimeType", CHARGE_ANNUAL_FEE);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
LOG.info("{}", chargesCreateJson); LOG.info("{}", chargesCreateJson);
@@ -118,7 +118,7 @@ public class ChargesHelper {
public static String getSavingsMonthlyFeeJSON() { public static String getSavingsMonthlyFeeJSON() {
final HashMap<String, Object> map = populateDefaultsForSavings(); final HashMap<String, Object> map = populateDefaultsForSavings();
map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay); map.put("feeOnMonthDay", ChargesHelper.FEE_ON_MONTH_DAY);
map.put("chargeTimeType", CHARGE_MONTHLY_FEE); map.put("chargeTimeType", CHARGE_MONTHLY_FEE);
map.put("feeInterval", 2); map.put("feeInterval", 2);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
@@ -144,12 +144,12 @@ public class ChargesHelper {
} }
public static HashMap<String, Object> populateDefaultsForSavings() { public static HashMap<String, Object> populateDefaultsForSavings() {
return populateDefaultsForSavings(amount, currencyCode); return populateDefaultsForSavings(AMOUNT, CURRENCY_CODE);
} }
public static HashMap<String, Object> populateDefaultsForSavings(String amount, String currencyCode) { public static HashMap<String, Object> populateDefaultsForSavings(String amount, String currencyCode) {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("active", ChargesHelper.active); map.put("active", ChargesHelper.ACTIVE);
map.put("amount", amount); map.put("amount", amount);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SAVINGS); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SAVINGS);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
@@ -161,7 +161,7 @@ public class ChargesHelper {
} }
public static String getLoanDisbursementJSON() { public static String getLoanDisbursementJSON() {
return getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount); return getLoanDisbursementJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT);
} }
public static String getLoanDisbursementJSON(final Integer chargeCalculationType, final String amount) { public static String getLoanDisbursementJSON(final Integer chargeCalculationType, final String amount) {
@@ -187,7 +187,7 @@ public class ChargesHelper {
} }
public static String getLoanSpecifiedDueDateJSON() { public static String getLoanSpecifiedDueDateJSON() {
return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT,
ChargesHelper.PENALTY); ChargesHelper.PENALTY);
} }
@@ -218,7 +218,7 @@ public class ChargesHelper {
} }
public static String getLoanSpecifiedDueDateWithAccountTransferJSON() { public static String getLoanSpecifiedDueDateWithAccountTransferJSON() {
return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, return getLoanSpecifiedDueDateJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT,
ChargesHelper.PENALTY, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER); ChargesHelper.PENALTY, ChargesHelper.CHARGE_PAYMENT_MODE_ACCOUNT_TRANSFER);
} }
@@ -249,7 +249,7 @@ public class ChargesHelper {
} }
public static String getLoanInstallmentFeeJSON() { public static String getLoanInstallmentFeeJSON() {
return getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount, return getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.AMOUNT,
ChargesHelper.PENALTY); ChargesHelper.PENALTY);
} }
@@ -280,7 +280,7 @@ public class ChargesHelper {
map.put("chargePaymentMode", ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR); map.put("chargePaymentMode", ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
map.put("chargeTimeType", CHARGE_OVERDUE_INSTALLMENT_FEE); map.put("chargeTimeType", CHARGE_OVERDUE_INSTALLMENT_FEE);
map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_MONTHS); map.put("feeFrequency", ChargesHelper.CHARGE_FEE_FREQUENCY_MONTHS);
map.put("feeOnMonthDay", ChargesHelper.feeOnMonthDay); map.put("feeOnMonthDay", ChargesHelper.FEE_ON_MONTH_DAY);
map.put("feeInterval", 2); map.put("feeInterval", 2);
String chargesCreateJson = new Gson().toJson(map); String chargesCreateJson = new Gson().toJson(map);
LOG.info("{}", chargesCreateJson); LOG.info("{}", chargesCreateJson);
@@ -301,11 +301,11 @@ public class ChargesHelper {
public static HashMap<String, Object> populateDefaultsForLoan() { public static HashMap<String, Object> populateDefaultsForLoan() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("active", ChargesHelper.active); map.put("active", ChargesHelper.ACTIVE);
map.put("amount", ChargesHelper.amount); map.put("amount", ChargesHelper.AMOUNT);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_LOAN); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_LOAN);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
map.put("currencyCode", ChargesHelper.currencyCode); map.put("currencyCode", ChargesHelper.CURRENCY_CODE);
map.put("locale", CommonConstants.LOCALE); map.put("locale", CommonConstants.LOCALE);
map.put("monthDayFormat", ChargesHelper.MONTH_DAY_FORMAT); map.put("monthDayFormat", ChargesHelper.MONTH_DAY_FORMAT);
map.put("name", Utils.randomNameGenerator("Charge_Loans_", 6)); map.put("name", Utils.randomNameGenerator("Charge_Loans_", 6));
@@ -314,12 +314,12 @@ public class ChargesHelper {
public static HashMap<String, Object> populateDefaultsClientCharge() { public static HashMap<String, Object> populateDefaultsClientCharge() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("active", ChargesHelper.active); map.put("active", ChargesHelper.ACTIVE);
map.put("amount", ChargesHelper.amount); map.put("amount", ChargesHelper.AMOUNT);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_CLIENT); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_CLIENT);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
map.put("chargeTimeType", ChargesHelper.CHARGE_SPECIFIED_DUE_DATE); map.put("chargeTimeType", ChargesHelper.CHARGE_SPECIFIED_DUE_DATE);
map.put("currencyCode", ChargesHelper.currencyCode); map.put("currencyCode", ChargesHelper.CURRENCY_CODE);
map.put("locale", CommonConstants.LOCALE); map.put("locale", CommonConstants.LOCALE);
map.put("monthDayFormat", ChargesHelper.MONTH_DAY_FORMAT); map.put("monthDayFormat", ChargesHelper.MONTH_DAY_FORMAT);
map.put("name", Utils.randomNameGenerator("Charge_client_", 8)); map.put("name", Utils.randomNameGenerator("Charge_client_", 8));
@@ -328,12 +328,12 @@ public class ChargesHelper {
public static HashMap<String, Object> populateDefaultsShareActivationCharge() { public static HashMap<String, Object> populateDefaultsShareActivationCharge() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("active", ChargesHelper.active); map.put("active", ChargesHelper.ACTIVE);
map.put("amount", ChargesHelper.amount); map.put("amount", ChargesHelper.AMOUNT);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
map.put("chargeTimeType", ChargesHelper.SHAREACCOUNT_ACTIVATION); map.put("chargeTimeType", ChargesHelper.SHAREACCOUNT_ACTIVATION);
map.put("currencyCode", ChargesHelper.currencyCode); map.put("currencyCode", ChargesHelper.CURRENCY_CODE);
map.put("locale", CommonConstants.LOCALE); map.put("locale", CommonConstants.LOCALE);
map.put("name", Utils.randomNameGenerator("Charge_Share_Activation_", 8)); map.put("name", Utils.randomNameGenerator("Charge_Share_Activation_", 8));
return map; return map;
@@ -341,12 +341,12 @@ public class ChargesHelper {
public static HashMap<String, Object> populateDefaultsSharePurchaseFlatCharge() { public static HashMap<String, Object> populateDefaultsSharePurchaseFlatCharge() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("active", ChargesHelper.active); map.put("active", ChargesHelper.ACTIVE);
map.put("amount", ChargesHelper.amount); map.put("amount", ChargesHelper.AMOUNT);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
map.put("chargeTimeType", ChargesHelper.SHARE_PURCHASE); map.put("chargeTimeType", ChargesHelper.SHARE_PURCHASE);
map.put("currencyCode", ChargesHelper.currencyCode); map.put("currencyCode", ChargesHelper.CURRENCY_CODE);
map.put("locale", CommonConstants.LOCALE); map.put("locale", CommonConstants.LOCALE);
map.put("name", Utils.randomNameGenerator("Charge_Share_Purchase_", 8)); map.put("name", Utils.randomNameGenerator("Charge_Share_Purchase_", 8));
return map; return map;
@@ -354,12 +354,12 @@ public class ChargesHelper {
public static HashMap<String, Object> populateDefaultsShareRedeemFlatCharge() { public static HashMap<String, Object> populateDefaultsShareRedeemFlatCharge() {
final HashMap<String, Object> map = new HashMap<>(); final HashMap<String, Object> map = new HashMap<>();
map.put("active", ChargesHelper.active); map.put("active", ChargesHelper.ACTIVE);
map.put("amount", ChargesHelper.amount); map.put("amount", ChargesHelper.AMOUNT);
map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES); map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT); map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
map.put("chargeTimeType", ChargesHelper.SHARE_REDEEM); map.put("chargeTimeType", ChargesHelper.SHARE_REDEEM);
map.put("currencyCode", ChargesHelper.currencyCode); map.put("currencyCode", ChargesHelper.CURRENCY_CODE);
map.put("locale", CommonConstants.LOCALE); map.put("locale", CommonConstants.LOCALE);
map.put("name", Utils.randomNameGenerator("Charge_Share_Redeem_", 8)); map.put("name", Utils.randomNameGenerator("Charge_Share_Redeem_", 8));
return map; return map;
@@ -98,7 +98,7 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
private final PaginationHelper<CenterData> paginationHelper = new PaginationHelper<>(); private final PaginationHelper<CenterData> paginationHelper = new PaginationHelper<>();
private final PaginationParametersDataValidator paginationParametersDataValidator; private final PaginationParametersDataValidator paginationParametersDataValidator;
private final static Set<String> supportedOrderByValues = new HashSet<>(Arrays.asList("id", "name", "officeId", "officeName")); private final static Set<String> SUPPORTED_ORDER_BY_VALUES = new HashSet<>(Arrays.asList("id", "name", "officeId", "officeName"));
@Autowired @Autowired
public CenterReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource, public CenterReadPlatformServiceImpl(final PlatformSecurityContext context, final RoutingDataSource dataSource,
@@ -172,7 +172,7 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
return extraCriteria.toString(); return extraCriteria.toString();
} }
private static final String sqlQuery = "g.id as id, g.account_no as accountNo, g.external_id as externalId, g.display_name as name, " private static final String SQL_QUERY = "g.id as id, g.account_no as accountNo, g.external_id as externalId, g.display_name as name, "
+ "g.office_id as officeId, o.name as officeName, " // + "g.office_id as officeId, o.name as officeName, " //
+ "g.staff_id as staffId, s.display_name as staffName, " // + "g.staff_id as staffId, s.display_name as staffName, " //
+ "g.status_enum as statusEnum, g.activation_date as activationDate, " // + "g.status_enum as statusEnum, g.activation_date as activationDate, " //
@@ -194,7 +194,7 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
public CenterDataMapper() { public CenterDataMapper() {
this.schemaSql = sqlQuery; this.schemaSql = SQL_QUERY;
} }
public String schema() { public String schema() {
@@ -320,7 +320,7 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
public GroupDataMapper() { public GroupDataMapper() {
this.schemaSql = sqlQuery; this.schemaSql = SQL_QUERY;
} }
public String schema() { public String schema() {
@@ -372,7 +372,7 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
@Override @Override
public Page<CenterData> retrievePagedAll(final SearchParameters searchParameters, final PaginationParameters parameters) { public Page<CenterData> retrievePagedAll(final SearchParameters searchParameters, final PaginationParameters parameters) {
this.paginationParametersDataValidator.validateParameterValues(parameters, supportedOrderByValues, "audits"); this.paginationParametersDataValidator.validateParameterValues(parameters, SUPPORTED_ORDER_BY_VALUES, "audits");
final AppUser currentUser = this.context.authenticatedUser(); final AppUser currentUser = this.context.authenticatedUser();
final String hierarchy = currentUser.getOffice().getHierarchy(); final String hierarchy = currentUser.getOffice().getHierarchy();
final String hierarchySearchString = hierarchy + "%"; final String hierarchySearchString = hierarchy + "%";
@@ -411,7 +411,7 @@ public class CenterReadPlatformServiceImpl implements CenterReadPlatformService
@Override @Override
public Collection<CenterData> retrieveAll(SearchParameters searchParameters, PaginationParameters parameters) { public Collection<CenterData> retrieveAll(SearchParameters searchParameters, PaginationParameters parameters) {
if (parameters!=null) { if (parameters!=null) {
this.paginationParametersDataValidator.validateParameterValues(parameters, supportedOrderByValues, "audits"); this.paginationParametersDataValidator.validateParameterValues(parameters, SUPPORTED_ORDER_BY_VALUES, "audits");
} }
final AppUser currentUser = this.context.authenticatedUser(); final AppUser currentUser = this.context.authenticatedUser();
final String hierarchy = currentUser.getOffice().getHierarchy(); final String hierarchy = currentUser.getOffice().getHierarchy();
@@ -254,7 +254,7 @@ public class LoansApiResource {
"inArrearsTolerance", "termFrequency", "termPeriodFrequencyType", "numberOfRepayments", "repaymentEvery", "inArrearsTolerance", "termFrequency", "termPeriodFrequencyType", "numberOfRepayments", "repaymentEvery",
"interestRatePerPeriod", "annualInterestRate", "repaymentFrequencyType", "transactionProcessingStrategyId", "interestRatePerPeriod", "annualInterestRate", "repaymentFrequencyType", "transactionProcessingStrategyId",
"transactionProcessingStrategyName", "interestRateFrequencyType", "amortizationType", "interestType", "transactionProcessingStrategyName", "interestRateFrequencyType", "amortizationType", "interestType",
"interestCalculationPeriodType", LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, "expectedFirstRepaymentOnDate", "interestCalculationPeriodType", LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, "expectedFirstRepaymentOnDate",
"graceOnPrincipalPayment", "recurringMoratoriumOnPrincipalPeriods", "graceOnInterestPayment", "graceOnInterestCharged", "interestChargedFromDate", "timeline", "graceOnPrincipalPayment", "recurringMoratoriumOnPrincipalPeriods", "graceOnInterestPayment", "graceOnInterestCharged", "interestChargedFromDate", "timeline",
"totalFeeChargesAtDisbursement", "summary", "repaymentSchedule", "transactions", "charges", "collateral", "guarantors", "totalFeeChargesAtDisbursement", "summary", "repaymentSchedule", "transactions", "charges", "collateral", "guarantors",
"meeting", "productOptions", "amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions", "meeting", "productOptions", "amortizationTypeOptions", "interestTypeOptions", "interestCalculationPeriodTypeOptions",
@@ -264,7 +264,7 @@ public class LoansApiResource {
"syncDisbursementWithMeeting", "loanCounter", "loanProductCounter", "notes", "accountLinkingOptions", "linkedAccount", "syncDisbursementWithMeeting", "loanCounter", "loanProductCounter", "notes", "accountLinkingOptions", "linkedAccount",
"interestRateDifferential", "isFloatingInterestRate", "interestRatesPeriods", LoanApiConstants.canUseForTopup, "interestRateDifferential", "isFloatingInterestRate", "interestRatesPeriods", LoanApiConstants.canUseForTopup,
LoanApiConstants.isTopup, LoanApiConstants.loanIdToClose, LoanApiConstants.topupAmount, LoanApiConstants.clientActiveLoanOptions, LoanApiConstants.isTopup, LoanApiConstants.loanIdToClose, LoanApiConstants.topupAmount, LoanApiConstants.clientActiveLoanOptions,
LoanApiConstants.datatables, LoanProductConstants.ratesParamName)); LoanApiConstants.datatables, LoanProductConstants.RATES_PARAM_NAME));
private final Set<String> LOAN_APPROVAL_DATA_PARAMETERS = new HashSet<>(Arrays.asList("approvalDate", "approvalAmount")); private final Set<String> LOAN_APPROVAL_DATA_PARAMETERS = new HashSet<>(Arrays.asList("approvalDate", "approvalAmount"));
final Set<String> GLIM_ACCOUNTS_DATA_PARAMETERS = new HashSet<>(Arrays.asList("glimId","groupId", "clientId","parentLoanAccountNo","parentPrincipalAmount", final Set<String> GLIM_ACCOUNTS_DATA_PARAMETERS = new HashSet<>(Arrays.asList("glimId","groupId", "clientId","parentLoanAccountNo","parentPrincipalAmount",
@@ -213,7 +213,7 @@ public class LoanScheduleAssembler {
final InterestCalculationPeriodMethod interestCalculationPeriodMethod = InterestCalculationPeriodMethod final InterestCalculationPeriodMethod interestCalculationPeriodMethod = InterestCalculationPeriodMethod
.fromInt(interestCalculationPeriodType); .fromInt(interestCalculationPeriodType);
Boolean allowPartialPeriodInterestCalcualtion = this.fromApiJsonHelper.extractBooleanNamed( Boolean allowPartialPeriodInterestCalcualtion = this.fromApiJsonHelper.extractBooleanNamed(
LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, element); LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, element);
if (allowPartialPeriodInterestCalcualtion == null) { if (allowPartialPeriodInterestCalcualtion == null) {
allowPartialPeriodInterestCalcualtion = loanProduct.getLoanProductRelatedDetail().isAllowPartialPeriodInterestCalcualtion(); allowPartialPeriodInterestCalcualtion = loanProduct.getLoanProductRelatedDetail().isAllowPartialPeriodInterestCalcualtion();
} }
@@ -317,7 +317,7 @@ public class LoanScheduleAssembler {
.isInterestChargedFromDateSameAsDisbursementDate(); .isInterestChargedFromDateSameAsDisbursementDate();
final Integer graceOnArrearsAgeing = this.fromApiJsonHelper.extractIntegerWithLocaleNamed( final Integer graceOnArrearsAgeing = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(
LoanProductConstants.graceOnArrearsAgeingParameterName, element); LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME, element);
// other // other
final BigDecimal inArrearsTolerance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("inArrearsTolerance", element); final BigDecimal inArrearsTolerance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("inArrearsTolerance", element);
@@ -55,7 +55,7 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper {
LoanApiConstants.loanTermFrequencyTypeParameterName, LoanApiConstants.repaymentFrequencyTypeParameterName, LoanApiConstants.loanTermFrequencyTypeParameterName, LoanApiConstants.repaymentFrequencyTypeParameterName,
LoanApiConstants.amortizationTypeParameterName, LoanApiConstants.interestTypeParameterName, LoanApiConstants.amortizationTypeParameterName, LoanApiConstants.interestTypeParameterName,
LoanApiConstants.interestCalculationPeriodTypeParameterName, LoanApiConstants.interestCalculationPeriodTypeParameterName,
LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, LoanApiConstants.interestRateFrequencyTypeParameterName, LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, LoanApiConstants.interestRateFrequencyTypeParameterName,
LoanApiConstants.disbursementDateParameterName, LoanApiConstants.repaymentsStartingFromDateParameterName, LoanApiConstants.disbursementDateParameterName, LoanApiConstants.repaymentsStartingFromDateParameterName,
LoanApiConstants.graceOnPrincipalPaymentParameterName, LoanApiConstants.graceOnInterestPaymentParameterName, LoanApiConstants.graceOnPrincipalPaymentParameterName, LoanApiConstants.graceOnInterestPaymentParameterName,
LoanApiConstants.graceOnInterestChargedParameterName, LoanApiConstants.interestChargedFromDateParameterName, LoanApiConstants.graceOnInterestChargedParameterName, LoanApiConstants.interestChargedFromDateParameterName,
@@ -64,11 +64,11 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper {
LoanApiConstants.collateralParameterName, LoanApiConstants.syncDisbursementWithMeetingParameterName, LoanApiConstants.collateralParameterName, LoanApiConstants.syncDisbursementWithMeetingParameterName,
LoanApiConstants.linkAccountIdParameterName, LoanApiConstants.disbursementDataParameterName, LoanApiConstants.linkAccountIdParameterName, LoanApiConstants.disbursementDataParameterName,
LoanApiConstants.emiAmountParameterName, LoanApiConstants.maxOutstandingBalanceParameterName, LoanApiConstants.emiAmountParameterName, LoanApiConstants.maxOutstandingBalanceParameterName,
LoanProductConstants.graceOnArrearsAgeingParameterName, LoanApiConstants.createStandingInstructionAtDisbursementParameterName, LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME, LoanApiConstants.createStandingInstructionAtDisbursementParameterName,
LoanApiConstants.isFloatingInterestRateParameterName, LoanApiConstants.interestRateDifferentialParameterName, LoanApiConstants.isFloatingInterestRateParameterName, LoanApiConstants.interestRateDifferentialParameterName,
LoanApiConstants.repaymentFrequencyNthDayTypeParameterName, LoanApiConstants.repaymentFrequencyDayOfWeekTypeParameterName, LoanApiConstants.repaymentFrequencyNthDayTypeParameterName, LoanApiConstants.repaymentFrequencyDayOfWeekTypeParameterName,
LoanApiConstants.isTopup, LoanApiConstants.loanIdToClose, LoanApiConstants.datatables, LoanApiConstants.isEqualAmortizationParam, LoanApiConstants.isTopup, LoanApiConstants.loanIdToClose, LoanApiConstants.datatables, LoanApiConstants.isEqualAmortizationParam,
LoanProductConstants.ratesParamName)); LoanProductConstants.RATES_PARAM_NAME));
private final FromJsonHelper fromApiJsonHelper; private final FromJsonHelper fromApiJsonHelper;
@@ -69,7 +69,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
LoanApiConstants.interestRatePerPeriodParameterName, LoanApiConstants.amortizationTypeParameterName, LoanApiConstants.interestRatePerPeriodParameterName, LoanApiConstants.amortizationTypeParameterName,
LoanApiConstants.interestTypeParameterName, LoanApiConstants.isFloatingInterestRate, LoanApiConstants.interestRateDifferential, LoanApiConstants.interestTypeParameterName, LoanApiConstants.isFloatingInterestRate, LoanApiConstants.interestRateDifferential,
LoanApiConstants.interestCalculationPeriodTypeParameterName, LoanApiConstants.interestCalculationPeriodTypeParameterName,
LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, LoanApiConstants.interestRateFrequencyTypeParameterName, LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, LoanApiConstants.interestRateFrequencyTypeParameterName,
LoanApiConstants.disbursementDateParameterName, LoanApiConstants.repaymentsStartingFromDateParameterName, LoanApiConstants.disbursementDateParameterName, LoanApiConstants.repaymentsStartingFromDateParameterName,
LoanApiConstants.graceOnPrincipalPaymentParameterName, LoanApiConstants.graceOnPrincipalPaymentParameterName,
LoanApiConstants.graceOnInterestPaymentParameterName, LoanApiConstants.graceOnInterestPaymentParameterName,
@@ -90,8 +90,8 @@ public final class LoanApplicationCommandFromApiJsonHelper {
LoanApiConstants.syncDisbursementWithMeetingParameterName,// optional LoanApiConstants.syncDisbursementWithMeetingParameterName,// optional
LoanApiConstants.linkAccountIdParameterName, LoanApiConstants.disbursementDataParameterName, LoanApiConstants.linkAccountIdParameterName, LoanApiConstants.disbursementDataParameterName,
LoanApiConstants.emiAmountParameterName, LoanApiConstants.maxOutstandingBalanceParameterName, LoanApiConstants.emiAmountParameterName, LoanApiConstants.maxOutstandingBalanceParameterName,
LoanProductConstants.graceOnArrearsAgeingParameterName, LoanApiConstants.createStandingInstructionAtDisbursementParameterName, LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME, LoanApiConstants.createStandingInstructionAtDisbursementParameterName,
LoanApiConstants.isTopup, LoanApiConstants.loanIdToClose, LoanApiConstants.datatables, LoanApiConstants.isEqualAmortizationParam,LoanProductConstants.ratesParamName, LoanApiConstants.isTopup, LoanApiConstants.loanIdToClose, LoanApiConstants.datatables, LoanApiConstants.isEqualAmortizationParam,LoanProductConstants.RATES_PARAM_NAME,
LoanApiConstants.applicationId, // glim specific LoanApiConstants.applicationId, // glim specific
LoanApiConstants.lastApplication)); // glim specific LoanApiConstants.lastApplication)); // glim specific
@@ -334,8 +334,8 @@ public final class LoanApplicationCommandFromApiJsonHelper {
baseDataValidator.reset().parameter("graceOnInterestCharged").value(graceOnInterestCharged).zeroOrPositiveAmount(); baseDataValidator.reset().parameter("graceOnInterestCharged").value(graceOnInterestCharged).zeroOrPositiveAmount();
final Integer graceOnArrearsAgeing = this.fromApiJsonHelper.extractIntegerWithLocaleNamed( final Integer graceOnArrearsAgeing = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(
LoanProductConstants.graceOnArrearsAgeingParameterName, element); LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.graceOnArrearsAgeingParameterName).value(graceOnArrearsAgeing) baseDataValidator.reset().parameter(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME).value(graceOnArrearsAgeing)
.zeroOrPositiveAmount(); .zeroOrPositiveAmount();
final String interestChargedFromDateParameterName = "interestChargedFromDate"; final String interestChargedFromDateParameterName = "interestChargedFromDate";
@@ -545,9 +545,9 @@ public final class LoanApplicationCommandFromApiJsonHelper {
} }
boolean isEqualAmortization = existingLoanApplication.getLoanProductRelatedDetail().isEqualAmortization(); boolean isEqualAmortization = existingLoanApplication.getLoanProductRelatedDetail().isEqualAmortization();
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.isEqualAmortizationParam, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, element)) {
isEqualAmortization = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.isEqualAmortizationParam, element); isEqualAmortization = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, element);
baseDataValidator.reset().parameter(LoanProductConstants.isEqualAmortizationParam).value(isEqualAmortization).ignoreIfNull() baseDataValidator.reset().parameter(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM).value(isEqualAmortization).ignoreIfNull()
.validateForBooleanValue(); .validateForBooleanValue();
if (isEqualAmortization && loanProduct.isInterestRecalculationEnabled()) { throw new EqualAmortizationUnsupportedFeatureException( if (isEqualAmortization && loanProduct.isInterestRecalculationEnabled()) { throw new EqualAmortizationUnsupportedFeatureException(
"interest.recalculation", "interest recalculation"); } "interest.recalculation", "interest recalculation"); }
@@ -782,10 +782,10 @@ public final class LoanApplicationCommandFromApiJsonHelper {
baseDataValidator.reset().parameter("graceOnInterestCharged").value(graceOnInterestCharged).zeroOrPositiveAmount(); baseDataValidator.reset().parameter("graceOnInterestCharged").value(graceOnInterestCharged).zeroOrPositiveAmount();
} }
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.graceOnArrearsAgeingParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME, element)) {
final Integer graceOnArrearsAgeing = this.fromApiJsonHelper.extractIntegerWithLocaleNamed( final Integer graceOnArrearsAgeing = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(
LoanProductConstants.graceOnArrearsAgeingParameterName, element); LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.graceOnArrearsAgeingParameterName).value(graceOnArrearsAgeing) baseDataValidator.reset().parameter(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME).value(graceOnArrearsAgeing)
.zeroOrPositiveAmount(); .zeroOrPositiveAmount();
} }
@@ -1207,15 +1207,15 @@ public final class LoanApplicationCommandFromApiJsonHelper {
.fromInt(interestCalculationPeriodType); .fromInt(interestCalculationPeriodType);
boolean considerPartialPeriodUpdates = interestCalculationPeriodMethod.isDaily() ? interestCalculationPeriodMethod.isDaily() boolean considerPartialPeriodUpdates = interestCalculationPeriodMethod.isDaily() ? interestCalculationPeriodMethod.isDaily()
: loanProduct.getLoanProductRelatedDetail().isAllowPartialPeriodInterestCalcualtion(); : loanProduct.getLoanProductRelatedDetail().isAllowPartialPeriodInterestCalcualtion();
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, element)) {
final Boolean considerPartialInterestEnabled = this.fromApiJsonHelper.extractBooleanNamed( final Boolean considerPartialInterestEnabled = this.fromApiJsonHelper.extractBooleanNamed(
LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, element); LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName) baseDataValidator.reset().parameter(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME)
.value(considerPartialInterestEnabled).notNull().isOneOfTheseValues(true, false); .value(considerPartialInterestEnabled).notNull().isOneOfTheseValues(true, false);
boolean considerPartialPeriods = considerPartialInterestEnabled == null ? false : considerPartialInterestEnabled; boolean considerPartialPeriods = considerPartialInterestEnabled == null ? false : considerPartialInterestEnabled;
if (interestCalculationPeriodMethod.isDaily()) { if (interestCalculationPeriodMethod.isDaily()) {
if (considerPartialPeriods) { if (considerPartialPeriods) {
baseDataValidator.reset().parameter(LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName) baseDataValidator.reset().parameter(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME)
.failWithCode("not.supported.for.daily.calcualtions"); .failWithCode("not.supported.for.daily.calcualtions");
} }
} else { } else {
@@ -1225,12 +1225,12 @@ public final class LoanApplicationCommandFromApiJsonHelper {
if (!considerPartialPeriodUpdates) { if (!considerPartialPeriodUpdates) {
if (loanProduct.isInterestRecalculationEnabled()) { if (loanProduct.isInterestRecalculationEnabled()) {
baseDataValidator.reset().parameter(LoanProductConstants.isInterestRecalculationEnabledParameterName) baseDataValidator.reset().parameter(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME)
.failWithCode("not.supported.for.selected.interest.calcualtion.type"); .failWithCode("not.supported.for.selected.interest.calcualtion.type");
} }
if (loanProduct.isMultiDisburseLoan()) { if (loanProduct.isMultiDisburseLoan()) {
baseDataValidator.reset().parameter(LoanProductConstants.multiDisburseLoanParameterName) baseDataValidator.reset().parameter(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME)
.failWithCode("not.supported.for.selected.interest.calcualtion.type"); .failWithCode("not.supported.for.selected.interest.calcualtion.type");
} }
@@ -1018,7 +1018,7 @@ public void checkForProductMixRestrictions(final Loan loan) {
} }
//Changes to modify loan rates. //Changes to modify loan rates.
if (command.hasParameter(LoanProductConstants.ratesParamName)) { if (command.hasParameter(LoanProductConstants.RATES_PARAM_NAME)) {
existingLoanApplication.updateLoanRates(rateAssembler.fromParsedJson(command.parsedJson())); existingLoanApplication.updateLoanRates(rateAssembler.fromParsedJson(command.parsedJson()));
} }
@@ -1200,7 +1200,7 @@ public void checkForProductMixRestrictions(final Loan loan) {
if (productRelatedDetail.isInterestRecalculationEnabled()) { if (productRelatedDetail.isInterestRecalculationEnabled()) {
this.fromApiJsonDeserializer.validateLoanForInterestRecalculation(existingLoanApplication); this.fromApiJsonDeserializer.validateLoanForInterestRecalculation(existingLoanApplication);
if (changes.containsKey(LoanProductConstants.isInterestRecalculationEnabledParameterName)) { if (changes.containsKey(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME)) {
createAndPersistCalendarInstanceForInterestRecalculation(existingLoanApplication); createAndPersistCalendarInstanceForInterestRecalculation(existingLoanApplication);
} }
@@ -22,66 +22,66 @@ import java.math.BigDecimal;
public interface LoanProductConstants { public interface LoanProductConstants {
public static final String useBorrowerCycleParameterName = "useBorrowerCycle"; public static final String USE_BORROWER_CYCLE_PARAMETER_NAME = "useBorrowerCycle";
public static final String principalVariationsForBorrowerCycleParameterName = "principalVariationsForBorrowerCycle"; public static final String PRINCIPAL_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME = "principalVariationsForBorrowerCycle";
public static final String interestRateVariationsForBorrowerCycleParameterName = "interestRateVariationsForBorrowerCycle"; public static final String INTEREST_RATE_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME = "interestRateVariationsForBorrowerCycle";
public static final String numberOfRepaymentVariationsForBorrowerCycleParameterName = "numberOfRepaymentVariationsForBorrowerCycle"; public static final String NUMBER_OF_REPAYMENT_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME = "numberOfRepaymentVariationsForBorrowerCycle";
public static final String defaultValueParameterName = "defaultValue"; public static final String DEFAULT_VALUE_PARAMETER_NAME = "defaultValue";
public static final String minValueParameterName = "minValue"; public static final String MIN_VALUE_PARAMETER_NAME = "minValue";
public static final String maxValueParameterName = "maxValue"; public static final String MAX_VALUE_PARAMETER_NAME = "maxValue";
public static final String valueConditionTypeParamName = "valueConditionType"; public static final String VALUE_CONDITION_TYPE_PARAM_NAME = "valueConditionType";
public static final String borrowerCycleNumberParamName = "borrowerCycleNumber"; public static final String BORROWER_CYCLE_NUMBER_PARAM_NAME = "borrowerCycleNumber";
public static final String borrowerCycleIdParameterName = "id"; public static final String BORROWER_CYCLE_ID_PARAMETER_NAME = "id";
public static final String principalPerCycleParameterName = "principalPerCycle"; public static final String PRINCIPAL_PER_CYCLE_PARAMETER_NAME = "principalPerCycle";
public static final String minPrincipalPerCycleParameterName = "minPrincipalPerCycle"; public static final String MIN_PRINCIPAL_PER_CYCLE_PARAMETER_NAME = "minPrincipalPerCycle";
public static final String maxPrincipalPerCycleParameterName = "maxPrincipalPerCycle"; public static final String MAX_PRINCIPAL_PER_CYCLE_PARAMETER_NAME = "maxPrincipalPerCycle";
public static final String principalValueUsageConditionParamName = "principalValueUsageCondition"; public static final String PRINCIPAL_VALUE_USAGE_CONDITION_PARAM_NAME = "principalValueUsageCondition";
public static final String principalCycleNumbersParamName = "principalCycleNumbers"; public static final String PRINCIPAL_CYCLE_NUMBERS_PARAM_NAME = "principalCycleNumbers";
public static final String numberOfRepaymentsPerCycleParameterName = "numberOfRepaymentsPerCycle"; public static final String NUMBER_OF_REPAYMENTS_PER_CYCLE_PARAMETER_NAME = "numberOfRepaymentsPerCycle";
public static final String minNumberOfRepaymentsPerCycleParameterName = "minNumberOfRepaymentsPerCycle"; public static final String MIN_NUMBER_OF_REPAYMENTS_PER_CYCLE_PARAMETER_NAME = "minNumberOfRepaymentsPerCycle";
public static final String maxNumberOfRepaymentsPerCycleParameterName = "maxNumberOfRepaymentsPerCycle"; public static final String MAX_NUMBER_OF_REPAYMENTS_PER_CYCLE_PARAMETER_NAME = "maxNumberOfRepaymentsPerCycle";
public static final String repaymentValueUsageConditionParamName = "repaymentValueUsageCondition"; public static final String REPAYMENT_VALUE_USAGE_CONDITION_PARAM_NAME = "repaymentValueUsageCondition";
public static final String repaymentCycleNumberParamName = "repaymentCycleNumber"; public static final String REPAYMENT_CYCLE_NUMBER_PARAM_NAME = "repaymentCycleNumber";
public static final String interestRatePerPeriodPerCycleParameterName = "interestRatePerPeriodPerCycle"; public static final String INTEREST_RATE_PER_PERIOD_PER_CYCLE_PARAMETER_NAME = "interestRatePerPeriodPerCycle";
public static final String minInterestRatePerPeriodPerCycleParameterName = "minInterestRatePerPeriodPerCycle"; public static final String MIN_INTEREST_RATE_PER_PERIOD_PER_CYCLE_PARAMETER_NAME = "minInterestRatePerPeriodPerCycle";
public static final String maxInterestRatePerPeriodPerCycleParameterName = "maxInterestRatePerPeriodPerCycle"; public static final String MAX_INTEREST_RATE_PER_PERIOD_PER_CYCLE_PARAMETER_NAME = "maxInterestRatePerPeriodPerCycle";
public static final String interestRateValueUsageConditionParamName = "interestRateValueUsageCondition"; public static final String INTEREST_RATE_VALUE_USAGE_CONDITION_PARAM_NAME = "interestRateValueUsageCondition";
public static final String interestRateCycleNumberParamName = "interestRateCycleNumber"; public static final String INTEREST_RATE_CYCLE_NUMBER_PARAM_NAME = "interestRateCycleNumber";
public static final String principal = "principal"; public static final String PRINCIPAL = "principal";
public static final String minPrincipal = "minPrincipal"; public static final String MIN_PRINCIPAL = "minPrincipal";
public static final String maxPrincipal = "maxPrincipalValue"; public static final String MAX_PRINCIPAL = "maxPrincipalValue";
public static final String interestRatePerPeriod = "interestRatePerPeriod"; public static final String INTEREST_RATE_PER_PERIOD = "interestRatePerPeriod";
public static final String minInterestRatePerPeriod = "minInterestRatePerPeriod"; public static final String MIN_INTEREST_RATE_PER_PERIOD = "minInterestRatePerPeriod";
public static final String maxInterestRatePerPeriod = "maxInterestRatePerPeriod"; public static final String MAX_INTEREST_RATE_PER_PERIOD = "maxInterestRatePerPeriod";
public static final String numberOfRepayments = "numberOfRepayments"; public static final String NUMBER_OF_REPAYMENTS = "numberOfRepayments";
public static final String minNumberOfRepayments = "minNumberOfRepayments"; public static final String MIN_NUMBER_OF_REPAYMENTS = "minNumberOfRepayments";
public static final String maxNumberOfRepayments = "maxNumberOfRepayments"; public static final String MAX_NUMBER_OF_REPAYMENTS = "maxNumberOfRepayments";
public static final String VALUE_CONDITION_END_WITH_ERROR = "condition.type.must.end.with.greterthan"; public static final String VALUE_CONDITION_END_WITH_ERROR = "condition.type.must.end.with.greterthan";
public static final String VALUE_CONDITION_START_WITH_ERROR = "condition.type.must.start.with.equal"; public static final String VALUE_CONDITION_START_WITH_ERROR = "condition.type.must.start.with.equal";
public static final String shortName = "shortName"; public static final String SHORT_NAME = "shortName";
public static final String multiDisburseLoanParameterName = "multiDisburseLoan"; public static final String MULTI_DISBURSE_LOAN_PARAMETER_NAME = "multiDisburseLoan";
public static final String maxTrancheCountParameterName = "maxTrancheCount"; public static final String MAX_TRANCHE_COUNT_PARAMETER_NAME = "maxTrancheCount";
public static final String outstandingLoanBalanceParameterName = "outstandingLoanBalance"; public static final String OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME = "outstandingLoanBalance";
public static final String graceOnArrearsAgeingParameterName = "graceOnArrearsAgeing"; public static final String GRACE_ON_ARREARS_AGEING_PARAMETER_NAME = "graceOnArrearsAgeing";
public static final String overdueDaysForNPAParameterName = "overdueDaysForNPA"; public static final String OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME = "overdueDaysForNPA";
public static final String minimumDaysBetweenDisbursalAndFirstRepayment = "minimumDaysBetweenDisbursalAndFirstRepayment"; public static final String MINIMUM_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT = "minimumDaysBetweenDisbursalAndFirstRepayment";
public static final String accountMovesOutOfNPAOnlyOnArrearsCompletionParamName = "accountMovesOutOfNPAOnlyOnArrearsCompletion"; public static final String ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME = "accountMovesOutOfNPAOnlyOnArrearsCompletion";
// Interest recalculation related // Interest recalculation related
public static final String isInterestRecalculationEnabledParameterName = "isInterestRecalculationEnabled"; public static final String IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME = "isInterestRecalculationEnabled";
public static final String daysInYearTypeParameterName = "daysInYearType"; public static final String DAYS_IN_YEAR_TYPE_PARAMETER_NAME = "daysInYearType";
public static final String daysInMonthTypeParameterName = "daysInMonthType"; public static final String DAYS_IN_MONTH_TYPE_PARAMETER_NAME = "daysInMonthType";
public static final String interestRecalculationCompoundingMethodParameterName = "interestRecalculationCompoundingMethod"; public static final String interestRecalculationCompoundingMethodParameterName = "interestRecalculationCompoundingMethod";
public static final String rescheduleStrategyMethodParameterName = "rescheduleStrategyMethod"; public static final String rescheduleStrategyMethodParameterName = "rescheduleStrategyMethod";
public static final String recalculationRestFrequencyTypeParameterName = "recalculationRestFrequencyType"; public static final String recalculationRestFrequencyTypeParameterName = "recalculationRestFrequencyType";
@@ -128,12 +128,12 @@ public interface LoanProductConstants {
public static final String maximumGapBetweenInstallments = "maximumGap" ; public static final String maximumGapBetweenInstallments = "maximumGap" ;
public static final String allowPartialPeriodInterestCalcualtionParamName = "allowPartialPeriodInterestCalcualtion"; public static final String ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME = "allowPartialPeriodInterestCalcualtion";
public static final String canUseForTopup = "canUseForTopup"; public static final String CAN_USE_FOR_TOPUP = "canUseForTopup";
public static final String isEqualAmortizationParam = "isEqualAmortization"; public static final String IS_EQUAL_AMORTIZATION_PARAM = "isEqualAmortization";
public static final String ratesParamName = "rates"; public static final String RATES_PARAM_NAME = "rates";
} }
@@ -98,15 +98,15 @@ public class LoanProductsApiResource {
"minNumberOfRepayments", "maxNumberOfRepayments", "repaymentEvery", "repaymentFrequencyType", "graceOnPrincipalPayment", "recurringMoratoriumOnPrincipalPeriods", "minNumberOfRepayments", "maxNumberOfRepayments", "repaymentEvery", "repaymentFrequencyType", "graceOnPrincipalPayment", "recurringMoratoriumOnPrincipalPeriods",
"graceOnInterestPayment", "graceOnInterestCharged", "interestRatePerPeriod", "minInterestRatePerPeriod", "graceOnInterestPayment", "graceOnInterestCharged", "interestRatePerPeriod", "minInterestRatePerPeriod",
"maxInterestRatePerPeriod", "interestRateFrequencyType", "annualInterestRate", "amortizationType", "interestType", "maxInterestRatePerPeriod", "interestRateFrequencyType", "annualInterestRate", "amortizationType", "interestType",
"interestCalculationPeriodType", LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, "inArrearsTolerance", "interestCalculationPeriodType", LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, "inArrearsTolerance",
"transactionProcessingStrategyId", "transactionProcessingStrategyName", "charges", "accountingRule", "externalId", "transactionProcessingStrategyId", "transactionProcessingStrategyName", "charges", "accountingRule", "externalId",
"accountingMappings", "paymentChannelToFundSourceMappings", "fundOptions", "paymentTypeOptions", "currencyOptions", "accountingMappings", "paymentChannelToFundSourceMappings", "fundOptions", "paymentTypeOptions", "currencyOptions",
"repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "amortizationTypeOptions", "interestTypeOptions", "repaymentFrequencyTypeOptions", "interestRateFrequencyTypeOptions", "amortizationTypeOptions", "interestTypeOptions",
"interestCalculationPeriodTypeOptions", "transactionProcessingStrategyOptions", "chargeOptions", "accountingOptions", "interestCalculationPeriodTypeOptions", "transactionProcessingStrategyOptions", "chargeOptions", "accountingOptions",
"accountingRuleOptions", "accountingMappingOptions", "floatingRateOptions", "isLinkedToFloatingInterestRates", "accountingRuleOptions", "accountingMappingOptions", "floatingRateOptions", "isLinkedToFloatingInterestRates",
"floatingRatesId", "interestRateDifferential", "minDifferentialLendingRate", "defaultDifferentialLendingRate", "floatingRatesId", "interestRateDifferential", "minDifferentialLendingRate", "defaultDifferentialLendingRate",
"maxDifferentialLendingRate", "isFloatingInterestRateCalculationAllowed", LoanProductConstants.canUseForTopup, LoanProductConstants.isEqualAmortizationParam, "maxDifferentialLendingRate", "isFloatingInterestRateCalculationAllowed", LoanProductConstants.CAN_USE_FOR_TOPUP, LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM,
LoanProductConstants.ratesParamName)); LoanProductConstants.RATES_PARAM_NAME));
private final Set<String> PRODUCT_MIX_DATA_PARAMETERS = new HashSet<>(Arrays.asList("productId", "productName", "restrictedProducts", private final Set<String> PRODUCT_MIX_DATA_PARAMETERS = new HashSet<>(Arrays.asList("productId", "productName", "restrictedProducts",
"allowedProducts", "productOptions")); "allowedProducts", "productOptions"));
@@ -193,7 +193,7 @@ public class LoanProduct extends AbstractPersistableCustom {
final List<Rate> productRates) { final List<Rate> productRates) {
final String name = command.stringValueOfParameterNamed("name"); final String name = command.stringValueOfParameterNamed("name");
final String shortName = command.stringValueOfParameterNamed(LoanProductConstants.shortName); final String shortName = command.stringValueOfParameterNamed(LoanProductConstants.SHORT_NAME);
final String description = command.stringValueOfParameterNamed("description"); final String description = command.stringValueOfParameterNamed("description");
final String currencyCode = command.stringValueOfParameterNamed("currencyCode"); final String currencyCode = command.stringValueOfParameterNamed("currencyCode");
final Integer digitsAfterDecimal = command.integerValueOfParameterNamed("digitsAfterDecimal"); final Integer digitsAfterDecimal = command.integerValueOfParameterNamed("digitsAfterDecimal");
@@ -208,7 +208,7 @@ public class LoanProduct extends AbstractPersistableCustom {
final InterestCalculationPeriodMethod interestCalculationPeriodMethod = InterestCalculationPeriodMethod.fromInt(command final InterestCalculationPeriodMethod interestCalculationPeriodMethod = InterestCalculationPeriodMethod.fromInt(command
.integerValueOfParameterNamed("interestCalculationPeriodType")); .integerValueOfParameterNamed("interestCalculationPeriodType"));
final boolean allowPartialPeriodInterestCalcualtion = command final boolean allowPartialPeriodInterestCalcualtion = command
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName); .booleanPrimitiveValueOfParameterNamed(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME);
final AmortizationMethod amortizationMethod = AmortizationMethod.fromInt(command.integerValueOfParameterNamed("amortizationType")); final AmortizationMethod amortizationMethod = AmortizationMethod.fromInt(command.integerValueOfParameterNamed("amortizationType"));
final PeriodFrequencyType repaymentFrequencyType = PeriodFrequencyType.fromInt(command final PeriodFrequencyType repaymentFrequencyType = PeriodFrequencyType.fromInt(command
.integerValueOfParameterNamed("repaymentFrequencyType")); .integerValueOfParameterNamed("repaymentFrequencyType"));
@@ -263,7 +263,7 @@ public class LoanProduct extends AbstractPersistableCustom {
final Integer graceOnInterestPayment = command.integerValueOfParameterNamed("graceOnInterestPayment"); final Integer graceOnInterestPayment = command.integerValueOfParameterNamed("graceOnInterestPayment");
final Integer graceOnInterestCharged = command.integerValueOfParameterNamed("graceOnInterestCharged"); final Integer graceOnInterestCharged = command.integerValueOfParameterNamed("graceOnInterestCharged");
final Integer minimumDaysBetweenDisbursalAndFirstRepayment = command final Integer minimumDaysBetweenDisbursalAndFirstRepayment = command
.integerValueOfParameterNamed(LoanProductConstants.minimumDaysBetweenDisbursalAndFirstRepayment); .integerValueOfParameterNamed(LoanProductConstants.MINIMUM_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT);
final AccountingRuleType accountingRuleType = AccountingRuleType.fromInt(command.integerValueOfParameterNamed("accountingRule")); final AccountingRuleType accountingRuleType = AccountingRuleType.fromInt(command.integerValueOfParameterNamed("accountingRule"));
final boolean includeInBorrowerCycle = command.booleanPrimitiveValueOfParameterNamed("includeInBorrowerCycle"); final boolean includeInBorrowerCycle = command.booleanPrimitiveValueOfParameterNamed("includeInBorrowerCycle");
@@ -272,7 +272,7 @@ public class LoanProduct extends AbstractPersistableCustom {
final LocalDate closeDate = command.localDateValueOfParameterNamed("closeDate"); final LocalDate closeDate = command.localDateValueOfParameterNamed("closeDate");
final String externalId = command.stringValueOfParameterNamedAllowingNull("externalId"); final String externalId = command.stringValueOfParameterNamedAllowingNull("externalId");
final boolean useBorrowerCycle = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.useBorrowerCycleParameterName); final boolean useBorrowerCycle = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME);
final Set<LoanProductBorrowerCycleVariations> loanProductBorrowerCycleVariations = new HashSet<>(); final Set<LoanProductBorrowerCycleVariations> loanProductBorrowerCycleVariations = new HashSet<>();
if (useBorrowerCycle) { if (useBorrowerCycle) {
@@ -280,26 +280,26 @@ public class LoanProduct extends AbstractPersistableCustom {
} }
final boolean multiDisburseLoan = command final boolean multiDisburseLoan = command
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.multiDisburseLoanParameterName); .booleanPrimitiveValueOfParameterNamed(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME);
Integer maxTrancheCount = null; Integer maxTrancheCount = null;
BigDecimal outstandingLoanBalance = null; BigDecimal outstandingLoanBalance = null;
if (multiDisburseLoan) { if (multiDisburseLoan) {
outstandingLoanBalance = command.bigDecimalValueOfParameterNamed(LoanProductConstants.outstandingLoanBalanceParameterName); outstandingLoanBalance = command.bigDecimalValueOfParameterNamed(LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME);
maxTrancheCount = command.integerValueOfParameterNamed(LoanProductConstants.maxTrancheCountParameterName); maxTrancheCount = command.integerValueOfParameterNamed(LoanProductConstants.MAX_TRANCHE_COUNT_PARAMETER_NAME);
} }
final Integer graceOnArrearsAgeing = command.integerValueOfParameterNamed(LoanProductConstants.graceOnArrearsAgeingParameterName); final Integer graceOnArrearsAgeing = command.integerValueOfParameterNamed(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME);
final Integer overdueDaysForNPA = command.integerValueOfParameterNamed(LoanProductConstants.overdueDaysForNPAParameterName); final Integer overdueDaysForNPA = command.integerValueOfParameterNamed(LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME);
// Interest recalculation settings // Interest recalculation settings
final boolean isInterestRecalculationEnabled = command final boolean isInterestRecalculationEnabled = command
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.isInterestRecalculationEnabledParameterName); .booleanPrimitiveValueOfParameterNamed(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME);
final DaysInMonthType daysInMonthType = DaysInMonthType.fromInt(command final DaysInMonthType daysInMonthType = DaysInMonthType.fromInt(command
.integerValueOfParameterNamed(LoanProductConstants.daysInMonthTypeParameterName)); .integerValueOfParameterNamed(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME));
final DaysInYearType daysInYearType = DaysInYearType.fromInt(command final DaysInYearType daysInYearType = DaysInYearType.fromInt(command
.integerValueOfParameterNamed(LoanProductConstants.daysInYearTypeParameterName)); .integerValueOfParameterNamed(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME));
LoanProductInterestRecalculationDetails interestRecalculationSettings = null; LoanProductInterestRecalculationDetails interestRecalculationSettings = null;
@@ -328,7 +328,7 @@ public class LoanProduct extends AbstractPersistableCustom {
: LoanProductConstants.DEFAULT_PRINCIPAL_THRESHOLD_FOR_SINGLE_DISBURSE_LOAN; : LoanProductConstants.DEFAULT_PRINCIPAL_THRESHOLD_FOR_SINGLE_DISBURSE_LOAN;
} }
final boolean accountMovesOutOfNPAOnlyOnArrearsCompletion = command final boolean accountMovesOutOfNPAOnlyOnArrearsCompletion = command
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.accountMovesOutOfNPAOnlyOnArrearsCompletionParamName); .booleanPrimitiveValueOfParameterNamed(LoanProductConstants.ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME);
final boolean canDefineEmiAmount = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.canDefineEmiAmountParamName); final boolean canDefineEmiAmount = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.canDefineEmiAmountParamName);
final Integer installmentAmountInMultiplesOf = command final Integer installmentAmountInMultiplesOf = command
.integerValueOfParameterNamed(LoanProductConstants.installmentAmountInMultiplesOfParamName); .integerValueOfParameterNamed(LoanProductConstants.installmentAmountInMultiplesOfParamName);
@@ -336,12 +336,12 @@ public class LoanProduct extends AbstractPersistableCustom {
final boolean syncExpectedWithDisbursementDate = command.booleanPrimitiveValueOfParameterNamed("syncExpectedWithDisbursementDate"); final boolean syncExpectedWithDisbursementDate = command.booleanPrimitiveValueOfParameterNamed("syncExpectedWithDisbursementDate");
final boolean canUseForTopup = command.parameterExists(LoanProductConstants.canUseForTopup) final boolean canUseForTopup = command.parameterExists(LoanProductConstants.CAN_USE_FOR_TOPUP)
? command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.canUseForTopup) ? command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.CAN_USE_FOR_TOPUP)
: false; : false;
final boolean isEqualAmortization = command.parameterExists(LoanProductConstants.isEqualAmortizationParam) ? command final boolean isEqualAmortization = command.parameterExists(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM) ? command
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.isEqualAmortizationParam) : false; .booleanPrimitiveValueOfParameterNamed(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM) : false;
return new LoanProduct(fund, loanTransactionProcessingStrategy, name, shortName, description, currency, principal, minPrincipal, return new LoanProduct(fund, loanTransactionProcessingStrategy, name, shortName, description, currency, principal, minPrincipal,
maxPrincipal, interestRatePerPeriod, minInterestRatePerPeriod, maxInterestRatePerPeriod, interestFrequencyType, maxPrincipal, interestRatePerPeriod, minInterestRatePerPeriod, maxInterestRatePerPeriod, interestFrequencyType,
@@ -389,7 +389,7 @@ public class LoanProduct extends AbstractPersistableCustom {
private static void assembleInterestRateVariations(final JsonCommand command, private static void assembleInterestRateVariations(final JsonCommand command,
final Set<LoanProductBorrowerCycleVariations> loanProductBorrowerCycleVariations) { final Set<LoanProductBorrowerCycleVariations> loanProductBorrowerCycleVariations) {
assembleVaritions(command, loanProductBorrowerCycleVariations, LoanProductParamType.INTERESTRATE.getValue(), assembleVaritions(command, loanProductBorrowerCycleVariations, LoanProductParamType.INTERESTRATE.getValue(),
LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName); LoanProductConstants.INTEREST_RATE_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME);
} }
@@ -400,7 +400,7 @@ public class LoanProduct extends AbstractPersistableCustom {
private static void assembleRepaymentVariations(final JsonCommand command, private static void assembleRepaymentVariations(final JsonCommand command,
final Set<LoanProductBorrowerCycleVariations> loanProductBorrowerCycleVariations) { final Set<LoanProductBorrowerCycleVariations> loanProductBorrowerCycleVariations) {
assembleVaritions(command, loanProductBorrowerCycleVariations, LoanProductParamType.REPAYMENT.getValue(), assembleVaritions(command, loanProductBorrowerCycleVariations, LoanProductParamType.REPAYMENT.getValue(),
LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName); LoanProductConstants.NUMBER_OF_REPAYMENT_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME);
} }
@@ -411,7 +411,7 @@ public class LoanProduct extends AbstractPersistableCustom {
private static void assemblePrincipalVariations(final JsonCommand command, private static void assemblePrincipalVariations(final JsonCommand command,
final Set<LoanProductBorrowerCycleVariations> loanProductBorrowerCycleVariations) { final Set<LoanProductBorrowerCycleVariations> loanProductBorrowerCycleVariations) {
assembleVaritions(command, loanProductBorrowerCycleVariations, LoanProductParamType.PRINCIPAL.getValue(), assembleVaritions(command, loanProductBorrowerCycleVariations, LoanProductParamType.PRINCIPAL.getValue(),
LoanProductConstants.principalVariationsForBorrowerCycleParameterName); LoanProductConstants.PRINCIPAL_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME);
} }
private static void assembleVaritions(final JsonCommand command, private static void assembleVaritions(final JsonCommand command,
@@ -428,27 +428,27 @@ public class LoanProduct extends AbstractPersistableCustom {
BigDecimal maxValue = null; BigDecimal maxValue = null;
Integer cycleNumber = null; Integer cycleNumber = null;
Integer valueUsageCondition = null; Integer valueUsageCondition = null;
if (jsonObject.has(LoanProductConstants.defaultValueParameterName) if (jsonObject.has(LoanProductConstants.DEFAULT_VALUE_PARAMETER_NAME)
&& jsonObject.get(LoanProductConstants.defaultValueParameterName).isJsonPrimitive()) { && jsonObject.get(LoanProductConstants.DEFAULT_VALUE_PARAMETER_NAME).isJsonPrimitive()) {
defaultValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.defaultValueParameterName).getAsBigDecimal(); defaultValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.DEFAULT_VALUE_PARAMETER_NAME).getAsBigDecimal();
} }
if (jsonObject.has(LoanProductConstants.minValueParameterName) if (jsonObject.has(LoanProductConstants.MIN_VALUE_PARAMETER_NAME)
&& jsonObject.get(LoanProductConstants.minValueParameterName).isJsonPrimitive() && jsonObject.get(LoanProductConstants.MIN_VALUE_PARAMETER_NAME).isJsonPrimitive()
&& StringUtils.isNotBlank(jsonObject.get(LoanProductConstants.minValueParameterName).getAsString())) { && StringUtils.isNotBlank(jsonObject.get(LoanProductConstants.MIN_VALUE_PARAMETER_NAME).getAsString())) {
minValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.minValueParameterName).getAsBigDecimal(); minValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.MIN_VALUE_PARAMETER_NAME).getAsBigDecimal();
} }
if (jsonObject.has(LoanProductConstants.maxValueParameterName) if (jsonObject.has(LoanProductConstants.MAX_VALUE_PARAMETER_NAME)
&& jsonObject.get(LoanProductConstants.maxValueParameterName).isJsonPrimitive() && jsonObject.get(LoanProductConstants.MAX_VALUE_PARAMETER_NAME).isJsonPrimitive()
&& StringUtils.isNotBlank(jsonObject.get(LoanProductConstants.maxValueParameterName).getAsString())) { && StringUtils.isNotBlank(jsonObject.get(LoanProductConstants.MAX_VALUE_PARAMETER_NAME).getAsString())) {
maxValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.maxValueParameterName).getAsBigDecimal(); maxValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.MAX_VALUE_PARAMETER_NAME).getAsBigDecimal();
} }
if (jsonObject.has(LoanProductConstants.borrowerCycleNumberParamName) if (jsonObject.has(LoanProductConstants.BORROWER_CYCLE_NUMBER_PARAM_NAME)
&& jsonObject.get(LoanProductConstants.borrowerCycleNumberParamName).isJsonPrimitive()) { && jsonObject.get(LoanProductConstants.BORROWER_CYCLE_NUMBER_PARAM_NAME).isJsonPrimitive()) {
cycleNumber = jsonObject.getAsJsonPrimitive(LoanProductConstants.borrowerCycleNumberParamName).getAsInt(); cycleNumber = jsonObject.getAsJsonPrimitive(LoanProductConstants.BORROWER_CYCLE_NUMBER_PARAM_NAME).getAsInt();
} }
if (jsonObject.has(LoanProductConstants.valueConditionTypeParamName) if (jsonObject.has(LoanProductConstants.VALUE_CONDITION_TYPE_PARAM_NAME)
&& jsonObject.get(LoanProductConstants.valueConditionTypeParamName).isJsonPrimitive()) { && jsonObject.get(LoanProductConstants.VALUE_CONDITION_TYPE_PARAM_NAME).isJsonPrimitive()) {
valueUsageCondition = jsonObject.getAsJsonPrimitive(LoanProductConstants.valueConditionTypeParamName).getAsInt(); valueUsageCondition = jsonObject.getAsJsonPrimitive(LoanProductConstants.VALUE_CONDITION_TYPE_PARAM_NAME).getAsInt();
} }
LoanProductBorrowerCycleVariations borrowerCycleVariations = new LoanProductBorrowerCycleVariations(cycleNumber, LoanProductBorrowerCycleVariations borrowerCycleVariations = new LoanProductBorrowerCycleVariations(cycleNumber,
paramType, valueUsageCondition, minValue, maxValue, defaultValue); paramType, valueUsageCondition, minValue, maxValue, defaultValue);
@@ -463,11 +463,11 @@ public class LoanProduct extends AbstractPersistableCustom {
final Map<String, Object> actualChanges = new LinkedHashMap<>(20); final Map<String, Object> actualChanges = new LinkedHashMap<>(20);
List<Long> variationIds = fetchAllVariationIds(); List<Long> variationIds = fetchAllVariationIds();
updateBorrowerCycleVaritions(command, LoanProductParamType.PRINCIPAL.getValue(), updateBorrowerCycleVaritions(command, LoanProductParamType.PRINCIPAL.getValue(),
LoanProductConstants.principalVariationsForBorrowerCycleParameterName, actualChanges, variationIds); LoanProductConstants.PRINCIPAL_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME, actualChanges, variationIds);
updateBorrowerCycleVaritions(command, LoanProductParamType.INTERESTRATE.getValue(), updateBorrowerCycleVaritions(command, LoanProductParamType.INTERESTRATE.getValue(),
LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName, actualChanges, variationIds); LoanProductConstants.INTEREST_RATE_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME, actualChanges, variationIds);
updateBorrowerCycleVaritions(command, LoanProductParamType.REPAYMENT.getValue(), updateBorrowerCycleVaritions(command, LoanProductParamType.REPAYMENT.getValue(),
LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName, actualChanges, variationIds); LoanProductConstants.NUMBER_OF_REPAYMENT_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME, actualChanges, variationIds);
for (Long id : variationIds) { for (Long id : variationIds) {
this.borrowerCycleVariations.remove(fetchLoanProductBorrowerCycleVariationById(id)); this.borrowerCycleVariations.remove(fetchLoanProductBorrowerCycleVariationById(id));
} }
@@ -496,32 +496,32 @@ public class LoanProduct extends AbstractPersistableCustom {
Integer cycleNumber = null; Integer cycleNumber = null;
Integer valueUsageCondition = null; Integer valueUsageCondition = null;
Long id = null; Long id = null;
if (jsonObject.has(LoanProductConstants.defaultValueParameterName) if (jsonObject.has(LoanProductConstants.DEFAULT_VALUE_PARAMETER_NAME)
&& jsonObject.get(LoanProductConstants.defaultValueParameterName).isJsonPrimitive()) { && jsonObject.get(LoanProductConstants.DEFAULT_VALUE_PARAMETER_NAME).isJsonPrimitive()) {
defaultValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.defaultValueParameterName).getAsBigDecimal(); defaultValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.DEFAULT_VALUE_PARAMETER_NAME).getAsBigDecimal();
} }
if (jsonObject.has(LoanProductConstants.minValueParameterName) if (jsonObject.has(LoanProductConstants.MIN_VALUE_PARAMETER_NAME)
&& jsonObject.get(LoanProductConstants.minValueParameterName).isJsonPrimitive() && jsonObject.get(LoanProductConstants.MIN_VALUE_PARAMETER_NAME).isJsonPrimitive()
&& StringUtils.isNotBlank(jsonObject.get(LoanProductConstants.minValueParameterName).getAsString())) { && StringUtils.isNotBlank(jsonObject.get(LoanProductConstants.MIN_VALUE_PARAMETER_NAME).getAsString())) {
minValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.minValueParameterName).getAsBigDecimal(); minValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.MIN_VALUE_PARAMETER_NAME).getAsBigDecimal();
} }
if (jsonObject.has(LoanProductConstants.maxValueParameterName) if (jsonObject.has(LoanProductConstants.MAX_VALUE_PARAMETER_NAME)
&& jsonObject.get(LoanProductConstants.maxValueParameterName).isJsonPrimitive() && jsonObject.get(LoanProductConstants.MAX_VALUE_PARAMETER_NAME).isJsonPrimitive()
&& StringUtils.isNotBlank(jsonObject.get(LoanProductConstants.maxValueParameterName).getAsString())) { && StringUtils.isNotBlank(jsonObject.get(LoanProductConstants.MAX_VALUE_PARAMETER_NAME).getAsString())) {
maxValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.maxValueParameterName).getAsBigDecimal(); maxValue = jsonObject.getAsJsonPrimitive(LoanProductConstants.MAX_VALUE_PARAMETER_NAME).getAsBigDecimal();
} }
if (jsonObject.has(LoanProductConstants.borrowerCycleNumberParamName) if (jsonObject.has(LoanProductConstants.BORROWER_CYCLE_NUMBER_PARAM_NAME)
&& jsonObject.get(LoanProductConstants.borrowerCycleNumberParamName).isJsonPrimitive()) { && jsonObject.get(LoanProductConstants.BORROWER_CYCLE_NUMBER_PARAM_NAME).isJsonPrimitive()) {
cycleNumber = jsonObject.getAsJsonPrimitive(LoanProductConstants.borrowerCycleNumberParamName).getAsInt(); cycleNumber = jsonObject.getAsJsonPrimitive(LoanProductConstants.BORROWER_CYCLE_NUMBER_PARAM_NAME).getAsInt();
} }
if (jsonObject.has(LoanProductConstants.valueConditionTypeParamName) if (jsonObject.has(LoanProductConstants.VALUE_CONDITION_TYPE_PARAM_NAME)
&& jsonObject.get(LoanProductConstants.valueConditionTypeParamName).isJsonPrimitive()) { && jsonObject.get(LoanProductConstants.VALUE_CONDITION_TYPE_PARAM_NAME).isJsonPrimitive()) {
valueUsageCondition = jsonObject.getAsJsonPrimitive(LoanProductConstants.valueConditionTypeParamName).getAsInt(); valueUsageCondition = jsonObject.getAsJsonPrimitive(LoanProductConstants.VALUE_CONDITION_TYPE_PARAM_NAME).getAsInt();
} }
if (jsonObject.has(LoanProductConstants.borrowerCycleIdParameterName) if (jsonObject.has(LoanProductConstants.BORROWER_CYCLE_ID_PARAMETER_NAME)
&& jsonObject.get(LoanProductConstants.borrowerCycleIdParameterName).isJsonPrimitive() && jsonObject.get(LoanProductConstants.BORROWER_CYCLE_ID_PARAMETER_NAME).isJsonPrimitive()
&& StringUtils.isNotBlank(jsonObject.get(LoanProductConstants.borrowerCycleIdParameterName).getAsString())) { && StringUtils.isNotBlank(jsonObject.get(LoanProductConstants.BORROWER_CYCLE_ID_PARAMETER_NAME).getAsString())) {
id = jsonObject.getAsJsonPrimitive(LoanProductConstants.borrowerCycleIdParameterName).getAsLong(); id = jsonObject.getAsJsonPrimitive(LoanProductConstants.BORROWER_CYCLE_ID_PARAMETER_NAME).getAsLong();
} }
LoanProductBorrowerCycleVariations borrowerCycleVariations = new LoanProductBorrowerCycleVariations(cycleNumber, LoanProductBorrowerCycleVariations borrowerCycleVariations = new LoanProductBorrowerCycleVariations(cycleNumber,
paramType, valueUsageCondition, minValue, maxValue, defaultValue); paramType, valueUsageCondition, minValue, maxValue, defaultValue);
@@ -790,7 +790,7 @@ public class LoanProduct extends AbstractPersistableCustom {
this.name = newValue; this.name = newValue;
} }
final String shortNameParamName = LoanProductConstants.shortName; final String shortNameParamName = LoanProductConstants.SHORT_NAME;
if (command.isChangeInStringParameterNamed(shortNameParamName, this.shortName)) { if (command.isChangeInStringParameterNamed(shortNameParamName, this.shortName)) {
final String newValue = command.stringValueOfParameterNamed(shortNameParamName); final String newValue = command.stringValueOfParameterNamed(shortNameParamName);
actualChanges.put(shortNameParamName, newValue); actualChanges.put(shortNameParamName, newValue);
@@ -839,9 +839,9 @@ public class LoanProduct extends AbstractPersistableCustom {
this.includeInBorrowerCycle = newValue; this.includeInBorrowerCycle = newValue;
} }
if (command.isChangeInBooleanParameterNamed(LoanProductConstants.useBorrowerCycleParameterName, this.useBorrowerCycle)) { if (command.isChangeInBooleanParameterNamed(LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME, this.useBorrowerCycle)) {
final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.useBorrowerCycleParameterName); final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME);
actualChanges.put(LoanProductConstants.useBorrowerCycleParameterName, newValue); actualChanges.put(LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME, newValue);
this.useBorrowerCycle = newValue; this.useBorrowerCycle = newValue;
} }
@@ -894,18 +894,18 @@ public class LoanProduct extends AbstractPersistableCustom {
} }
loanProducTrancheDetails.update(command, actualChanges, localeAsInput); loanProducTrancheDetails.update(command, actualChanges, localeAsInput);
if (command.isChangeInIntegerParameterNamed(LoanProductConstants.overdueDaysForNPAParameterName, this.overdueDaysForNPA)) { if (command.isChangeInIntegerParameterNamed(LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME, this.overdueDaysForNPA)) {
final Integer newValue = command.integerValueOfParameterNamed(LoanProductConstants.overdueDaysForNPAParameterName); final Integer newValue = command.integerValueOfParameterNamed(LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME);
actualChanges.put(LoanProductConstants.overdueDaysForNPAParameterName, newValue); actualChanges.put(LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME, newValue);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
this.overdueDaysForNPA = newValue; this.overdueDaysForNPA = newValue;
} }
if (command.isChangeInIntegerParameterNamed(LoanProductConstants.minimumDaysBetweenDisbursalAndFirstRepayment, if (command.isChangeInIntegerParameterNamed(LoanProductConstants.MINIMUM_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT,
this.minimumDaysBetweenDisbursalAndFirstRepayment)) { this.minimumDaysBetweenDisbursalAndFirstRepayment)) {
final Integer newValue = command final Integer newValue = command
.integerValueOfParameterNamed(LoanProductConstants.minimumDaysBetweenDisbursalAndFirstRepayment); .integerValueOfParameterNamed(LoanProductConstants.MINIMUM_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT);
actualChanges.put(LoanProductConstants.minimumDaysBetweenDisbursalAndFirstRepayment, newValue); actualChanges.put(LoanProductConstants.MINIMUM_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT, newValue);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
this.minimumDaysBetweenDisbursalAndFirstRepayment = newValue; this.minimumDaysBetweenDisbursalAndFirstRepayment = newValue;
} }
@@ -921,7 +921,7 @@ public class LoanProduct extends AbstractPersistableCustom {
* Update interest recalculation settings * Update interest recalculation settings
*/ */
final boolean isInterestRecalculationEnabledChanged = actualChanges final boolean isInterestRecalculationEnabledChanged = actualChanges
.containsKey(LoanProductConstants.isInterestRecalculationEnabledParameterName); .containsKey(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME);
if (isInterestRecalculationEnabledChanged) { if (isInterestRecalculationEnabledChanged) {
if (this.isInterestRecalculationEnabled()) { if (this.isInterestRecalculationEnabled()) {
@@ -1008,11 +1008,11 @@ public class LoanProduct extends AbstractPersistableCustom {
} }
if (command.parsedJson().getAsJsonObject().getAsJsonObject(LoanProductConstants.allowAttributeOverridesParamName) if (command.parsedJson().getAsJsonObject().getAsJsonObject(LoanProductConstants.allowAttributeOverridesParamName)
.getAsJsonPrimitive(LoanProductConstants.graceOnArrearsAgeingParameterName).getAsBoolean() != this.loanConfigurableAttributes .getAsJsonPrimitive(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME).getAsBoolean() != this.loanConfigurableAttributes
.getGraceOnArrearsAgingBoolean()) { .getGraceOnArrearsAgingBoolean()) {
this.loanConfigurableAttributes.setGraceOnArrearsAgeing(command.parsedJson().getAsJsonObject() this.loanConfigurableAttributes.setGraceOnArrearsAgeing(command.parsedJson().getAsJsonObject()
.getAsJsonObject(LoanProductConstants.allowAttributeOverridesParamName) .getAsJsonObject(LoanProductConstants.allowAttributeOverridesParamName)
.getAsJsonPrimitive(LoanProductConstants.graceOnArrearsAgeingParameterName).getAsBoolean()); .getAsJsonPrimitive(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME).getAsBoolean());
} }
} else { } else {
this.loanConfigurableAttributes = LoanProductConfigurableAttributes.populateDefaultsForConfigurableAttributes(); this.loanConfigurableAttributes = LoanProductConfigurableAttributes.populateDefaultsForConfigurableAttributes();
@@ -1045,11 +1045,11 @@ public class LoanProduct extends AbstractPersistableCustom {
actualChanges.put(LoanProductConstants.principalThresholdForLastInstallmentParamName, newValue); actualChanges.put(LoanProductConstants.principalThresholdForLastInstallmentParamName, newValue);
this.principalThresholdForLastInstallment = newValue; this.principalThresholdForLastInstallment = newValue;
} }
if (command.isChangeInBooleanParameterNamed(LoanProductConstants.accountMovesOutOfNPAOnlyOnArrearsCompletionParamName, if (command.isChangeInBooleanParameterNamed(LoanProductConstants.ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME,
this.accountMovesOutOfNPAOnlyOnArrearsCompletion)) { this.accountMovesOutOfNPAOnlyOnArrearsCompletion)) {
final boolean newValue = command final boolean newValue = command
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.accountMovesOutOfNPAOnlyOnArrearsCompletionParamName); .booleanPrimitiveValueOfParameterNamed(LoanProductConstants.ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME);
actualChanges.put(LoanProductConstants.accountMovesOutOfNPAOnlyOnArrearsCompletionParamName, newValue); actualChanges.put(LoanProductConstants.ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME, newValue);
this.accountMovesOutOfNPAOnlyOnArrearsCompletion = newValue; this.accountMovesOutOfNPAOnlyOnArrearsCompletion = newValue;
} }
if (command.isChangeInBooleanParameterNamed(LoanProductConstants.canDefineEmiAmountParamName, this.canDefineInstallmentAmount)) { if (command.isChangeInBooleanParameterNamed(LoanProductConstants.canDefineEmiAmountParamName, this.canDefineInstallmentAmount)) {
@@ -1066,16 +1066,16 @@ public class LoanProduct extends AbstractPersistableCustom {
this.installmentAmountInMultiplesOf = newValue; this.installmentAmountInMultiplesOf = newValue;
} }
if (command.isChangeInBooleanParameterNamed(LoanProductConstants.canUseForTopup, this.canUseForTopup)) { if (command.isChangeInBooleanParameterNamed(LoanProductConstants.CAN_USE_FOR_TOPUP, this.canUseForTopup)) {
final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.canUseForTopup); final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.CAN_USE_FOR_TOPUP);
actualChanges.put(LoanProductConstants.canUseForTopup, newValue); actualChanges.put(LoanProductConstants.CAN_USE_FOR_TOPUP, newValue);
this.canUseForTopup = newValue; this.canUseForTopup = newValue;
} }
if (command.hasParameter(LoanProductConstants.ratesParamName)) { if (command.hasParameter(LoanProductConstants.RATES_PARAM_NAME)) {
final JsonArray jsonArray = command.arrayOfParameterNamed(LoanProductConstants.ratesParamName); final JsonArray jsonArray = command.arrayOfParameterNamed(LoanProductConstants.RATES_PARAM_NAME);
if (jsonArray != null) { if (jsonArray != null) {
actualChanges.put(LoanProductConstants.ratesParamName, command.jsonFragment(LoanProductConstants.ratesParamName)); actualChanges.put(LoanProductConstants.RATES_PARAM_NAME, command.jsonFragment(LoanProductConstants.RATES_PARAM_NAME));
} }
} }
@@ -1236,29 +1236,29 @@ public class LoanProduct extends AbstractPersistableCustom {
public Map<String, BigDecimal> fetchBorrowerCycleVariationsForCycleNumber(final Integer cycleNumber) { public Map<String, BigDecimal> fetchBorrowerCycleVariationsForCycleNumber(final Integer cycleNumber) {
Map<String, BigDecimal> borrowerCycleVariations = new HashMap<>(); Map<String, BigDecimal> borrowerCycleVariations = new HashMap<>();
borrowerCycleVariations.put(LoanProductConstants.principal, this.loanProductRelatedDetail.getPrincipal().getAmount()); borrowerCycleVariations.put(LoanProductConstants.PRINCIPAL, this.loanProductRelatedDetail.getPrincipal().getAmount());
borrowerCycleVariations.put(LoanProductConstants.interestRatePerPeriod, borrowerCycleVariations.put(LoanProductConstants.INTEREST_RATE_PER_PERIOD,
this.loanProductRelatedDetail.getNominalInterestRatePerPeriod()); this.loanProductRelatedDetail.getNominalInterestRatePerPeriod());
if (this.loanProductRelatedDetail.getNumberOfRepayments() != null) { if (this.loanProductRelatedDetail.getNumberOfRepayments() != null) {
borrowerCycleVariations.put(LoanProductConstants.numberOfRepayments, borrowerCycleVariations.put(LoanProductConstants.MAX_INTEREST_RATE_PER_PERIOD,
BigDecimal.valueOf(this.loanProductRelatedDetail.getNumberOfRepayments())); BigDecimal.valueOf(this.loanProductRelatedDetail.getNumberOfRepayments()));
} }
if (this.loanProductMinMaxConstraints != null) { if (this.loanProductMinMaxConstraints != null) {
borrowerCycleVariations.put(LoanProductConstants.minPrincipal, this.loanProductMinMaxConstraints.getMinPrincipal()); borrowerCycleVariations.put(LoanProductConstants.MIN_PRINCIPAL, this.loanProductMinMaxConstraints.getMinPrincipal());
borrowerCycleVariations.put(LoanProductConstants.maxPrincipal, this.loanProductMinMaxConstraints.getMaxPrincipal()); borrowerCycleVariations.put(LoanProductConstants.MAX_PRINCIPAL, this.loanProductMinMaxConstraints.getMaxPrincipal());
borrowerCycleVariations.put(LoanProductConstants.minInterestRatePerPeriod, borrowerCycleVariations.put(LoanProductConstants.MIN_INTEREST_RATE_PER_PERIOD,
this.loanProductMinMaxConstraints.getMinNominalInterestRatePerPeriod()); this.loanProductMinMaxConstraints.getMinNominalInterestRatePerPeriod());
borrowerCycleVariations.put(LoanProductConstants.maxInterestRatePerPeriod, borrowerCycleVariations.put(LoanProductConstants.MAX_INTEREST_RATE_PER_PERIOD,
this.loanProductMinMaxConstraints.getMaxNominalInterestRatePerPeriod()); this.loanProductMinMaxConstraints.getMaxNominalInterestRatePerPeriod());
if (this.loanProductMinMaxConstraints.getMinNumberOfRepayments() != null) { if (this.loanProductMinMaxConstraints.getMinNumberOfRepayments() != null) {
borrowerCycleVariations.put(LoanProductConstants.minNumberOfRepayments, borrowerCycleVariations.put(LoanProductConstants.MIN_NUMBER_OF_REPAYMENTS,
BigDecimal.valueOf(this.loanProductMinMaxConstraints.getMinNumberOfRepayments())); BigDecimal.valueOf(this.loanProductMinMaxConstraints.getMinNumberOfRepayments()));
} }
if (this.loanProductMinMaxConstraints.getMaxNumberOfRepayments() != null) { if (this.loanProductMinMaxConstraints.getMaxNumberOfRepayments() != null) {
borrowerCycleVariations.put(LoanProductConstants.maxNumberOfRepayments, borrowerCycleVariations.put(LoanProductConstants.MAX_NUMBER_OF_REPAYMENTS,
BigDecimal.valueOf(this.loanProductMinMaxConstraints.getMaxNumberOfRepayments())); BigDecimal.valueOf(this.loanProductMinMaxConstraints.getMaxNumberOfRepayments()));
} }
} }
@@ -1271,21 +1271,21 @@ public class LoanProduct extends AbstractPersistableCustom {
&& cycleVariation.getValueConditionType().equals(LoanProductValueConditionType.EQUAL)) { && cycleVariation.getValueConditionType().equals(LoanProductValueConditionType.EQUAL)) {
switch (cycleVariation.getParamType()) { switch (cycleVariation.getParamType()) {
case PRINCIPAL: case PRINCIPAL:
borrowerCycleVariations.put(LoanProductConstants.principal, cycleVariation.getDefaultValue()); borrowerCycleVariations.put(LoanProductConstants.PRINCIPAL, cycleVariation.getDefaultValue());
borrowerCycleVariations.put(LoanProductConstants.minPrincipal, cycleVariation.getMinValue()); borrowerCycleVariations.put(LoanProductConstants.MIN_PRINCIPAL, cycleVariation.getMinValue());
borrowerCycleVariations.put(LoanProductConstants.maxPrincipal, cycleVariation.getMaxValue()); borrowerCycleVariations.put(LoanProductConstants.MAX_PRINCIPAL, cycleVariation.getMaxValue());
principalCycleUsed = cycleVariation.getBorrowerCycleNumber(); principalCycleUsed = cycleVariation.getBorrowerCycleNumber();
break; break;
case INTERESTRATE: case INTERESTRATE:
borrowerCycleVariations.put(LoanProductConstants.interestRatePerPeriod, cycleVariation.getDefaultValue()); borrowerCycleVariations.put(LoanProductConstants.INTEREST_RATE_PER_PERIOD, cycleVariation.getDefaultValue());
borrowerCycleVariations.put(LoanProductConstants.minInterestRatePerPeriod, cycleVariation.getMinValue()); borrowerCycleVariations.put(LoanProductConstants.MIN_INTEREST_RATE_PER_PERIOD, cycleVariation.getMinValue());
borrowerCycleVariations.put(LoanProductConstants.maxInterestRatePerPeriod, cycleVariation.getMaxValue()); borrowerCycleVariations.put(LoanProductConstants.MAX_INTEREST_RATE_PER_PERIOD, cycleVariation.getMaxValue());
interestCycleUsed = cycleVariation.getBorrowerCycleNumber(); interestCycleUsed = cycleVariation.getBorrowerCycleNumber();
break; break;
case REPAYMENT: case REPAYMENT:
borrowerCycleVariations.put(LoanProductConstants.numberOfRepayments, cycleVariation.getDefaultValue()); borrowerCycleVariations.put(LoanProductConstants.MAX_INTEREST_RATE_PER_PERIOD, cycleVariation.getDefaultValue());
borrowerCycleVariations.put(LoanProductConstants.minNumberOfRepayments, cycleVariation.getMinValue()); borrowerCycleVariations.put(LoanProductConstants.MIN_NUMBER_OF_REPAYMENTS, cycleVariation.getMinValue());
borrowerCycleVariations.put(LoanProductConstants.maxNumberOfRepayments, cycleVariation.getMaxValue()); borrowerCycleVariations.put(LoanProductConstants.MAX_NUMBER_OF_REPAYMENTS, cycleVariation.getMaxValue());
repaymentCycleUsed = cycleVariation.getBorrowerCycleNumber(); repaymentCycleUsed = cycleVariation.getBorrowerCycleNumber();
break; break;
default: default:
@@ -1296,25 +1296,25 @@ public class LoanProduct extends AbstractPersistableCustom {
switch (cycleVariation.getParamType()) { switch (cycleVariation.getParamType()) {
case PRINCIPAL: case PRINCIPAL:
if (principalCycleUsed < cycleVariation.getBorrowerCycleNumber()) { if (principalCycleUsed < cycleVariation.getBorrowerCycleNumber()) {
borrowerCycleVariations.put(LoanProductConstants.principal, cycleVariation.getDefaultValue()); borrowerCycleVariations.put(LoanProductConstants.PRINCIPAL, cycleVariation.getDefaultValue());
borrowerCycleVariations.put(LoanProductConstants.minPrincipal, cycleVariation.getMinValue()); borrowerCycleVariations.put(LoanProductConstants.MIN_PRINCIPAL, cycleVariation.getMinValue());
borrowerCycleVariations.put(LoanProductConstants.maxPrincipal, cycleVariation.getMaxValue()); borrowerCycleVariations.put(LoanProductConstants.MAX_PRINCIPAL, cycleVariation.getMaxValue());
principalCycleUsed = cycleVariation.getBorrowerCycleNumber(); principalCycleUsed = cycleVariation.getBorrowerCycleNumber();
} }
break; break;
case INTERESTRATE: case INTERESTRATE:
if (interestCycleUsed < cycleVariation.getBorrowerCycleNumber()) { if (interestCycleUsed < cycleVariation.getBorrowerCycleNumber()) {
borrowerCycleVariations.put(LoanProductConstants.interestRatePerPeriod, cycleVariation.getDefaultValue()); borrowerCycleVariations.put(LoanProductConstants.INTEREST_RATE_PER_PERIOD, cycleVariation.getDefaultValue());
borrowerCycleVariations.put(LoanProductConstants.minInterestRatePerPeriod, cycleVariation.getMinValue()); borrowerCycleVariations.put(LoanProductConstants.MIN_INTEREST_RATE_PER_PERIOD, cycleVariation.getMinValue());
borrowerCycleVariations.put(LoanProductConstants.maxInterestRatePerPeriod, cycleVariation.getMaxValue()); borrowerCycleVariations.put(LoanProductConstants.MAX_INTEREST_RATE_PER_PERIOD, cycleVariation.getMaxValue());
interestCycleUsed = cycleVariation.getBorrowerCycleNumber(); interestCycleUsed = cycleVariation.getBorrowerCycleNumber();
} }
break; break;
case REPAYMENT: case REPAYMENT:
if (repaymentCycleUsed < cycleVariation.getBorrowerCycleNumber()) { if (repaymentCycleUsed < cycleVariation.getBorrowerCycleNumber()) {
borrowerCycleVariations.put(LoanProductConstants.numberOfRepayments, cycleVariation.getDefaultValue()); borrowerCycleVariations.put(LoanProductConstants.MAX_INTEREST_RATE_PER_PERIOD, cycleVariation.getDefaultValue());
borrowerCycleVariations.put(LoanProductConstants.minNumberOfRepayments, cycleVariation.getMinValue()); borrowerCycleVariations.put(LoanProductConstants.MIN_NUMBER_OF_REPAYMENTS, cycleVariation.getMinValue());
borrowerCycleVariations.put(LoanProductConstants.maxNumberOfRepayments, cycleVariation.getMaxValue()); borrowerCycleVariations.put(LoanProductConstants.MAX_NUMBER_OF_REPAYMENTS, cycleVariation.getMaxValue());
repaymentCycleUsed = cycleVariation.getBorrowerCycleNumber(); repaymentCycleUsed = cycleVariation.getBorrowerCycleNumber();
} }
break; break;
@@ -66,7 +66,7 @@ public class LoanProductConfigurableAttributes extends AbstractPersistableCustom
LoanProductConstants.interestCalculationPeriodTypeParamName, LoanProductConstants.interestCalculationPeriodTypeParamName,
LoanProductConstants.inArrearsToleranceParamName, LoanProductConstants.repaymentEveryParamName, LoanProductConstants.inArrearsToleranceParamName, LoanProductConstants.repaymentEveryParamName,
LoanProductConstants.graceOnPrincipalAndInterestPaymentParamName, LoanProductConstants.graceOnPrincipalAndInterestPaymentParamName,
LoanProductConstants.graceOnArrearsAgeingParameterName}; LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME};
public static LoanProductConfigurableAttributes createFrom(JsonCommand command) { public static LoanProductConfigurableAttributes createFrom(JsonCommand command) {
@@ -93,7 +93,7 @@ public class LoanProductConfigurableAttributes extends AbstractPersistableCustom
.getAsJsonPrimitive(LoanProductConstants.graceOnPrincipalAndInterestPaymentParamName).getAsBoolean(); .getAsJsonPrimitive(LoanProductConstants.graceOnPrincipalAndInterestPaymentParamName).getAsBoolean();
final Boolean graceOnArrearsAging = command.parsedJson().getAsJsonObject() final Boolean graceOnArrearsAging = command.parsedJson().getAsJsonObject()
.getAsJsonObject(LoanProductConstants.allowAttributeOverridesParamName) .getAsJsonObject(LoanProductConstants.allowAttributeOverridesParamName)
.getAsJsonPrimitive(LoanProductConstants.graceOnArrearsAgeingParameterName).getAsBoolean(); .getAsJsonPrimitive(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME).getAsBoolean();
return new LoanProductConfigurableAttributes(amortization, interestMethod, transactionProcessingStrategy, interestCalcPeriod, return new LoanProductConfigurableAttributes(amortization, interestMethod, transactionProcessingStrategy, interestCalcPeriod,
arrearsTolerance, repaymentEvery, graceOnPrincipalAndInterestPayment, graceOnArrearsAging); arrearsTolerance, repaymentEvery, graceOnPrincipalAndInterestPayment, graceOnArrearsAging);
@@ -423,11 +423,11 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche
this.interestCalculationPeriodMethod = InterestCalculationPeriodMethod.fromInt(newValue); this.interestCalculationPeriodMethod = InterestCalculationPeriodMethod.fromInt(newValue);
} }
if (command.isChangeInBooleanParameterNamed(LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, if (command.isChangeInBooleanParameterNamed(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME,
this.allowPartialPeriodInterestCalcualtion)) { this.allowPartialPeriodInterestCalcualtion)) {
final boolean newValue = command final boolean newValue = command
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName); .booleanPrimitiveValueOfParameterNamed(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME);
actualChanges.put(LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, newValue); actualChanges.put(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, newValue);
this.allowPartialPeriodInterestCalcualtion = newValue; this.allowPartialPeriodInterestCalcualtion = newValue;
} }
@@ -467,38 +467,38 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche
this.graceOnInterestCharged = newValue; this.graceOnInterestCharged = newValue;
} }
if (command.isChangeInIntegerParameterNamed(LoanProductConstants.graceOnArrearsAgeingParameterName, this.graceOnArrearsAgeing)) { if (command.isChangeInIntegerParameterNamed(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME, this.graceOnArrearsAgeing)) {
final Integer newValue = command.integerValueOfParameterNamed(LoanProductConstants.graceOnArrearsAgeingParameterName); final Integer newValue = command.integerValueOfParameterNamed(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME);
actualChanges.put(LoanProductConstants.graceOnArrearsAgeingParameterName, newValue); actualChanges.put(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME, newValue);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
this.graceOnArrearsAgeing = newValue; this.graceOnArrearsAgeing = newValue;
} }
if (command.isChangeInIntegerParameterNamed(LoanProductConstants.daysInMonthTypeParameterName, this.daysInMonthType)) { if (command.isChangeInIntegerParameterNamed(LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME, this.daysInMonthType)) {
final Integer newValue = command.integerValueOfParameterNamed(LoanProductConstants.daysInMonthTypeParameterName); final Integer newValue = command.integerValueOfParameterNamed(LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME);
actualChanges.put(LoanProductConstants.daysInMonthTypeParameterName, newValue); actualChanges.put(LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME, newValue);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
this.daysInMonthType = newValue; this.daysInMonthType = newValue;
} }
if (command.isChangeInIntegerParameterNamed(LoanProductConstants.daysInYearTypeParameterName, this.daysInYearType)) { if (command.isChangeInIntegerParameterNamed(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME, this.daysInYearType)) {
final Integer newValue = command.integerValueOfParameterNamed(LoanProductConstants.daysInYearTypeParameterName); final Integer newValue = command.integerValueOfParameterNamed(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME);
actualChanges.put(LoanProductConstants.daysInYearTypeParameterName, newValue); actualChanges.put(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME, newValue);
actualChanges.put("locale", localeAsInput); actualChanges.put("locale", localeAsInput);
this.daysInYearType = newValue; this.daysInYearType = newValue;
} }
if (command.isChangeInBooleanParameterNamed(LoanProductConstants.isInterestRecalculationEnabledParameterName, if (command.isChangeInBooleanParameterNamed(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME,
this.isInterestRecalculationEnabled)) { this.isInterestRecalculationEnabled)) {
final boolean newValue = command final boolean newValue = command
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.isInterestRecalculationEnabledParameterName); .booleanPrimitiveValueOfParameterNamed(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME);
actualChanges.put(LoanProductConstants.isInterestRecalculationEnabledParameterName, newValue); actualChanges.put(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME, newValue);
this.isInterestRecalculationEnabled = newValue; this.isInterestRecalculationEnabled = newValue;
} }
if (command.isChangeInBooleanParameterNamed(LoanProductConstants.isEqualAmortizationParam, this.isEqualAmortization)) { if (command.isChangeInBooleanParameterNamed(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, this.isEqualAmortization)) {
final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.isEqualAmortizationParam); final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM);
actualChanges.put(LoanProductConstants.isEqualAmortizationParam, newValue); actualChanges.put(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, newValue);
this.isEqualAmortization = newValue; this.isEqualAmortization = newValue;
} }
@@ -48,25 +48,25 @@ public class LoanProductTrancheDetails {
} }
public void update(final JsonCommand command, final Map<String, Object> actualChanges, final String localeAsInput) { public void update(final JsonCommand command, final Map<String, Object> actualChanges, final String localeAsInput) {
if (command.isChangeInBooleanParameterNamed(LoanProductConstants.multiDisburseLoanParameterName, this.multiDisburseLoan)) { if (command.isChangeInBooleanParameterNamed(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME, this.multiDisburseLoan)) {
final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.multiDisburseLoanParameterName); final boolean newValue = command.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME);
actualChanges.put(LoanProductConstants.multiDisburseLoanParameterName, newValue); actualChanges.put(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME, newValue);
this.multiDisburseLoan = newValue; this.multiDisburseLoan = newValue;
} }
if (this.multiDisburseLoan) { if (this.multiDisburseLoan) {
if (command.isChangeInIntegerParameterNamed(LoanProductConstants.maxTrancheCountParameterName, this.maxTrancheCount)) { if (command.isChangeInIntegerParameterNamed(LoanProductConstants.MAX_TRANCHE_COUNT_PARAMETER_NAME, this.maxTrancheCount)) {
final Integer newValue = command.integerValueOfParameterNamed(LoanProductConstants.maxTrancheCountParameterName); final Integer newValue = command.integerValueOfParameterNamed(LoanProductConstants.MAX_TRANCHE_COUNT_PARAMETER_NAME);
actualChanges.put(LoanProductConstants.maxTrancheCountParameterName, newValue); actualChanges.put(LoanProductConstants.MAX_TRANCHE_COUNT_PARAMETER_NAME, newValue);
this.maxTrancheCount = newValue; this.maxTrancheCount = newValue;
} }
if (command.isChangeInBigDecimalParameterNamed(LoanProductConstants.outstandingLoanBalanceParameterName, if (command.isChangeInBigDecimalParameterNamed(LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME,
this.outstandingLoanBalance)) { this.outstandingLoanBalance)) {
final BigDecimal newValue = command final BigDecimal newValue = command
.bigDecimalValueOfParameterNamed(LoanProductConstants.outstandingLoanBalanceParameterName); .bigDecimalValueOfParameterNamed(LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME);
actualChanges.put(LoanProductConstants.outstandingLoanBalanceParameterName, newValue); actualChanges.put(LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME, newValue);
actualChanges.put(LoanProductConstants.outstandingLoanBalanceParameterName, localeAsInput); actualChanges.put(LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME, localeAsInput);
this.outstandingLoanBalance = newValue; this.outstandingLoanBalance = newValue;
} }
} else { } else {
@@ -64,7 +64,7 @@ public final class LoanProductDataValidator {
"currencyCode", "digitsAfterDecimal", "inMultiplesOf", "principal", "minPrincipal", "maxPrincipal", "repaymentEvery", "currencyCode", "digitsAfterDecimal", "inMultiplesOf", "principal", "minPrincipal", "maxPrincipal", "repaymentEvery",
"numberOfRepayments", "minNumberOfRepayments", "maxNumberOfRepayments", "repaymentFrequencyType", "interestRatePerPeriod", "numberOfRepayments", "minNumberOfRepayments", "maxNumberOfRepayments", "repaymentFrequencyType", "interestRatePerPeriod",
"minInterestRatePerPeriod", "maxInterestRatePerPeriod", "interestRateFrequencyType", "amortizationType", "interestType", "minInterestRatePerPeriod", "maxInterestRatePerPeriod", "interestRateFrequencyType", "amortizationType", "interestType",
"interestCalculationPeriodType", LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, "inArrearsTolerance", "interestCalculationPeriodType", LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, "inArrearsTolerance",
"transactionProcessingStrategyId", "graceOnPrincipalPayment", "recurringMoratoriumOnPrincipalPeriods", "graceOnInterestPayment", "graceOnInterestCharged", "charges", "transactionProcessingStrategyId", "graceOnPrincipalPayment", "recurringMoratoriumOnPrincipalPeriods", "graceOnInterestPayment", "graceOnInterestCharged", "charges",
"accountingRule", "includeInBorrowerCycle", "startDate", "closeDate", "externalId", "isLinkedToFloatingInterestRates", "accountingRule", "includeInBorrowerCycle", "startDate", "closeDate", "externalId", "isLinkedToFloatingInterestRates",
"floatingRatesId", "interestRateDifferential", "minDifferentialLendingRate", "defaultDifferentialLendingRate", "floatingRatesId", "interestRateDifferential", "minDifferentialLendingRate", "defaultDifferentialLendingRate",
@@ -78,14 +78,14 @@ public final class LoanProductDataValidator {
LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(), LoanProductAccountingParams.PAYMENT_CHANNEL_FUND_SOURCE_MAPPING.getValue(),
LoanProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue(), LoanProductAccountingParams.FEE_INCOME_ACCOUNT_MAPPING.getValue(),
LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(), LoanProductAccountingParams.INCOME_FROM_RECOVERY.getValue(),
LoanProductAccountingParams.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), LoanProductConstants.useBorrowerCycleParameterName, LoanProductAccountingParams.PENALTY_INCOME_ACCOUNT_MAPPING.getValue(), LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME,
LoanProductConstants.principalVariationsForBorrowerCycleParameterName, LoanProductConstants.PRINCIPAL_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME,
LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName, LoanProductConstants.INTEREST_RATE_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME,
LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName, LoanProductConstants.shortName, LoanProductConstants.NUMBER_OF_REPAYMENT_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME, LoanProductConstants.SHORT_NAME,
LoanProductConstants.multiDisburseLoanParameterName, LoanProductConstants.outstandingLoanBalanceParameterName, LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME, LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME,
LoanProductConstants.maxTrancheCountParameterName, LoanProductConstants.graceOnArrearsAgeingParameterName, LoanProductConstants.MAX_TRANCHE_COUNT_PARAMETER_NAME, LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME,
LoanProductConstants.overdueDaysForNPAParameterName, LoanProductConstants.isInterestRecalculationEnabledParameterName, LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME, LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME,
LoanProductConstants.daysInYearTypeParameterName, LoanProductConstants.daysInMonthTypeParameterName, LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME, LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME,
LoanProductConstants.rescheduleStrategyMethodParameterName, LoanProductConstants.rescheduleStrategyMethodParameterName,
LoanProductConstants.interestRecalculationCompoundingMethodParameterName, LoanProductConstants.interestRecalculationCompoundingMethodParameterName,
LoanProductConstants.recalculationRestFrequencyIntervalParameterName, LoanProductConstants.recalculationRestFrequencyIntervalParameterName,
@@ -93,10 +93,10 @@ public final class LoanProductDataValidator {
LoanProductConstants.recalculationCompoundingFrequencyIntervalParameterName, LoanProductConstants.recalculationCompoundingFrequencyIntervalParameterName,
LoanProductConstants.recalculationCompoundingFrequencyTypeParameterName, LoanProductConstants.recalculationCompoundingFrequencyTypeParameterName,
LoanProductConstants.isArrearsBasedOnOriginalScheduleParamName, LoanProductConstants.isArrearsBasedOnOriginalScheduleParamName,
LoanProductConstants.minimumDaysBetweenDisbursalAndFirstRepayment, LoanProductConstants.mandatoryGuaranteeParamName, LoanProductConstants.MINIMUM_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT, LoanProductConstants.mandatoryGuaranteeParamName,
LoanProductConstants.holdGuaranteeFundsParamName, LoanProductConstants.minimumGuaranteeFromGuarantorParamName, LoanProductConstants.holdGuaranteeFundsParamName, LoanProductConstants.minimumGuaranteeFromGuarantorParamName,
LoanProductConstants.minimumGuaranteeFromOwnFundsParamName, LoanProductConstants.principalThresholdForLastInstallmentParamName, LoanProductConstants.minimumGuaranteeFromOwnFundsParamName, LoanProductConstants.principalThresholdForLastInstallmentParamName,
LoanProductConstants.accountMovesOutOfNPAOnlyOnArrearsCompletionParamName, LoanProductConstants.canDefineEmiAmountParamName, LoanProductConstants.ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME, LoanProductConstants.canDefineEmiAmountParamName,
LoanProductConstants.installmentAmountInMultiplesOfParamName, LoanProductConstants.installmentAmountInMultiplesOfParamName,
LoanProductConstants.preClosureInterestCalculationStrategyParamName, LoanProductConstants.allowAttributeOverridesParamName, LoanProductConstants.preClosureInterestCalculationStrategyParamName, LoanProductConstants.allowAttributeOverridesParamName,
LoanProductConstants.allowVariableInstallmentsParamName, LoanProductConstants.minimumGapBetweenInstallments, LoanProductConstants.allowVariableInstallmentsParamName, LoanProductConstants.minimumGapBetweenInstallments,
@@ -106,15 +106,15 @@ public final class LoanProductDataValidator {
LoanProductConstants.recalculationRestFrequencyWeekdayParamName, LoanProductConstants.recalculationRestFrequencyWeekdayParamName,
LoanProductConstants.recalculationRestFrequencyNthDayParamName, LoanProductConstants.recalculationRestFrequencyOnDayParamName, LoanProductConstants.recalculationRestFrequencyNthDayParamName, LoanProductConstants.recalculationRestFrequencyOnDayParamName,
LoanProductConstants.isCompoundingToBePostedAsTransactionParamName, LoanProductConstants.allowCompoundingOnEodParamName, LoanProductConstants.isCompoundingToBePostedAsTransactionParamName, LoanProductConstants.allowCompoundingOnEodParamName,
LoanProductConstants.canUseForTopup, LoanProductConstants.isEqualAmortizationParam, LoanProductConstants.CAN_USE_FOR_TOPUP, LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM,
LoanProductConstants.ratesParamName)); LoanProductConstants.RATES_PARAM_NAME));
private static final String[] supportedloanConfigurableAttributes = {LoanProductConstants.amortizationTypeParamName, private static final String[] supportedloanConfigurableAttributes = {LoanProductConstants.amortizationTypeParamName,
LoanProductConstants.interestTypeParamName, LoanProductConstants.transactionProcessingStrategyIdParamName, LoanProductConstants.interestTypeParamName, LoanProductConstants.transactionProcessingStrategyIdParamName,
LoanProductConstants.interestCalculationPeriodTypeParamName, LoanProductConstants.interestCalculationPeriodTypeParamName,
LoanProductConstants.inArrearsToleranceParamName, LoanProductConstants.repaymentEveryParamName, LoanProductConstants.inArrearsToleranceParamName, LoanProductConstants.repaymentEveryParamName,
LoanProductConstants.graceOnPrincipalAndInterestPaymentParamName, LoanProductConstants.graceOnPrincipalAndInterestPaymentParamName,
LoanProductConstants.graceOnArrearsAgeingParameterName}; LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME};
private final FromJsonHelper fromApiJsonHelper; private final FromJsonHelper fromApiJsonHelper;
@@ -137,8 +137,8 @@ public final class LoanProductDataValidator {
final String name = this.fromApiJsonHelper.extractStringNamed("name", element); final String name = this.fromApiJsonHelper.extractStringNamed("name", element);
baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100); baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100);
final String shortName = this.fromApiJsonHelper.extractStringNamed(LoanProductConstants.shortName, element); final String shortName = this.fromApiJsonHelper.extractStringNamed(LoanProductConstants.SHORT_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.shortName).value(shortName).notBlank().notExceedingLengthOf(4); baseDataValidator.reset().parameter(LoanProductConstants.SHORT_NAME).value(shortName).notBlank().notExceedingLengthOf(4);
final String description = this.fromApiJsonHelper.extractStringNamed("description", element); final String description = this.fromApiJsonHelper.extractStringNamed("description", element);
baseDataValidator.reset().parameter("description").value(description).notExceedingLengthOf(500); baseDataValidator.reset().parameter("description").value(description).notExceedingLengthOf(500);
@@ -149,16 +149,16 @@ public final class LoanProductDataValidator {
} }
boolean isEqualAmortization = false; boolean isEqualAmortization = false;
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.isEqualAmortizationParam, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, element)) {
isEqualAmortization = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.isEqualAmortizationParam, element); isEqualAmortization = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, element);
baseDataValidator.reset().parameter(LoanProductConstants.isEqualAmortizationParam).value(isEqualAmortization).ignoreIfNull() baseDataValidator.reset().parameter(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM).value(isEqualAmortization).ignoreIfNull()
.validateForBooleanValue(); .validateForBooleanValue();
} }
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.minimumDaysBetweenDisbursalAndFirstRepayment, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.MINIMUM_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT, element)) {
final Long minimumDaysBetweenDisbursalAndFirstRepayment = this.fromApiJsonHelper.extractLongNamed( final Long minimumDaysBetweenDisbursalAndFirstRepayment = this.fromApiJsonHelper.extractLongNamed(
LoanProductConstants.minimumDaysBetweenDisbursalAndFirstRepayment, element); LoanProductConstants.MINIMUM_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT, element);
baseDataValidator.reset().parameter(LoanProductConstants.minimumDaysBetweenDisbursalAndFirstRepayment) baseDataValidator.reset().parameter(LoanProductConstants.MINIMUM_DAYS_BETWEEN_DISBURSAL_AND_FIRST_REPAYMENT)
.value(minimumDaysBetweenDisbursalAndFirstRepayment).ignoreIfNull().integerGreaterThanZero(); .value(minimumDaysBetweenDisbursalAndFirstRepayment).ignoreIfNull().integerGreaterThanZero();
} }
@@ -280,42 +280,42 @@ public final class LoanProductDataValidator {
baseDataValidator.reset().parameter("graceOnInterestCharged").value(graceOnInterestCharged).zeroOrPositiveAmount(); baseDataValidator.reset().parameter("graceOnInterestCharged").value(graceOnInterestCharged).zeroOrPositiveAmount();
final Integer graceOnArrearsAgeing = this.fromApiJsonHelper.extractIntegerWithLocaleNamed( final Integer graceOnArrearsAgeing = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(
LoanProductConstants.graceOnArrearsAgeingParameterName, element); LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.graceOnArrearsAgeingParameterName).value(graceOnArrearsAgeing) baseDataValidator.reset().parameter(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME).value(graceOnArrearsAgeing)
.integerZeroOrGreater(); .integerZeroOrGreater();
final Integer overdueDaysForNPA = this.fromApiJsonHelper.extractIntegerWithLocaleNamed( final Integer overdueDaysForNPA = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(
LoanProductConstants.overdueDaysForNPAParameterName, element); LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.overdueDaysForNPAParameterName).value(overdueDaysForNPA) baseDataValidator.reset().parameter(LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME).value(overdueDaysForNPA)
.integerZeroOrGreater(); .integerZeroOrGreater();
/** /**
* { @link DaysInYearType } * { @link DaysInYearType }
*/ */
final Integer daysInYearType = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.daysInYearTypeParameterName, final Integer daysInYearType = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME,
element, Locale.getDefault()); element, Locale.getDefault());
baseDataValidator.reset().parameter(LoanProductConstants.daysInYearTypeParameterName).value(daysInYearType).notNull() baseDataValidator.reset().parameter(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME).value(daysInYearType).notNull()
.isOneOfTheseValues(1, 360, 364, 365); .isOneOfTheseValues(1, 360, 364, 365);
/** /**
* { @link DaysInMonthType } * { @link DaysInMonthType }
*/ */
final Integer daysInMonthType = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.daysInMonthTypeParameterName, final Integer daysInMonthType = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME,
element, Locale.getDefault()); element, Locale.getDefault());
baseDataValidator.reset().parameter(LoanProductConstants.daysInMonthTypeParameterName).value(daysInMonthType).notNull() baseDataValidator.reset().parameter(LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME).value(daysInMonthType).notNull()
.isOneOfTheseValues(1, 30); .isOneOfTheseValues(1, 30);
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.accountMovesOutOfNPAOnlyOnArrearsCompletionParamName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME, element)) {
Boolean npaChangeConfig = this.fromApiJsonHelper.extractBooleanNamed( Boolean npaChangeConfig = this.fromApiJsonHelper.extractBooleanNamed(
LoanProductConstants.accountMovesOutOfNPAOnlyOnArrearsCompletionParamName, element); LoanProductConstants.ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.accountMovesOutOfNPAOnlyOnArrearsCompletionParamName) baseDataValidator.reset().parameter(LoanProductConstants.ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME)
.value(npaChangeConfig).notNull().isOneOfTheseValues(true, false); .value(npaChangeConfig).notNull().isOneOfTheseValues(true, false);
} }
// Interest recalculation settings // Interest recalculation settings
final Boolean isInterestRecalculationEnabled = this.fromApiJsonHelper.extractBooleanNamed( final Boolean isInterestRecalculationEnabled = this.fromApiJsonHelper.extractBooleanNamed(
LoanProductConstants.isInterestRecalculationEnabledParameterName, element); LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.isInterestRecalculationEnabledParameterName) baseDataValidator.reset().parameter(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME)
.value(isInterestRecalculationEnabled).notNull().isOneOfTheseValues(true, false); .value(isInterestRecalculationEnabled).notNull().isOneOfTheseValues(true, false);
if (isInterestRecalculationEnabled != null) { if (isInterestRecalculationEnabled != null) {
@@ -621,10 +621,10 @@ public final class LoanProductDataValidator {
.value(receivablePenaltyAccountId).notNull().integerGreaterThanZero(); .value(receivablePenaltyAccountId).notNull().integerGreaterThanZero();
} }
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.useBorrowerCycleParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME, element)) {
final Boolean useBorrowerCycle = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.useBorrowerCycleParameterName, final Boolean useBorrowerCycle = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME,
element); element);
baseDataValidator.reset().parameter(LoanProductConstants.useBorrowerCycleParameterName).value(useBorrowerCycle).ignoreIfNull() baseDataValidator.reset().parameter(LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME).value(useBorrowerCycle).ignoreIfNull()
.validateForBooleanValue(); .validateForBooleanValue();
if (useBorrowerCycle) { if (useBorrowerCycle) {
validateBorrowerCycleVariations(element, baseDataValidator); validateBorrowerCycleVariations(element, baseDataValidator);
@@ -639,10 +639,10 @@ public final class LoanProductDataValidator {
validatePartialPeriodSupport(interestCalculationPeriodType, baseDataValidator, element, null); validatePartialPeriodSupport(interestCalculationPeriodType, baseDataValidator, element, null);
if(this.fromApiJsonHelper.parameterExists(LoanProductConstants.canUseForTopup, element)){ if(this.fromApiJsonHelper.parameterExists(LoanProductConstants.CAN_USE_FOR_TOPUP, element)){
final Boolean canUseForTopup = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.canUseForTopup, final Boolean canUseForTopup = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.CAN_USE_FOR_TOPUP,
element); element);
baseDataValidator.reset().parameter(LoanProductConstants.canUseForTopup).value(canUseForTopup).validateForBooleanValue(); baseDataValidator.reset().parameter(LoanProductConstants.CAN_USE_FOR_TOPUP).value(canUseForTopup).validateForBooleanValue();
} }
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
@@ -653,8 +653,8 @@ public final class LoanProductDataValidator {
&& this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.allowVariableInstallmentsParamName, element)) { && this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.allowVariableInstallmentsParamName, element)) {
boolean isEqualAmortization = false; boolean isEqualAmortization = false;
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.isEqualAmortizationParam, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, element)) {
isEqualAmortization = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.isEqualAmortizationParam, element); isEqualAmortization = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, element);
} }
if (isEqualAmortization) { throw new EqualAmortizationUnsupportedFeatureException("variable.installment", if (isEqualAmortization) { throw new EqualAmortizationUnsupportedFeatureException("variable.installment",
"variable installment"); } "variable installment"); }
@@ -733,30 +733,30 @@ public final class LoanProductDataValidator {
private void validateMultiDisburseLoanData(final DataValidatorBuilder baseDataValidator, final JsonElement element) { private void validateMultiDisburseLoanData(final DataValidatorBuilder baseDataValidator, final JsonElement element) {
Boolean multiDisburseLoan = false; Boolean multiDisburseLoan = false;
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.multiDisburseLoanParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME, element)) {
multiDisburseLoan = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.multiDisburseLoanParameterName, element); multiDisburseLoan = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.multiDisburseLoanParameterName).value(multiDisburseLoan) baseDataValidator.reset().parameter(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME).value(multiDisburseLoan)
.ignoreIfNull().validateForBooleanValue(); .ignoreIfNull().validateForBooleanValue();
} }
boolean isEqualAmortization = false; boolean isEqualAmortization = false;
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.isEqualAmortizationParam, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, element)) {
isEqualAmortization = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.isEqualAmortizationParam, element); isEqualAmortization = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, element);
} }
if (isEqualAmortization && multiDisburseLoan) { throw new EqualAmortizationUnsupportedFeatureException("tranche.disbursal", if (isEqualAmortization && multiDisburseLoan) { throw new EqualAmortizationUnsupportedFeatureException("tranche.disbursal",
"tranche disbursal"); } "tranche disbursal"); }
if (multiDisburseLoan) { if (multiDisburseLoan) {
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.outstandingLoanBalanceParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME, element)) {
final BigDecimal outstandingLoanBalance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed( final BigDecimal outstandingLoanBalance = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(
LoanProductConstants.outstandingLoanBalanceParameterName, element); LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.outstandingLoanBalanceParameterName).value(outstandingLoanBalance) baseDataValidator.reset().parameter(LoanProductConstants.OUTSTANDING_LOAN_BALANCE_PARAMETER_NAME).value(outstandingLoanBalance)
.ignoreIfNull().zeroOrPositiveAmount(); .ignoreIfNull().zeroOrPositiveAmount();
} }
final Integer maxTrancheCount = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.maxTrancheCountParameterName, final Integer maxTrancheCount = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.MAX_TRANCHE_COUNT_PARAMETER_NAME,
element, Locale.getDefault()); element, Locale.getDefault());
baseDataValidator.reset().parameter(LoanProductConstants.maxTrancheCountParameterName).value(maxTrancheCount).notNull() baseDataValidator.reset().parameter(LoanProductConstants.MAX_TRANCHE_COUNT_PARAMETER_NAME).value(maxTrancheCount).notNull()
.integerGreaterThanZero(); .integerGreaterThanZero();
final Integer interestType = this.fromApiJsonHelper.extractIntegerNamed("interestType", element, Locale.getDefault()); final Integer interestType = this.fromApiJsonHelper.extractIntegerNamed("interestType", element, Locale.getDefault());
@@ -963,9 +963,9 @@ public final class LoanProductDataValidator {
baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100); baseDataValidator.reset().parameter("name").value(name).notBlank().notExceedingLengthOf(100);
} }
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.shortName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.SHORT_NAME, element)) {
final String shortName = this.fromApiJsonHelper.extractStringNamed(LoanProductConstants.shortName, element); final String shortName = this.fromApiJsonHelper.extractStringNamed(LoanProductConstants.SHORT_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.shortName).value(shortName).notBlank().notExceedingLengthOf(4); baseDataValidator.reset().parameter(LoanProductConstants.SHORT_NAME).value(shortName).notBlank().notExceedingLengthOf(4);
} }
if (this.fromApiJsonHelper.parameterExists("description", element)) { if (this.fromApiJsonHelper.parameterExists("description", element)) {
@@ -1080,17 +1080,17 @@ public final class LoanProductDataValidator {
baseDataValidator.reset().parameter("graceOnInterestCharged").value(graceOnInterestCharged).zeroOrPositiveAmount(); baseDataValidator.reset().parameter("graceOnInterestCharged").value(graceOnInterestCharged).zeroOrPositiveAmount();
} }
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.graceOnArrearsAgeingParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME, element)) {
final Integer graceOnArrearsAgeing = this.fromApiJsonHelper.extractIntegerWithLocaleNamed( final Integer graceOnArrearsAgeing = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(
LoanProductConstants.graceOnArrearsAgeingParameterName, element); LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.graceOnArrearsAgeingParameterName).value(graceOnArrearsAgeing) baseDataValidator.reset().parameter(LoanProductConstants.GRACE_ON_ARREARS_AGEING_PARAMETER_NAME).value(graceOnArrearsAgeing)
.integerZeroOrGreater(); .integerZeroOrGreater();
} }
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.overdueDaysForNPAParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME, element)) {
final Integer overdueDaysForNPA = this.fromApiJsonHelper.extractIntegerWithLocaleNamed( final Integer overdueDaysForNPA = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(
LoanProductConstants.overdueDaysForNPAParameterName, element); LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.overdueDaysForNPAParameterName).value(overdueDaysForNPA) baseDataValidator.reset().parameter(LoanProductConstants.OVERDUE_DAYS_FOR_NPA_PARAMETER_NAME).value(overdueDaysForNPA)
.integerZeroOrGreater(); .integerZeroOrGreater();
} }
@@ -1115,43 +1115,43 @@ public final class LoanProductDataValidator {
/** /**
* { @link DaysInYearType } * { @link DaysInYearType }
*/ */
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.daysInYearTypeParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME, element)) {
final Integer daysInYearType = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.daysInYearTypeParameterName, final Integer daysInYearType = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME,
element, Locale.getDefault()); element, Locale.getDefault());
baseDataValidator.reset().parameter(LoanProductConstants.daysInYearTypeParameterName).value(daysInYearType).notNull() baseDataValidator.reset().parameter(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME).value(daysInYearType).notNull()
.isOneOfTheseValues(1, 360, 364, 365); .isOneOfTheseValues(1, 360, 364, 365);
} }
/** /**
* { @link DaysInMonthType } * { @link DaysInMonthType }
*/ */
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.daysInMonthTypeParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME, element)) {
final Integer daysInMonthType = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.daysInMonthTypeParameterName, final Integer daysInMonthType = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME,
element, Locale.getDefault()); element, Locale.getDefault());
baseDataValidator.reset().parameter(LoanProductConstants.daysInMonthTypeParameterName).value(daysInMonthType).notNull() baseDataValidator.reset().parameter(LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME).value(daysInMonthType).notNull()
.isOneOfTheseValues(1, 30); .isOneOfTheseValues(1, 30);
} }
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.accountMovesOutOfNPAOnlyOnArrearsCompletionParamName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME, element)) {
Boolean npaChangeConfig = this.fromApiJsonHelper.extractBooleanNamed( Boolean npaChangeConfig = this.fromApiJsonHelper.extractBooleanNamed(
LoanProductConstants.accountMovesOutOfNPAOnlyOnArrearsCompletionParamName, element); LoanProductConstants.ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.accountMovesOutOfNPAOnlyOnArrearsCompletionParamName) baseDataValidator.reset().parameter(LoanProductConstants.ACCOUNT_MOVES_OUT_OF_NPA_ONLY_ON_ARREARS_COMPLETION_PARAM_NAME)
.value(npaChangeConfig).notNull().isOneOfTheseValues(true, false); .value(npaChangeConfig).notNull().isOneOfTheseValues(true, false);
} }
boolean isEqualAmortization = loanProduct.isEqualAmortization(); boolean isEqualAmortization = loanProduct.isEqualAmortization();
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.isEqualAmortizationParam, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, element)) {
isEqualAmortization = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.isEqualAmortizationParam, element); isEqualAmortization = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM, element);
baseDataValidator.reset().parameter(LoanProductConstants.isEqualAmortizationParam).value(isEqualAmortization).ignoreIfNull() baseDataValidator.reset().parameter(LoanProductConstants.IS_EQUAL_AMORTIZATION_PARAM).value(isEqualAmortization).ignoreIfNull()
.validateForBooleanValue(); .validateForBooleanValue();
} }
// Interest recalculation settings // Interest recalculation settings
Boolean isInterestRecalculationEnabled = loanProduct.isInterestRecalculationEnabled(); Boolean isInterestRecalculationEnabled = loanProduct.isInterestRecalculationEnabled();
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.isInterestRecalculationEnabledParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME, element)) {
isInterestRecalculationEnabled = this.fromApiJsonHelper.extractBooleanNamed( isInterestRecalculationEnabled = this.fromApiJsonHelper.extractBooleanNamed(
LoanProductConstants.isInterestRecalculationEnabledParameterName, element); LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.isInterestRecalculationEnabledParameterName) baseDataValidator.reset().parameter(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME)
.value(isInterestRecalculationEnabled).notNull().isOneOfTheseValues(true, false); .value(isInterestRecalculationEnabled).notNull().isOneOfTheseValues(true, false);
} }
@@ -1472,10 +1472,10 @@ public final class LoanProductDataValidator {
validateMinMaxConstraints(element, baseDataValidator, loanProduct); validateMinMaxConstraints(element, baseDataValidator, loanProduct);
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.useBorrowerCycleParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME, element)) {
final Boolean useBorrowerCycle = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.useBorrowerCycleParameterName, final Boolean useBorrowerCycle = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME,
element); element);
baseDataValidator.reset().parameter(LoanProductConstants.useBorrowerCycleParameterName).value(useBorrowerCycle).ignoreIfNull() baseDataValidator.reset().parameter(LoanProductConstants.USE_BORROWER_CYCLE_PARAMETER_NAME).value(useBorrowerCycle).ignoreIfNull()
.validateForBooleanValue(); .validateForBooleanValue();
if (useBorrowerCycle) { if (useBorrowerCycle) {
validateBorrowerCycleVariations(element, baseDataValidator); validateBorrowerCycleVariations(element, baseDataValidator);
@@ -1490,10 +1490,10 @@ public final class LoanProductDataValidator {
validatePartialPeriodSupport(interestCalculationPeriodType, baseDataValidator, element, loanProduct); validatePartialPeriodSupport(interestCalculationPeriodType, baseDataValidator, element, loanProduct);
if(this.fromApiJsonHelper.parameterExists(LoanProductConstants.canUseForTopup, element)){ if(this.fromApiJsonHelper.parameterExists(LoanProductConstants.CAN_USE_FOR_TOPUP, element)){
final Boolean canUseForTopup = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.canUseForTopup, final Boolean canUseForTopup = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.CAN_USE_FOR_TOPUP,
element); element);
baseDataValidator.reset().parameter(LoanProductConstants.canUseForTopup).value(canUseForTopup).validateForBooleanValue(); baseDataValidator.reset().parameter(LoanProductConstants.CAN_USE_FOR_TOPUP).value(canUseForTopup).validateForBooleanValue();
} }
throwExceptionIfValidationWarningsExist(dataValidationErrors); throwExceptionIfValidationWarningsExist(dataValidationErrors);
@@ -1590,8 +1590,8 @@ public final class LoanProductDataValidator {
BigDecimal maxPrincipalAmount = null; BigDecimal maxPrincipalAmount = null;
if (this.fromApiJsonHelper.parameterExists(principalParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(principalParameterName, element)) {
principalAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(principalParameterName, element); principalAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(principalParameterName, element);
minPrincipalAmount = minmaxValues.get(LoanProductConstants.minPrincipal); minPrincipalAmount = minmaxValues.get(LoanProductConstants.MIN_PRINCIPAL);
maxPrincipalAmount = minmaxValues.get(LoanProductConstants.maxPrincipal); maxPrincipalAmount = minmaxValues.get(LoanProductConstants.MAX_PRINCIPAL);
} }
if ((minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) > 0) if ((minPrincipalAmount != null && minPrincipalAmount.compareTo(BigDecimal.ZERO) > 0)
@@ -1612,11 +1612,11 @@ public final class LoanProductDataValidator {
Integer numberOfRepayments = null; Integer numberOfRepayments = null;
if (this.fromApiJsonHelper.parameterExists(numberOfRepaymentsParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(numberOfRepaymentsParameterName, element)) {
numberOfRepayments = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(numberOfRepaymentsParameterName, element); numberOfRepayments = this.fromApiJsonHelper.extractIntegerWithLocaleNamed(numberOfRepaymentsParameterName, element);
if (minmaxValues.get(LoanProductConstants.minNumberOfRepayments) != null) { if (minmaxValues.get(LoanProductConstants.MIN_NUMBER_OF_REPAYMENTS) != null) {
minNumberOfRepayments = minmaxValues.get(LoanProductConstants.minNumberOfRepayments).intValueExact(); minNumberOfRepayments = minmaxValues.get(LoanProductConstants.MIN_NUMBER_OF_REPAYMENTS).intValueExact();
} }
if (minmaxValues.get(LoanProductConstants.maxNumberOfRepayments) != null) { if (minmaxValues.get(LoanProductConstants.MAX_NUMBER_OF_REPAYMENTS) != null) {
maxNumberOfRepayments = minmaxValues.get(LoanProductConstants.maxNumberOfRepayments).intValueExact(); maxNumberOfRepayments = minmaxValues.get(LoanProductConstants.MAX_NUMBER_OF_REPAYMENTS).intValueExact();
} }
} }
@@ -1639,8 +1639,8 @@ public final class LoanProductDataValidator {
BigDecimal maxInterestRatePerPeriod = null; BigDecimal maxInterestRatePerPeriod = null;
if (this.fromApiJsonHelper.parameterExists(interestRatePerPeriodParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(interestRatePerPeriodParameterName, element)) {
interestRatePerPeriod = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(interestRatePerPeriodParameterName, element); interestRatePerPeriod = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(interestRatePerPeriodParameterName, element);
minInterestRatePerPeriod = minmaxValues.get(LoanProductConstants.minInterestRatePerPeriod); minInterestRatePerPeriod = minmaxValues.get(LoanProductConstants.MIN_INTEREST_RATE_PER_PERIOD);
maxInterestRatePerPeriod = minmaxValues.get(LoanProductConstants.maxInterestRatePerPeriod); maxInterestRatePerPeriod = minmaxValues.get(LoanProductConstants.MAX_INTEREST_RATE_PER_PERIOD);
} }
if (maxInterestRatePerPeriod != null) { if (maxInterestRatePerPeriod != null) {
if (minInterestRatePerPeriod != null) { if (minInterestRatePerPeriod != null) {
@@ -1867,28 +1867,28 @@ public final class LoanProductDataValidator {
private void validateBorrowerCyclePrincipalVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator) { private void validateBorrowerCyclePrincipalVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
validateBorrowerCycleVariations(element, baseDataValidator, LoanProductConstants.principalVariationsForBorrowerCycleParameterName, validateBorrowerCycleVariations(element, baseDataValidator, LoanProductConstants.PRINCIPAL_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME,
LoanProductConstants.principalPerCycleParameterName, LoanProductConstants.minPrincipalPerCycleParameterName, LoanProductConstants.PRINCIPAL_PER_CYCLE_PARAMETER_NAME, LoanProductConstants.MIN_PRINCIPAL_PER_CYCLE_PARAMETER_NAME,
LoanProductConstants.maxPrincipalPerCycleParameterName, LoanProductConstants.principalValueUsageConditionParamName, LoanProductConstants.MIN_PRINCIPAL_PER_CYCLE_PARAMETER_NAME, LoanProductConstants.PRINCIPAL_VALUE_USAGE_CONDITION_PARAM_NAME,
LoanProductConstants.principalCycleNumbersParamName); LoanProductConstants.PRINCIPAL_CYCLE_NUMBERS_PARAM_NAME);
} }
private void validateBorrowerCycleRepaymentVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator) { private void validateBorrowerCycleRepaymentVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
validateBorrowerCycleVariations(element, baseDataValidator, validateBorrowerCycleVariations(element, baseDataValidator,
LoanProductConstants.numberOfRepaymentVariationsForBorrowerCycleParameterName, LoanProductConstants.NUMBER_OF_REPAYMENT_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME,
LoanProductConstants.numberOfRepaymentsPerCycleParameterName, LoanProductConstants.NUMBER_OF_REPAYMENTS_PER_CYCLE_PARAMETER_NAME,
LoanProductConstants.minNumberOfRepaymentsPerCycleParameterName, LoanProductConstants.MIN_NUMBER_OF_REPAYMENTS_PER_CYCLE_PARAMETER_NAME,
LoanProductConstants.maxNumberOfRepaymentsPerCycleParameterName, LoanProductConstants.MAX_NUMBER_OF_REPAYMENTS_PER_CYCLE_PARAMETER_NAME,
LoanProductConstants.repaymentValueUsageConditionParamName, LoanProductConstants.repaymentCycleNumberParamName); LoanProductConstants.REPAYMENT_VALUE_USAGE_CONDITION_PARAM_NAME, LoanProductConstants.REPAYMENT_CYCLE_NUMBER_PARAM_NAME);
} }
private void validateBorrowerCycleInterestVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator) { private void validateBorrowerCycleInterestVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator) {
validateBorrowerCycleVariations(element, baseDataValidator, validateBorrowerCycleVariations(element, baseDataValidator,
LoanProductConstants.interestRateVariationsForBorrowerCycleParameterName, LoanProductConstants.INTEREST_RATE_VARIATIONS_FOR_BORROWER_CYCLE_PARAMETER_NAME,
LoanProductConstants.interestRatePerPeriodPerCycleParameterName, LoanProductConstants.INTEREST_RATE_PER_PERIOD_PER_CYCLE_PARAMETER_NAME,
LoanProductConstants.minInterestRatePerPeriodPerCycleParameterName, LoanProductConstants.MIN_INTEREST_RATE_PER_PERIOD_PER_CYCLE_PARAMETER_NAME,
LoanProductConstants.maxInterestRatePerPeriodPerCycleParameterName, LoanProductConstants.MAX_INTEREST_RATE_PER_PERIOD_PER_CYCLE_PARAMETER_NAME,
LoanProductConstants.interestRateValueUsageConditionParamName, LoanProductConstants.interestRateCycleNumberParamName); LoanProductConstants.INTEREST_RATE_VALUE_USAGE_CONDITION_PARAM_NAME, LoanProductConstants.INTEREST_RATE_VALUE_USAGE_CONDITION_PARAM_NAME);
} }
private void validateBorrowerCycleVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator, private void validateBorrowerCycleVariations(final JsonElement element, final DataValidatorBuilder baseDataValidator,
@@ -1905,16 +1905,16 @@ public final class LoanProductDataValidator {
do { do {
final JsonObject jsonObject = variationArray.get(i).getAsJsonObject(); final JsonObject jsonObject = variationArray.get(i).getAsJsonObject();
BigDecimal defaultValue = this.fromApiJsonHelper.extractBigDecimalNamed(LoanProductConstants.defaultValueParameterName, BigDecimal defaultValue = this.fromApiJsonHelper.extractBigDecimalNamed(LoanProductConstants.DEFAULT_VALUE_PARAMETER_NAME,
jsonObject, locale); jsonObject, locale);
BigDecimal minValue = this.fromApiJsonHelper.extractBigDecimalNamed(LoanProductConstants.minValueParameterName, BigDecimal minValue = this.fromApiJsonHelper.extractBigDecimalNamed(LoanProductConstants.MIN_VALUE_PARAMETER_NAME,
jsonObject, locale); jsonObject, locale);
BigDecimal maxValue = this.fromApiJsonHelper.extractBigDecimalNamed(LoanProductConstants.maxValueParameterName, BigDecimal maxValue = this.fromApiJsonHelper.extractBigDecimalNamed(LoanProductConstants.MAX_VALUE_PARAMETER_NAME,
jsonObject, locale); jsonObject, locale);
Integer cycleNumber = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.borrowerCycleNumberParamName, Integer cycleNumber = this.fromApiJsonHelper.extractIntegerNamed(LoanProductConstants.BORROWER_CYCLE_NUMBER_PARAM_NAME,
jsonObject, locale); jsonObject, locale);
Integer valueUsageCondition = this.fromApiJsonHelper.extractIntegerNamed( Integer valueUsageCondition = this.fromApiJsonHelper.extractIntegerNamed(
LoanProductConstants.valueConditionTypeParamName, jsonObject, locale); LoanProductConstants.VALUE_CONDITION_TYPE_PARAM_NAME, jsonObject, locale);
baseDataValidator.reset().parameter(defaultParameterName).value(defaultValue).notBlank(); baseDataValidator.reset().parameter(defaultParameterName).value(defaultValue).notBlank();
if (minValue != null) { if (minValue != null) {
@@ -2033,15 +2033,15 @@ public final class LoanProductDataValidator {
.fromInt(interestCalculationPeriodType); .fromInt(interestCalculationPeriodType);
boolean considerPartialPeriodUpdates = interestCalculationPeriodMethod.isDaily(); boolean considerPartialPeriodUpdates = interestCalculationPeriodMethod.isDaily();
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, element)) {
final Boolean considerPartialInterestEnabled = this.fromApiJsonHelper.extractBooleanNamed( final Boolean considerPartialInterestEnabled = this.fromApiJsonHelper.extractBooleanNamed(
LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName, element); LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME, element);
baseDataValidator.reset().parameter(LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName) baseDataValidator.reset().parameter(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME)
.value(considerPartialInterestEnabled).notNull().isOneOfTheseValues(true, false); .value(considerPartialInterestEnabled).notNull().isOneOfTheseValues(true, false);
final boolean considerPartialPeriods = considerPartialInterestEnabled == null ? false : considerPartialInterestEnabled; final boolean considerPartialPeriods = considerPartialInterestEnabled == null ? false : considerPartialInterestEnabled;
if (interestCalculationPeriodMethod.isDaily()) { if (interestCalculationPeriodMethod.isDaily()) {
if (considerPartialPeriods) { if (considerPartialPeriods) {
baseDataValidator.reset().parameter(LoanProductConstants.allowPartialPeriodInterestCalcualtionParamName) baseDataValidator.reset().parameter(LoanProductConstants.ALLOW_PARTIAL_PERIOD_INTEREST_CALCUALTION_PARAM_NAME)
.failWithCode("not.supported.for.daily.calcualtions"); .failWithCode("not.supported.for.daily.calcualtions");
} }
} else { } else {
@@ -2051,26 +2051,26 @@ public final class LoanProductDataValidator {
if (!considerPartialPeriodUpdates) { if (!considerPartialPeriodUpdates) {
Boolean isInterestRecalculationEnabled = null; Boolean isInterestRecalculationEnabled = null;
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.isInterestRecalculationEnabledParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME, element)) {
isInterestRecalculationEnabled = this.fromApiJsonHelper.extractBooleanNamed( isInterestRecalculationEnabled = this.fromApiJsonHelper.extractBooleanNamed(
LoanProductConstants.isInterestRecalculationEnabledParameterName, element); LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME, element);
} else if (loanProduct != null) { } else if (loanProduct != null) {
isInterestRecalculationEnabled = loanProduct.isInterestRecalculationEnabled(); isInterestRecalculationEnabled = loanProduct.isInterestRecalculationEnabled();
} }
if (isInterestRecalculationEnabled != null && isInterestRecalculationEnabled) { if (isInterestRecalculationEnabled != null && isInterestRecalculationEnabled) {
baseDataValidator.reset().parameter(LoanProductConstants.isInterestRecalculationEnabledParameterName) baseDataValidator.reset().parameter(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME)
.failWithCode("not.supported.for.selected.interest.calcualtion.type"); .failWithCode("not.supported.for.selected.interest.calcualtion.type");
} }
Boolean multiDisburseLoan = null; Boolean multiDisburseLoan = null;
if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.multiDisburseLoanParameterName, element)) { if (this.fromApiJsonHelper.parameterExists(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME, element)) {
multiDisburseLoan = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.multiDisburseLoanParameterName, multiDisburseLoan = this.fromApiJsonHelper.extractBooleanNamed(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME,
element); element);
} else if (loanProduct != null) { } else if (loanProduct != null) {
isInterestRecalculationEnabled = loanProduct.isMultiDisburseLoan(); isInterestRecalculationEnabled = loanProduct.isMultiDisburseLoan();
} }
if (multiDisburseLoan != null && multiDisburseLoan) { if (multiDisburseLoan != null && multiDisburseLoan) {
baseDataValidator.reset().parameter(LoanProductConstants.multiDisburseLoanParameterName) baseDataValidator.reset().parameter(LoanProductConstants.MULTI_DISBURSE_LOAN_PARAMETER_NAME)
.failWithCode("not.supported.for.selected.interest.calcualtion.type"); .failWithCode("not.supported.for.selected.interest.calcualtion.type");
} }
@@ -243,11 +243,11 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
.updateLoanProductToGLAccountMapping(product.getId(), command, accountingTypeChanged, product.getAccountingType()); .updateLoanProductToGLAccountMapping(product.getId(), command, accountingTypeChanged, product.getAccountingType());
changes.putAll(accountingMappingChanges); changes.putAll(accountingMappingChanges);
if (changes.containsKey(LoanProductConstants.ratesParamName)) { if (changes.containsKey(LoanProductConstants.RATES_PARAM_NAME)) {
final List<Rate> productRates = assembleListOfProductRates(command); final List<Rate> productRates = assembleListOfProductRates(command);
final boolean updated = product.updateRates(productRates); final boolean updated = product.updateRates(productRates);
if (!updated) { if (!updated) {
changes.remove(LoanProductConstants.ratesParamName); changes.remove(LoanProductConstants.RATES_PARAM_NAME);
} }
} }
@@ -52,10 +52,10 @@ public class RateAssembler {
final JsonObject topLevelJsonElement = element.getAsJsonObject(); final JsonObject topLevelJsonElement = element.getAsJsonObject();
final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement); final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(topLevelJsonElement);
if (topLevelJsonElement.has(LoanProductConstants.ratesParamName) && topLevelJsonElement if (topLevelJsonElement.has(LoanProductConstants.RATES_PARAM_NAME) && topLevelJsonElement
.get(LoanProductConstants.ratesParamName) .get(LoanProductConstants.RATES_PARAM_NAME)
.isJsonArray()) { .isJsonArray()) {
final JsonArray array = topLevelJsonElement.get(LoanProductConstants.ratesParamName) final JsonArray array = topLevelJsonElement.get(LoanProductConstants.RATES_PARAM_NAME)
.getAsJsonArray(); .getAsJsonArray();
List<Long> idList = new ArrayList<>(); List<Long> idList = new ArrayList<>();