This is an automated email from the ASF dual-hosted git repository.
adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new f63df474f FINERACT-2154: Store "Pre-close interest calculation
strategy" on loan level
f63df474f is described below
commit f63df474f679440655f0809b085186a461cd0093
Author: Adam Saghy <[email protected]>
AuthorDate: Thu Nov 28 16:48:21 2024 +0100
FINERACT-2154: Store "Pre-close interest calculation strategy" on loan level
---
.../domain/LoanInterestRecalculationDetails.java | 18 ++++++++--
.../loanschedule/domain/LoanApplicationTerms.java | 12 +++----
.../data/LoanProductInterestRecalculationData.java | 4 +--
...> LoanPreCloseInterestCalculationStrategy.java} | 14 ++++----
.../portfolio/loanproduct/domain/LoanProduct.java | 6 ++--
.../LoanProductInterestRecalculationDetails.java | 16 ++++-----
.../LoanDropdownReadPlatformServiceImpl.java | 6 ++--
.../loanproduct/service/LoanEnumerations.java | 14 ++++----
.../tenant/module/loan/module-changelog-master.xml | 1 +
...25_store_pre_closure_strategy_to_loan_level.xml | 38 ++++++++++++++++++++++
...dvancedPaymentScheduleTransactionProcessor.java | 9 +++--
.../serialization/LoanProductDataValidator.java | 4 +--
.../domain/DefaultScheduledDateGeneratorTest.java | 2 +-
13 files changed, 98 insertions(+), 46 deletions(-)
diff --git
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java
index 7823850ea..20eb8d6e3 100644
---
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java
+++
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanInterestRecalculationDetails.java
@@ -20,11 +20,14 @@ package org.apache.fineract.portfolio.loanaccount.domain;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
+import jakarta.persistence.EnumType;
+import jakarta.persistence.Enumerated;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import
org.apache.fineract.infrastructure.core.domain.AbstractPersistableCustom;
import
org.apache.fineract.portfolio.loanproduct.domain.InterestRecalculationCompoundingMethod;
+import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreCloseInterestCalculationStrategy;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanProductInterestRecalculationDetails;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanRescheduleStrategyMethod;
import
org.apache.fineract.portfolio.loanproduct.domain.RecalculationFrequencyType;
@@ -88,6 +91,10 @@ public class LoanInterestRecalculationDetails extends
AbstractPersistableCustom<
@Column(name = "allow_compounding_on_eod")
private Boolean allowCompoundingOnEod;
+ @Column(name = "pre_close_interest_calculation_strategy")
+ @Enumerated(EnumType.ORDINAL)
+ private LoanPreCloseInterestCalculationStrategy
preCloseInterestCalculationStrategy;
+
@Column(name = "disallow_interest_calc_on_past_due")
private Boolean disallowInterestCalculationOnPastDue;
@@ -99,7 +106,8 @@ public class LoanInterestRecalculationDetails extends
AbstractPersistableCustom<
final Integer restFrequencyType, final Integer restInterval, final
Integer restFrequencyNthDay, Integer restFrequencyWeekday,
Integer restFrequencyOnDay, Integer compoundingFrequencyType,
Integer compoundingInterval, Integer compoundingFrequencyNthDay,
Integer compoundingFrequencyWeekday, Integer
compoundingFrequencyOnDay, final boolean isCompoundingToBePostedAsTransaction,
- final boolean allowCompoundingOnEod, final boolean
disallowInterestCalculationOnPastDue) {
+ final boolean allowCompoundingOnEod, final boolean
disallowInterestCalculationOnPastDue,
+ final LoanPreCloseInterestCalculationStrategy
preCloseInterestCalculationStrategy) {
this.interestRecalculationCompoundingMethod =
interestRecalculationCompoundingMethod;
this.rescheduleStrategyMethod = rescheduleStrategyMethod;
this.restFrequencyNthDay = restFrequencyNthDay;
@@ -115,6 +123,7 @@ public class LoanInterestRecalculationDetails extends
AbstractPersistableCustom<
this.isCompoundingToBePostedAsTransaction =
isCompoundingToBePostedAsTransaction;
this.allowCompoundingOnEod = allowCompoundingOnEod;
this.disallowInterestCalculationOnPastDue =
disallowInterestCalculationOnPastDue;
+ this.preCloseInterestCalculationStrategy =
preCloseInterestCalculationStrategy;
}
public static LoanInterestRecalculationDetails createFrom(
@@ -132,7 +141,8 @@ public class LoanInterestRecalculationDetails extends
AbstractPersistableCustom<
loanProductInterestRecalculationDetails.getCompoundingFrequencyOnDay(),
loanProductInterestRecalculationDetails.getIsCompoundingToBePostedAsTransaction(),
loanProductInterestRecalculationDetails.allowCompoundingOnEod(),
-
loanProductInterestRecalculationDetails.disallowInterestCalculationOnPastDue());
+
loanProductInterestRecalculationDetails.disallowInterestCalculationOnPastDue(),
+
loanProductInterestRecalculationDetails.getPreCloseInterestCalculationStrategy());
}
public void updateLoan(final Loan loan) {
@@ -198,4 +208,8 @@ public class LoanInterestRecalculationDetails extends
AbstractPersistableCustom<
public Boolean disallowInterestCalculationOnPastDue() {
return disallowInterestCalculationOnPastDue;
}
+
+ public LoanPreCloseInterestCalculationStrategy
getPreCloseInterestCalculationStrategy() {
+ return preCloseInterestCalculationStrategy;
+ }
}
diff --git
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java
index 661076c89..f9a3373e1 100644
---
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java
+++
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/LoanApplicationTerms.java
@@ -52,7 +52,7 @@ import
org.apache.fineract.portfolio.loanproduct.domain.AmortizationMethod;
import
org.apache.fineract.portfolio.loanproduct.domain.InterestCalculationPeriodMethod;
import org.apache.fineract.portfolio.loanproduct.domain.InterestMethod;
import
org.apache.fineract.portfolio.loanproduct.domain.InterestRecalculationCompoundingMethod;
-import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreClosureInterestCalculationStrategy;
+import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreCloseInterestCalculationStrategy;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanProductRelatedDetail;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanRescheduleStrategyMethod;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanSupportedInterestRefundTypes;
@@ -173,7 +173,7 @@ public final class LoanApplicationTerms {
private BigDecimal principalThresholdForLastInstalment;
private Integer installmentAmountInMultiplesOf;
- private LoanPreClosureInterestCalculationStrategy
preClosureInterestCalculationStrategy;
+ private LoanPreCloseInterestCalculationStrategy
preClosureInterestCalculationStrategy;
private Money approvedPrincipal;
@@ -450,7 +450,7 @@ public final class LoanApplicationTerms {
final InterestRecalculationCompoundingMethod
interestRecalculationCompoundingMethod,
final CalendarInstance compoundingCalendarInstance, final
RecalculationFrequencyType compoundingFrequencyType,
final BigDecimal principalThresholdForLastInstalment, final
Integer installmentAmountInMultiplesOf,
- final LoanPreClosureInterestCalculationStrategy
preClosureInterestCalculationStrategy, final Calendar loanCalendar,
+ final LoanPreCloseInterestCalculationStrategy
preClosureInterestCalculationStrategy, final Calendar loanCalendar,
BigDecimal approvedAmount, List<LoanTermVariationsData>
loanTermVariations,
Boolean isInterestChargedFromDateSameAsDisbursalDateEnabled, final
Integer numberOfDays,
boolean isSkipRepaymentOnFirstDayOfMonth, final HolidayDetailDTO
holidayDetailDTO, final boolean allowCompoundingOnEod,
@@ -494,7 +494,7 @@ public final class LoanApplicationTerms {
final RecalculationFrequencyType recalculationFrequencyType, final
CalendarInstance restCalendarInstance,
final InterestRecalculationCompoundingMethod compoundingMethod,
final CalendarInstance compoundingCalendarInstance,
final RecalculationFrequencyType compoundingFrequencyType,
- final LoanPreClosureInterestCalculationStrategy
loanPreClosureInterestCalculationStrategy,
+ final LoanPreCloseInterestCalculationStrategy
loanPreClosureInterestCalculationStrategy,
final LoanRescheduleStrategyMethod rescheduleStrategyMethod, final
Calendar loanCalendar, BigDecimal approvedAmount,
BigDecimal annualNominalInterestRate, final
List<LoanTermVariationsData> loanTermVariations,
final CalendarHistoryDataWrapper calendarHistoryDataWrapper, final
Integer numberOfDays,
@@ -574,7 +574,7 @@ public final class LoanApplicationTerms {
final CalendarInstance restCalendarInstance, final
RecalculationFrequencyType recalculationFrequencyType,
final CalendarInstance compoundingCalendarInstance, final
RecalculationFrequencyType compoundingFrequencyType,
final BigDecimal principalThresholdForLastInstalment, final
Integer installmentAmountInMultiplesOf,
- final LoanPreClosureInterestCalculationStrategy
preClosureInterestCalculationStrategy, final Calendar loanCalendar,
+ final LoanPreCloseInterestCalculationStrategy
preClosureInterestCalculationStrategy, final Calendar loanCalendar,
BigDecimal approvedAmount, List<LoanTermVariationsData>
loanTermVariations,
final CalendarHistoryDataWrapper calendarHistoryDataWrapper,
Boolean isInterestChargedFromDateSameAsDisbursalDateEnabled,
final Integer numberOfDays, final boolean
isSkipRepaymentOnFirstDayOfMonth, final HolidayDetailDTO holidayDetailDTO,
@@ -1795,7 +1795,7 @@ public final class LoanApplicationTerms {
return this.interestCalculationPeriodMethod;
}
- public LoanPreClosureInterestCalculationStrategy
getPreClosureInterestCalculationStrategy() {
+ public LoanPreCloseInterestCalculationStrategy
getPreClosureInterestCalculationStrategy() {
return this.preClosureInterestCalculationStrategy;
}
diff --git
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductInterestRecalculationData.java
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductInterestRecalculationData.java
index 9820a6316..478cc47c1 100644
---
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductInterestRecalculationData.java
+++
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/data/LoanProductInterestRecalculationData.java
@@ -26,7 +26,7 @@ import java.io.Serializable;
import lombok.Getter;
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
import
org.apache.fineract.portfolio.loanproduct.domain.InterestRecalculationCompoundingMethod;
-import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreClosureInterestCalculationStrategy;
+import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreCloseInterestCalculationStrategy;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanRescheduleStrategyMethod;
@Getter
@@ -102,7 +102,7 @@ public class LoanProductInterestRecalculationData
implements Serializable {
final boolean isArrearsBasedOnOriginalSchedule = false;
final boolean isCompoundingToBePostedAsTransaction = false;
final EnumOptionData preCloseInterestCalculationStrategy =
preCloseInterestCalculationStrategy(
-
LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE);
+ LoanPreCloseInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE);
final boolean allowCompoundingOnEod = false;
final boolean disallowInterestCalculationOnPastDue = false;
diff --git
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanPreClosureInterestCalculationStrategy.java
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanPreCloseInterestCalculationStrategy.java
similarity index 76%
rename from
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanPreClosureInterestCalculationStrategy.java
rename to
fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanPreCloseInterestCalculationStrategy.java
index 25ce5dd0b..fb653f8ed 100644
---
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanPreClosureInterestCalculationStrategy.java
+++
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanPreCloseInterestCalculationStrategy.java
@@ -21,7 +21,7 @@ package org.apache.fineract.portfolio.loanproduct.domain;
import java.util.HashMap;
import java.util.Map;
-public enum LoanPreClosureInterestCalculationStrategy {
+public enum LoanPreCloseInterestCalculationStrategy {
NONE(0, "loanPreClosureInterestCalculationStrategy.none"), //
TILL_PRE_CLOSURE_DATE(1,
"loanPreClosureInterestCalculationStrategy.tillPreClosureDate"), //
@@ -33,13 +33,13 @@ public enum LoanPreClosureInterestCalculationStrategy {
private final Integer value;
private final String code;
- private static final Map<Integer,
LoanPreClosureInterestCalculationStrategy> intToEnumMap = new HashMap<>();
+ private static final Map<Integer, LoanPreCloseInterestCalculationStrategy>
intToEnumMap = new HashMap<>();
private static int minValue;
private static int maxValue;
static {
int i = 0;
- for (final LoanPreClosureInterestCalculationStrategy type :
LoanPreClosureInterestCalculationStrategy.values()) {
+ for (final LoanPreCloseInterestCalculationStrategy type :
LoanPreCloseInterestCalculationStrategy.values()) {
if (i == 0) {
minValue = type.value;
}
@@ -54,11 +54,11 @@ public enum LoanPreClosureInterestCalculationStrategy {
}
}
- public static LoanPreClosureInterestCalculationStrategy fromInt(final
Integer ruleTypeValue) {
+ public static LoanPreCloseInterestCalculationStrategy fromInt(final
Integer ruleTypeValue) {
return intToEnumMap.get(ruleTypeValue);
}
- LoanPreClosureInterestCalculationStrategy(final Integer value, final
String code) {
+ LoanPreCloseInterestCalculationStrategy(final Integer value, final String
code) {
this.value = value;
this.code = code;
}
@@ -80,10 +80,10 @@ public enum LoanPreClosureInterestCalculationStrategy {
}
public boolean calculateTillRestFrequencyEnabled() {
- return
this.getValue().equals(LoanPreClosureInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE.getValue());
+ return
this.getValue().equals(LoanPreCloseInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE.getValue());
}
public boolean calculateTillPreClosureDateEnabled() {
- return
this.getValue().equals(LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getValue());
+ return
this.getValue().equals(LoanPreCloseInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getValue());
}
}
diff --git
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java
index cbc6d2b07..c28b590fc 100644
---
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java
+++
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProduct.java
@@ -1594,10 +1594,10 @@ public class LoanProduct extends
AbstractPersistableCustom<Long> {
return isBasedOnOriginalSchedule;
}
- public LoanPreClosureInterestCalculationStrategy
preCloseInterestCalculationStrategy() {
- LoanPreClosureInterestCalculationStrategy
preCloseInterestCalculationStrategy =
LoanPreClosureInterestCalculationStrategy.NONE;
+ public LoanPreCloseInterestCalculationStrategy
preCloseInterestCalculationStrategy() {
+ LoanPreCloseInterestCalculationStrategy
preCloseInterestCalculationStrategy =
LoanPreCloseInterestCalculationStrategy.NONE;
if (this.isInterestRecalculationEnabled()) {
- preCloseInterestCalculationStrategy =
getProductInterestRecalculationDetails().preCloseInterestCalculationStrategy();
+ preCloseInterestCalculationStrategy =
getProductInterestRecalculationDetails().getPreCloseInterestCalculationStrategy();
}
return preCloseInterestCalculationStrategy;
}
diff --git
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductInterestRecalculationDetails.java
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductInterestRecalculationDetails.java
index ecca9c1dd..e9bc005f9 100644
---
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductInterestRecalculationDetails.java
+++
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/domain/LoanProductInterestRecalculationDetails.java
@@ -88,7 +88,7 @@ public class LoanProductInterestRecalculationDetails extends
AbstractPersistable
private boolean isArrearsBasedOnOriginalSchedule;
@Column(name = "pre_close_interest_calculation_strategy")
- private Integer preClosureInterestCalculationStrategy;
+ private Integer preCloseInterestCalculationStrategy;
@Column(name = "is_compounding_to_be_posted_as_transaction")
private Boolean isCompoundingToBePostedAsTransaction;
@@ -159,7 +159,7 @@ public class LoanProductInterestRecalculationDetails
extends AbstractPersistable
Integer preCloseInterestCalculationStrategy = command
.integerValueOfParameterNamed(LoanProductConstants.preClosureInterestCalculationStrategyParamName);
if (preCloseInterestCalculationStrategy == null) {
- preCloseInterestCalculationStrategy =
LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getValue();
+ preCloseInterestCalculationStrategy =
LoanPreCloseInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getValue();
}
final boolean isCompoundingToBePostedAsTransaction = command
@@ -196,7 +196,7 @@ public class LoanProductInterestRecalculationDetails
extends AbstractPersistable
this.compoundingFrequencyOnDay = compoundingFrequencyOnDay;
this.compoundingFrequencyWeekday = compoundingFrequencyWeekday;
this.isArrearsBasedOnOriginalSchedule =
isArrearsBasedOnOriginalSchedule;
- this.preClosureInterestCalculationStrategy =
preCloseInterestCalculationStrategy;
+ this.preCloseInterestCalculationStrategy =
preCloseInterestCalculationStrategy;
this.isCompoundingToBePostedAsTransaction =
isCompoundingToBePostedAsTransaction;
this.allowCompoundingOnEod = allowCompoundingOnEod;
this.disallowInterestCalculationOnPastDue =
disallowInterestCalculationOnPastDue;
@@ -397,13 +397,13 @@ public class LoanProductInterestRecalculationDetails
extends AbstractPersistable
}
if
(command.isChangeInIntegerParameterNamed(LoanProductConstants.preClosureInterestCalculationStrategyParamName,
- this.preClosureInterestCalculationStrategy)) {
+ this.preCloseInterestCalculationStrategy)) {
Integer newValue =
command.integerValueOfParameterNamed(LoanProductConstants.preClosureInterestCalculationStrategyParamName);
if (newValue == null) {
- newValue =
LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getValue();
+ newValue =
LoanPreCloseInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getValue();
}
actualChanges.put(LoanProductConstants.preClosureInterestCalculationStrategyParamName,
newValue);
- this.preClosureInterestCalculationStrategy = newValue;
+ this.preCloseInterestCalculationStrategy = newValue;
}
if
(command.isChangeInBooleanParameterNamed(LoanProductConstants.isCompoundingToBePostedAsTransactionParamName,
@@ -443,8 +443,8 @@ public class LoanProductInterestRecalculationDetails
extends AbstractPersistable
return this.isArrearsBasedOnOriginalSchedule;
}
- public LoanPreClosureInterestCalculationStrategy
preCloseInterestCalculationStrategy() {
- return
LoanPreClosureInterestCalculationStrategy.fromInt(this.preClosureInterestCalculationStrategy);
+ public LoanPreCloseInterestCalculationStrategy
getPreCloseInterestCalculationStrategy() {
+ return
LoanPreCloseInterestCalculationStrategy.fromInt(this.preCloseInterestCalculationStrategy);
}
public Integer getRestFrequencyNthDay() {
diff --git
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java
index aa3b6ac00..af8e2d8b6 100644
---
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java
+++
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanDropdownReadPlatformServiceImpl.java
@@ -49,7 +49,7 @@ import
org.apache.fineract.portfolio.loanproduct.domain.AmortizationMethod;
import
org.apache.fineract.portfolio.loanproduct.domain.InterestCalculationPeriodMethod;
import org.apache.fineract.portfolio.loanproduct.domain.InterestMethod;
import
org.apache.fineract.portfolio.loanproduct.domain.InterestRecalculationCompoundingMethod;
-import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreClosureInterestCalculationStrategy;
+import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreCloseInterestCalculationStrategy;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanProductValueConditionType;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanRescheduleStrategyMethod;
import
org.apache.fineract.portfolio.loanproduct.domain.RecalculationFrequencyType;
@@ -175,8 +175,8 @@ public class LoanDropdownReadPlatformServiceImpl implements
LoanDropdownReadPlat
@Override
public List<EnumOptionData>
retrievePreCloseInterestCalculationStrategyOptions() {
- return
Arrays.asList(preCloseInterestCalculationStrategy(LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE),
-
preCloseInterestCalculationStrategy(LoanPreClosureInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE));
+ return
Arrays.asList(preCloseInterestCalculationStrategy(LoanPreCloseInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE),
+
preCloseInterestCalculationStrategy(LoanPreCloseInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE));
}
@Override
diff --git
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanEnumerations.java
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanEnumerations.java
index acf6abb04..2711e7bcd 100644
---
a/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanEnumerations.java
+++
b/fineract-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/service/LoanEnumerations.java
@@ -33,7 +33,7 @@ import
org.apache.fineract.portfolio.loanproduct.domain.AmortizationMethod;
import
org.apache.fineract.portfolio.loanproduct.domain.InterestCalculationPeriodMethod;
import org.apache.fineract.portfolio.loanproduct.domain.InterestMethod;
import
org.apache.fineract.portfolio.loanproduct.domain.InterestRecalculationCompoundingMethod;
-import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreClosureInterestCalculationStrategy;
+import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreCloseInterestCalculationStrategy;
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductParamType;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanProductValueConditionType;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanRescheduleStrategyMethod;
@@ -522,19 +522,19 @@ public final class LoanEnumerations {
}
public static EnumOptionData preCloseInterestCalculationStrategy(final int
id) {
- return
preCloseInterestCalculationStrategy(LoanPreClosureInterestCalculationStrategy.fromInt(id));
+ return
preCloseInterestCalculationStrategy(LoanPreCloseInterestCalculationStrategy.fromInt(id));
}
- public static EnumOptionData preCloseInterestCalculationStrategy(final
LoanPreClosureInterestCalculationStrategy type) {
+ public static EnumOptionData preCloseInterestCalculationStrategy(final
LoanPreCloseInterestCalculationStrategy type) {
EnumOptionData optionData = null;
switch (type) {
case TILL_PRE_CLOSURE_DATE:
- optionData = new
EnumOptionData(LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getValue().longValue(),
-
LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getCode(),
"Till Pre-Close Date");
+ optionData = new
EnumOptionData(LoanPreCloseInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getValue().longValue(),
+
LoanPreCloseInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE.getCode(), "Till
Pre-Close Date");
break;
case TILL_REST_FREQUENCY_DATE:
- optionData = new
EnumOptionData(LoanPreClosureInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE.getValue().longValue(),
-
LoanPreClosureInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE.getCode(),
"Till Rest Frequency Date");
+ optionData = new
EnumOptionData(LoanPreCloseInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE.getValue().longValue(),
+
LoanPreCloseInterestCalculationStrategy.TILL_REST_FREQUENCY_DATE.getCode(),
"Till Rest Frequency Date");
break;
case NONE:
break;
diff --git
a/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/module-changelog-master.xml
b/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/module-changelog-master.xml
index 49f9f17fc..3ee2905cd 100644
---
a/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/module-changelog-master.xml
+++
b/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/module-changelog-master.xml
@@ -47,4 +47,5 @@
<include relativeToChangelogFile="true"
file="parts/1022_add_interest_refund_support.xml"/>
<include relativeToChangelogFile="true"
file="parts/1023_add_charge_off_behaviour.xml"/>
<include relativeToChangelogFile="true"
file="parts/1024_accrual_adjustment_transaction_type.xml"/>
+ <include relativeToChangelogFile="true"
file="parts/1025_store_pre_closure_strategy_to_loan_level.xml"/>
</databaseChangeLog>
diff --git
a/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/parts/1025_store_pre_closure_strategy_to_loan_level.xml
b/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/parts/1025_store_pre_closure_strategy_to_loan_level.xml
new file mode 100644
index 000000000..c243c2ba7
--- /dev/null
+++
b/fineract-loan/src/main/resources/db/changelog/tenant/module/loan/parts/1025_store_pre_closure_strategy_to_loan_level.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.3.xsd">
+
+ <changeSet author="fineract" id="1024-1">
+ <addColumn tableName="m_loan_recalculation_details">
+ <column defaultValueNumeric="1"
name="pre_close_interest_calculation_strategy" type="SMALLINT">
+ <constraints nullable="false"/>
+ </column>
+ </addColumn>
+ <sql>
+ UPDATE m_loan_recalculation_details SET
pre_close_interest_calculation_strategy = 2 WHERE loan_id IN (
+ SELECT ml.id FROM m_loan ml,
m_product_loan_recalculation_details plrd WHERE plrd.product_id = ml.product_id
AND plrd.pre_close_interest_calculation_strategy = 2
+ )
+ </sql>
+ </changeSet>
+</databaseChangeLog>
diff --git
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java
index b88f6b3cb..6d78a6c9d 100644
---
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java
+++
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java
@@ -93,7 +93,7 @@ import
org.apache.fineract.portfolio.loanproduct.domain.AllocationType;
import
org.apache.fineract.portfolio.loanproduct.domain.CreditAllocationTransactionType;
import org.apache.fineract.portfolio.loanproduct.domain.DueType;
import
org.apache.fineract.portfolio.loanproduct.domain.FutureInstallmentAllocationRule;
-import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreClosureInterestCalculationStrategy;
+import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreCloseInterestCalculationStrategy;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanProductRelatedDetail;
import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType;
import org.springframework.transaction.annotation.Propagation;
@@ -1657,10 +1657,10 @@ public class
AdvancedPaymentScheduleTransactionProcessor extends AbstractLoanRep
private LocalDate
calculateNewPayDateInCaseOfInAdvancePayment(LoanTransaction loanTransaction,
LoanRepaymentScheduleInstallment inAdvanceInstallment) {
- LoanPreClosureInterestCalculationStrategy strategy =
loanTransaction.getLoan().getLoanProduct()
- .preCloseInterestCalculationStrategy();
+ LoanPreCloseInterestCalculationStrategy strategy =
loanTransaction.getLoan().getLoanInterestRecalculationDetails()
+ .getPreCloseInterestCalculationStrategy();
- LocalDate payDate = switch (strategy) {
+ return switch (strategy) {
case TILL_PRE_CLOSURE_DATE -> loanTransaction.getTransactionDate();
// TODO use isInPeriod
case TILL_REST_FREQUENCY_DATE ->
loanTransaction.getTransactionDate().isAfter(inAdvanceInstallment.getFromDate())
//
@@ -1669,7 +1669,6 @@ public class AdvancedPaymentScheduleTransactionProcessor
extends AbstractLoanRep
: loanTransaction.getTransactionDate(); //
case NONE -> throw new IllegalStateException("Unexpected
PreClosureInterestCalculationStrategy: NONE");
};
- return payDate;
}
@NotNull
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java
index 51813bb31..f967e897b 100644
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanproduct/serialization/LoanProductDataValidator.java
@@ -61,7 +61,7 @@ import
org.apache.fineract.portfolio.loanproduct.domain.AmortizationMethod;
import
org.apache.fineract.portfolio.loanproduct.domain.InterestCalculationPeriodMethod;
import org.apache.fineract.portfolio.loanproduct.domain.InterestMethod;
import
org.apache.fineract.portfolio.loanproduct.domain.InterestRecalculationCompoundingMethod;
-import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreClosureInterestCalculationStrategy;
+import
org.apache.fineract.portfolio.loanproduct.domain.LoanPreCloseInterestCalculationStrategy;
import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanProductPaymentAllocationRule;
import
org.apache.fineract.portfolio.loanproduct.domain.LoanProductValueConditionType;
@@ -1224,7 +1224,7 @@ public final class LoanProductDataValidator {
.extractIntegerWithLocaleNamed(LoanProductConstants.preClosureInterestCalculationStrategyParamName,
element);
baseDataValidator.reset().parameter(LoanProductConstants.preClosureInterestCalculationStrategyParamName)
.value(preCloseInterestCalculationStrategy).ignoreIfNull().inMinMaxRange(
-
LoanPreClosureInterestCalculationStrategy.getMinValue(),
LoanPreClosureInterestCalculationStrategy.getMaxValue());
+ LoanPreCloseInterestCalculationStrategy.getMinValue(),
LoanPreCloseInterestCalculationStrategy.getMaxValue());
}
public void validateForUpdate(final JsonCommand command, final LoanProduct
loanProduct) {
diff --git
a/fineract-provider/src/test/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGeneratorTest.java
b/fineract-provider/src/test/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGeneratorTest.java
index 61cd464f9..3cdf6995c 100644
---
a/fineract-provider/src/test/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGeneratorTest.java
+++
b/fineract-provider/src/test/java/org/apache/fineract/portfolio/loanaccount/loanschedule/domain/DefaultScheduledDateGeneratorTest.java
@@ -29,7 +29,7 @@ import static
org.apache.fineract.portfolio.loanaccount.loanschedule.domain.Loan
import static
org.apache.fineract.portfolio.loanproduct.domain.AmortizationMethod.EQUAL_PRINCIPAL;
import static
org.apache.fineract.portfolio.loanproduct.domain.InterestCalculationPeriodMethod.SAME_AS_REPAYMENT_PERIOD;
import static
org.apache.fineract.portfolio.loanproduct.domain.InterestMethod.FLAT;
-import static
org.apache.fineract.portfolio.loanproduct.domain.LoanPreClosureInterestCalculationStrategy.NONE;
+import static
org.apache.fineract.portfolio.loanproduct.domain.LoanPreCloseInterestCalculationStrategy.NONE;
import static
org.apache.fineract.portfolio.loanproduct.domain.RepaymentStartDateType.DISBURSEMENT_DATE;
import static org.apache.fineract.util.TimeZoneConstants.ASIA_MANILA_ID;
import static org.apache.fineract.util.TimeZoneConstants.EUROPE_BERLIN_ID;