Add days in year at loan level #FINERACT-1302
This commit is contained in:
committed by
Michael Vorburger ⛑️
parent
c927915443
commit
b0c45da472
+2
@@ -515,6 +515,8 @@ final class LoansApiResourceSwagger {
|
||||
public String expectedDisbursementDate;
|
||||
@Schema(example = "2")
|
||||
public Integer transactionProcessingStrategyId;
|
||||
@Schema(example = "360", allowableValues = "1, 360, 364, 36")
|
||||
public Integer daysInYearType;
|
||||
}
|
||||
|
||||
@Schema(description = "PostLoansResponse")
|
||||
|
||||
+8
-1
@@ -336,7 +336,14 @@ public class LoanScheduleAssembler {
|
||||
*/
|
||||
final DaysInMonthType daysInMonthType = loanProduct.fetchDaysInMonthType();
|
||||
|
||||
final DaysInYearType daysInYearType = loanProduct.fetchDaysInYearType();
|
||||
DaysInYearType daysInYearType = null;
|
||||
final Integer daysInYearTypeIntFromApplication = this.fromApiJsonHelper
|
||||
.extractIntegerNamed(LoanApiConstants.daysInYearTypeParameterName, element, Locale.getDefault());
|
||||
if (daysInYearTypeIntFromApplication != null) {
|
||||
daysInYearType = DaysInYearType.fromInt(daysInYearTypeIntFromApplication);
|
||||
} else {
|
||||
daysInYearType = loanProduct.fetchDaysInYearType();
|
||||
}
|
||||
|
||||
final boolean isInterestRecalculationEnabled = loanProduct.isInterestRecalculationEnabled();
|
||||
RecalculationFrequencyType recalculationFrequencyType = null;
|
||||
|
||||
+2
-1
@@ -68,7 +68,8 @@ public final class CalculateLoanScheduleQueryFromApiJsonHelper {
|
||||
LoanApiConstants.createStandingInstructionAtDisbursementParameterName, LoanApiConstants.isFloatingInterestRateParameterName,
|
||||
LoanApiConstants.interestRateDifferentialParameterName, LoanApiConstants.repaymentFrequencyNthDayTypeParameterName,
|
||||
LoanApiConstants.repaymentFrequencyDayOfWeekTypeParameterName, LoanApiConstants.isTopup, LoanApiConstants.loanIdToClose,
|
||||
LoanApiConstants.datatables, LoanApiConstants.isEqualAmortizationParam, LoanProductConstants.RATES_PARAM_NAME));
|
||||
LoanApiConstants.datatables, LoanApiConstants.isEqualAmortizationParam, LoanProductConstants.RATES_PARAM_NAME,
|
||||
LoanApiConstants.daysInYearTypeParameterName));
|
||||
|
||||
private final FromJsonHelper fromApiJsonHelper;
|
||||
|
||||
|
||||
+11
-4
@@ -88,7 +88,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
|
||||
LoanApiConstants.createStandingInstructionAtDisbursementParameterName, LoanApiConstants.isTopup, LoanApiConstants.loanIdToClose,
|
||||
LoanApiConstants.datatables, LoanApiConstants.isEqualAmortizationParam, LoanProductConstants.RATES_PARAM_NAME,
|
||||
LoanApiConstants.applicationId, // glim specific
|
||||
LoanApiConstants.lastApplication)); // glim specific
|
||||
LoanApiConstants.lastApplication, LoanApiConstants.daysInYearTypeParameterName)); // glim specific
|
||||
|
||||
private final FromJsonHelper fromApiJsonHelper;
|
||||
private final CalculateLoanScheduleQueryFromApiJsonHelper apiJsonHelper;
|
||||
@@ -485,7 +485,14 @@ public final class LoanApplicationCommandFromApiJsonHelper {
|
||||
baseDataValidator.reset().parameter(LoanApiConstants.datatables).value(datatables).notNull().jsonArrayNotEmpty();
|
||||
}
|
||||
|
||||
validateLoanMultiDisbursementdate(element, baseDataValidator, expectedDisbursementDate, principal);
|
||||
if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.daysInYearTypeParameterName, element)) {
|
||||
final Integer daysInYearType = this.fromApiJsonHelper.extractIntegerNamed(LoanApiConstants.daysInYearTypeParameterName, element,
|
||||
Locale.getDefault());
|
||||
baseDataValidator.reset().parameter(LoanApiConstants.daysInYearTypeParameterName).value(daysInYearType).notNull()
|
||||
.isOneOfTheseValues(1, 360, 364, 365);
|
||||
}
|
||||
|
||||
validateLoanMultiDisbursementDate(element, baseDataValidator, expectedDisbursementDate, principal);
|
||||
validatePartialPeriodSupport(interestCalculationPeriodType, baseDataValidator, element, loanProduct);
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
@@ -932,7 +939,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
|
||||
}
|
||||
}
|
||||
|
||||
validateLoanMultiDisbursementdate(element, baseDataValidator, expectedDisbursementDate, principal);
|
||||
validateLoanMultiDisbursementDate(element, baseDataValidator, expectedDisbursementDate, principal);
|
||||
validatePartialPeriodSupport(interestCalculationPeriodType, baseDataValidator, element, loanProduct);
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
@@ -1079,7 +1086,7 @@ public final class LoanApplicationCommandFromApiJsonHelper {
|
||||
}
|
||||
}
|
||||
|
||||
public void validateLoanMultiDisbursementdate(final JsonElement element, final DataValidatorBuilder baseDataValidator,
|
||||
public void validateLoanMultiDisbursementDate(final JsonElement element, final DataValidatorBuilder baseDataValidator,
|
||||
LocalDate expectedDisbursement, BigDecimal totalPrincipal) {
|
||||
|
||||
this.validateDisbursementsAreDatewiseOrdered(element, baseDataValidator);
|
||||
|
||||
+1
-1
@@ -434,7 +434,7 @@ public final class LoanEventApiJsonValidator {
|
||||
.failWithCode(LoanApiConstants.ALREADY_DISBURSED);
|
||||
}
|
||||
|
||||
fromApiJsonDeserializer.validateLoanMultiDisbursementdate(element, baseDataValidator, actualDisbursementDate, approvedPrincipal);
|
||||
fromApiJsonDeserializer.validateLoanMultiDisbursementDate(element, baseDataValidator, actualDisbursementDate, approvedPrincipal);
|
||||
|
||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1286,7 +1286,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements Loa
|
||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
|
||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan");
|
||||
final BigDecimal principal = this.fromJsonHelper.extractBigDecimalWithLocaleNamed("approvedLoanAmount", element);
|
||||
fromApiJsonDeserializer.validateLoanMultiDisbursementdate(element, baseDataValidator, expectedDisbursementDate, principal);
|
||||
fromApiJsonDeserializer.validateLoanMultiDisbursementDate(element, baseDataValidator, expectedDisbursementDate, principal);
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
}
|
||||
|
||||
+1
-1
@@ -2630,7 +2630,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
}
|
||||
final BigDecimal principal = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed("approvedLoanAmount", element);
|
||||
|
||||
loanApplicationCommandFromApiJsonHelper.validateLoanMultiDisbursementdate(element, baseDataValidator, expectedDisbursementDate,
|
||||
loanApplicationCommandFromApiJsonHelper.validateLoanMultiDisbursementDate(element, baseDataValidator, expectedDisbursementDate,
|
||||
principal);
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException(dataValidationErrors);
|
||||
|
||||
+1
-1
@@ -297,7 +297,7 @@ public class LoanProduct extends AbstractPersistableCustom {
|
||||
final boolean isInterestRecalculationEnabled = command
|
||||
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME);
|
||||
final DaysInMonthType daysInMonthType = DaysInMonthType
|
||||
.fromInt(command.integerValueOfParameterNamed(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME));
|
||||
.fromInt(command.integerValueOfParameterNamed(LoanProductConstants.DAYS_IN_MONTH_TYPE_PARAMETER_NAME));
|
||||
|
||||
final DaysInYearType daysInYearType = DaysInYearType
|
||||
.fromInt(command.integerValueOfParameterNamed(LoanProductConstants.DAYS_IN_YEAR_TYPE_PARAMETER_NAME));
|
||||
|
||||
@@ -11650,7 +11650,7 @@ Request Body:
|
||||
</tr>
|
||||
<tr class=alt>
|
||||
<td>graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, linkAccountId, allowPartialPeriodInterestCalcualtion,
|
||||
fixedEmiAmount, maxOutstandingLoanBalance, disbursementData, graceOnArrearsAgeing, createStandingInstructionAtDisbursement (requires linkedAccountId if set to true)
|
||||
fixedEmiAmount, maxOutstandingLoanBalance, disbursementData, graceOnArrearsAgeing, createStandingInstructionAtDisbursement (requires linkedAccountId if set to true), daysInYearType
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -11685,6 +11685,7 @@ Request Body:
|
||||
"linkAccountId" : "1",
|
||||
"fixedEmiAmount":1100,
|
||||
"maxOutstandingLoanBalance":"35000",
|
||||
"daysInYearType":1,
|
||||
"disbursementData":[{"expectedDisbursementDate":"01 November 2013",
|
||||
"principal":22000,"approvedPrincipal":22000}],
|
||||
"datatables": [{
|
||||
|
||||
Reference in New Issue
Block a user