FINERACT-2197: Introduce a new type of ACTUAL during calculation of days in year, update

This commit is contained in:
Jose Alberto Hernandez
2025-03-24 19:30:44 +01:00
committed by Adam Saghy
parent 3f2079566c
commit f3bb66f209
3 changed files with 61 additions and 67 deletions
@@ -350,6 +350,30 @@ final class LoanProductsApiResourceSwagger {
public Long resourceId;
}
public static final class GetLoanProductsDaysInMonthType {
private GetLoanProductsDaysInMonthType() {}
@Schema(example = "1")
public Long id;
@Schema(example = "DaysInMonthType.actual")
public String code;
@Schema(example = "Actual")
public String description;
}
public static final class GetLoanProductsDaysInYearType {
private GetLoanProductsDaysInYearType() {}
@Schema(example = "1")
public Long id;
@Schema(example = "DaysInYearType.actual")
public String code;
@Schema(example = "Actual")
public String description;
}
@Schema(description = "GetLoanProductsResponse")
public static final class GetLoanProductsResponse {
@@ -435,30 +459,6 @@ final class LoanProductsApiResourceSwagger {
public String description;
}
static final class GetLoansProductsDaysInMonthType {
private GetLoansProductsDaysInMonthType() {}
@Schema(example = "30")
public Long id;
@Schema(example = "DaysInMonthType.days360")
public String code;
@Schema(example = "30 Days")
public String description;
}
static final class GetLoansProductsDaysInYearType {
private GetLoansProductsDaysInYearType() {}
@Schema(example = "360")
public Long id;
@Schema(example = "DaysInYearType.days360")
public String code;
@Schema(example = "360 Days")
public String description;
}
static final class GetLoanProductsDaysInYearCustomStrategy {
private GetLoanProductsDaysInYearCustomStrategy() {}
@@ -626,8 +626,8 @@ final class LoanProductsApiResourceSwagger {
public List<Integer> interestRateVariationsForBorrowerCycle;
@Schema(example = "[]")
public List<Integer> numberOfRepaymentVariationsForBorrowerCycle;
public GetLoansProductsDaysInMonthType daysInMonthType;
public GetLoansProductsDaysInYearType daysInYearType;
public GetLoanProductsDaysInMonthType daysInMonthType;
public GetLoanProductsDaysInYearType daysInYearType;
public GetLoanProductsDaysInYearCustomStrategy daysInYearCustomStrategy;
@Schema(example = "true")
public Boolean isInterestRecalculationEnabled;
@@ -713,42 +713,6 @@ final class LoanProductsApiResourceSwagger {
public String description;
}
static final class GetLoansProductsDaysInMonthTemplateType {
private GetLoansProductsDaysInMonthTemplateType() {}
@Schema(example = "1")
public Long id;
@Schema(example = "DaysInMonthType.actual")
public String code;
@Schema(example = "Actual")
public String description;
}
static final class GetLoanProductsDaysInYearTemplateType {
private GetLoanProductsDaysInYearTemplateType() {}
@Schema(example = "1")
public Long id;
@Schema(example = "DaysInYearType.actual")
public String code;
@Schema(example = "Actual")
public String description;
}
static final class GetLoanProductsDaysInYearCustomStrategyTemplateType {
private GetLoanProductsDaysInYearCustomStrategyTemplateType() {}
@Schema(example = "FULL_LEAP_YEAR")
public String id;
@Schema(example = "DaysInYearCustomStrategyType.fullLeapYear")
public String code;
@Schema(example = "Full Leap Year")
public String description;
}
static final class GetLoanProductsInterestRecalculationTemplateData {
private GetLoanProductsInterestRecalculationTemplateData() {}
@@ -1098,9 +1062,9 @@ final class LoanProductsApiResourceSwagger {
@Schema(example = "[]")
public List<Integer> numberOfRepaymentVariationsForBorrowerCycle;
public GetLoanProductsTemplateResponse.GetLoanProductsAccountingRule accountingRule;
public GetLoansProductsDaysInMonthTemplateType daysInMonthType;
public GetLoanProductsDaysInYearTemplateType daysInYearType;
public GetLoanProductsDaysInYearCustomStrategyTemplateType daysInYearCustomStrategy;
public GetLoanProductsDaysInMonthType daysInMonthType;
public GetLoanProductsDaysInYearType daysInYearType;
public StringEnumOptionData daysInYearCustomStrategy;
@Schema(example = "false")
public Boolean isInterestRecalculationEnabled;
public GetLoanProductsInterestRecalculationTemplateData interestRecalculationData;
@@ -1117,9 +1081,9 @@ final class LoanProductsApiResourceSwagger {
public Set<GetLoanProductsResponse.GetLoanProductsAccountingRule> accountingRuleOptions;
public GetLoanProductsAccountingMappingOptions accountingMappingOptions;
public Set<GetLoanProductsValueConditionTypeOptions> valueConditionTypeOptions;
public Set<GetLoansProductsDaysInMonthTemplateType> daysInMonthTypeOptions;
public Set<StringEnumOptionData> daysInMonthTypeOptions;
public Set<GetLoanProductsInterestTemplateType> daysInYearTypeOptions;
public Set<GetLoanProductsDaysInYearCustomStrategyTemplateType> daysInYearTypeCustomStrategyOptions;
public Set<StringEnumOptionData> daysInYearTypeCustomStrategyOptions;
public Set<GetLoanProductsResponse.GetLoanProductsInterestRecalculationData.GetLoanProductsInterestRecalculationCompoundingType> interestRecalculationCompoundingTypeOptions;
public Set<GetLoanProductsResponse.GetLoanProductsInterestRecalculationData.GetLoanProductsRescheduleStrategyType> rescheduleStrategyTypeOptions;
public Set<GetLoanProductsResponse.GetLoanProductsInterestRecalculationData.GetLoanProductsInterestRecalculationCompoundingFrequencyType> interestRecalculationFrequencyTypeOptions;
@@ -1402,6 +1366,9 @@ final class LoanProductsApiResourceSwagger {
@Schema(example = "[]")
public List<Integer> numberOfRepaymentVariationsForBorrowerCycle;
public GetLoanProductsResponse.GetLoanProductsAccountingRule accountingRule;
public GetLoanProductsDaysInMonthType daysInMonthType;
public GetLoanProductsDaysInYearType daysInYearType;
public StringEnumOptionData daysInYearCustomStrategy;
@Schema(example = "false")
public Boolean canUseForTopup;
public GetLoanAccountingMappings accountingMappings;
@@ -1555,6 +1522,8 @@ final class LoanProductsApiResourceSwagger {
public Long daysInMonthType;
@Schema(example = "1")
public Long daysInYearType;
@Schema(example = "FULL_LEAP_YEAR")
public String daysInYearCustomStrategy;
@Schema(example = "true")
public Boolean allowPartialPeriodInterestCalcualtion;
@Schema(example = "179")
@@ -523,6 +523,13 @@ public class LoanProductRelatedDetail implements LoanProductMinimumRepaymentSche
this.daysInYearType = newValue;
}
if (command.parameterExists(LoanProductConstants.DAYS_IN_YEAR_CUSTOM_STRATEGY_TYPE_PARAMETER_NAME)) {
final DaysInYearCustomStrategyType newValue = DaysInYearCustomStrategyType
.valueOf(command.stringValueOfParameterNamed(LoanProductConstants.DAYS_IN_YEAR_CUSTOM_STRATEGY_TYPE_PARAMETER_NAME));
actualChanges.put(LoanProductConstants.DAYS_IN_YEAR_CUSTOM_STRATEGY_TYPE_PARAMETER_NAME, newValue.name());
this.daysInYearCustomStrategy = newValue;
}
if (command.isChangeInBooleanParameterNamed(LoanProductConstants.IS_INTEREST_RECALCULATION_ENABLED_PARAMETER_NAME,
this.isInterestRecalculationEnabled)) {
final boolean newValue = command
@@ -20,7 +20,9 @@ package org.apache.fineract.integrationtests;
import java.io.IOException;
import java.math.BigDecimal;
import org.apache.fineract.client.models.GetLoanProductsProductIdResponse;
import org.apache.fineract.client.models.PostLoanProductsResponse;
import org.apache.fineract.client.models.PutLoanProductsProductIdRequest;
import org.apache.fineract.integrationtests.common.ClientHelper;
import org.apache.fineract.integrationtests.common.FineractClientHelper;
import org.junit.jupiter.api.Assertions;
@@ -46,6 +48,22 @@ public class DaysInYearCustomStrategyTest extends BaseLoanIntegrationTest {
}
}
@Test
public void test_Update_DaysInYearsCustomStrategy_Value() {
PostLoanProductsResponse postLoanProduct = loanProductHelper.createLoanProduct(create4IProgressive().currencyCode("USD")
.daysInYearType(DaysInYearType.ACTUAL).daysInYearCustomStrategy(DaysInYearCustomStrategy.FEB_29_PERIOD_ONLY));
Assertions.assertNotNull(postLoanProduct.getResourceId());
final Long loanProductId = postLoanProduct.getResourceId();
GetLoanProductsProductIdResponse loanProduct = loanTransactionHelper.getLoanProduct(loanProductId.intValue());
Assertions.assertEquals("FEB_29_PERIOD_ONLY", loanProduct.getDaysInYearCustomStrategy().getId());
loanProductHelper.updateLoanProductById(loanProductId,
new PutLoanProductsProductIdRequest().daysInYearCustomStrategy(DaysInYearCustomStrategy.FULL_LEAP_YEAR));
loanProduct = loanTransactionHelper.getLoanProduct(loanProductId.intValue());
Assertions.assertEquals("FULL_LEAP_YEAR", loanProduct.getDaysInYearCustomStrategy().getId());
}
@Test
public void testFEB_29_PERIOD_ONLY() {
runAt("1 January 2024", () -> {