FINERACT-1981: Introduce Interest should not be calculated on past due principal amount

This commit is contained in:
Janos Meszaros
2024-11-29 11:59:18 +01:00
committed by Adam Saghy
parent 3858611190
commit 4cb849fa17
17 changed files with 287 additions and 85 deletions
@@ -47,6 +47,7 @@ public class LoanInterestRecalculationData {
private Boolean isCompoundingToBePostedAsTransaction;
private CalendarData compoundingCalendarData;
private Boolean allowCompoundingOnEod;
private Boolean disallowInterestCalculationOnPastDue;
public LoanInterestRecalculationData(final Long id, final Long loanId, final EnumOptionData interestRecalculationCompoundingType,
final EnumOptionData rescheduleStrategyType, final CalendarData calendarData,
@@ -56,7 +57,7 @@ public class LoanInterestRecalculationData {
final EnumOptionData recalculationCompoundingFrequencyType, final Integer recalculationCompoundingFrequencyInterval,
final EnumOptionData recalculationCompoundingFrequencyNthDay, final EnumOptionData recalculationCompoundingFrequencyWeekday,
final Integer recalculationCompoundingFrequencyOnDay, final Boolean isCompoundingToBePostedAsTransaction,
final Boolean allowCompoundingOnEod) {
final Boolean allowCompoundingOnEod, final Boolean disallowInterestCalculationOnPastDue) {
this.id = id;
this.loanId = loanId;
this.interestRecalculationCompoundingType = interestRecalculationCompoundingType;
@@ -75,6 +76,7 @@ public class LoanInterestRecalculationData {
this.compoundingCalendarData = compoundingCalendarData;
this.isCompoundingToBePostedAsTransaction = isCompoundingToBePostedAsTransaction;
this.allowCompoundingOnEod = allowCompoundingOnEod;
this.disallowInterestCalculationOnPastDue = disallowInterestCalculationOnPastDue;
}
public LoanInterestRecalculationData withCalendarData(final CalendarData calendarData, CalendarData compoundingCalendarData) {
@@ -88,6 +88,9 @@ public class LoanInterestRecalculationDetails extends AbstractPersistableCustom<
@Column(name = "allow_compounding_on_eod")
private Boolean allowCompoundingOnEod;
@Column(name = "disallow_interest_calc_on_past_due")
private Boolean disallowInterestCalculationOnPastDue;
protected LoanInterestRecalculationDetails() {
// Default constructor for jpa repository
}
@@ -96,7 +99,7 @@ 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 allowCompoundingOnEod, final boolean disallowInterestCalculationOnPastDue) {
this.interestRecalculationCompoundingMethod = interestRecalculationCompoundingMethod;
this.rescheduleStrategyMethod = rescheduleStrategyMethod;
this.restFrequencyNthDay = restFrequencyNthDay;
@@ -111,6 +114,7 @@ public class LoanInterestRecalculationDetails extends AbstractPersistableCustom<
this.compoundingInterval = compoundingInterval;
this.isCompoundingToBePostedAsTransaction = isCompoundingToBePostedAsTransaction;
this.allowCompoundingOnEod = allowCompoundingOnEod;
this.disallowInterestCalculationOnPastDue = disallowInterestCalculationOnPastDue;
}
public static LoanInterestRecalculationDetails createFrom(
@@ -127,7 +131,8 @@ public class LoanInterestRecalculationDetails extends AbstractPersistableCustom<
loanProductInterestRecalculationDetails.getCompoundingFrequencyWeekday(),
loanProductInterestRecalculationDetails.getCompoundingFrequencyOnDay(),
loanProductInterestRecalculationDetails.getIsCompoundingToBePostedAsTransaction(),
loanProductInterestRecalculationDetails.allowCompoundingOnEod());
loanProductInterestRecalculationDetails.allowCompoundingOnEod(),
loanProductInterestRecalculationDetails.disallowInterestCalculationOnPastDue());
}
public void updateLoan(final Loan loan) {
@@ -189,4 +194,8 @@ public class LoanInterestRecalculationDetails extends AbstractPersistableCustom<
public boolean allowCompoundingOnEod() {
return this.allowCompoundingOnEod;
}
public Boolean disallowInterestCalculationOnPastDue() {
return disallowInterestCalculationOnPastDue;
}
}
@@ -97,6 +97,7 @@ public interface LoanProductConstants {
String recalculationCompoundingFrequencyNthDayParamName = "recalculationCompoundingFrequencyNthDayType";
String recalculationCompoundingFrequencyOnDayParamName = "recalculationCompoundingFrequencyOnDayType";
String isCompoundingToBePostedAsTransactionParamName = "isCompoundingToBePostedAsTransaction";
String disallowInterestCalculationOnPastDueParamName = "disallowInterestCalculationOnPastDue";
// Guarantee related
String holdGuaranteeFundsParamName = "holdGuaranteeFunds";
@@ -198,6 +198,8 @@ final class LoanProductsApiResourceSwagger {
public Boolean isCompoundingToBePostedAsTransaction;
@Schema(example = "false")
public Boolean allowCompoundingOnEod;
@Schema(example = "false")
public Boolean disallowInterestCalculationOnPastDue;
// Accounting
@Schema(example = "3")
@@ -520,6 +522,8 @@ final class LoanProductsApiResourceSwagger {
public GetLoanProductsPreClosureInterestCalculationStrategy preClosureInterestCalculationStrategy;
@Schema(example = "true")
public Boolean isArrearsBasedOnOriginalSchedule;
@Schema(example = "false")
public Boolean disallowInterestCalculationOnPastDue;
@Schema(example = "true")
public Boolean isCompoundingToBePostedAsTransaction;
@Schema(example = "true")
@@ -1182,7 +1182,7 @@ public class LoanProductData implements Serializable {
getInterestRecalculationRestOnDayType(), compoundingCalendarData, getRecalculationCompoundingFrequencyType(),
getRecalculationCompoundingFrequencyInterval(), getInterestRecalculationCompoundingNthDayType(),
getInterestRecalculationCompoundingWeekDayType(), getInterestRecalculationCompoundingOnDayType(),
isCompoundingToBePostedAsTransaction(), allowCompoundingOnEod());
isCompoundingToBePostedAsTransaction(), allowCompoundingOnEod(), disallowInterestCalculationOnPastDue());
}
private EnumOptionData getRescheduleStrategyType() {
@@ -1279,6 +1279,11 @@ public class LoanProductData implements Serializable {
return isInterestRecalculationEnabled() ? this.interestRecalculationData.isAllowCompoundingOnEod() : null;
}
@SuppressFBWarnings("NP_BOOLEAN_RETURN_NULL")
public Boolean disallowInterestCalculationOnPastDue() {
return isInterestRecalculationEnabled() ? this.interestRecalculationData.disallowInterestCalculationOnPastDue() : null;
}
public void setLoanProductConfigurableAttributes(LoanProductConfigurableAttributes loanProductConfigurableAttributes) {
this.allowAttributeOverrides = loanProductConfigurableAttributes;
}
@@ -50,6 +50,7 @@ public class LoanProductInterestRecalculationData implements Serializable {
private final boolean isCompoundingToBePostedAsTransaction;
private final EnumOptionData preClosureInterestCalculationStrategy;
private final boolean allowCompoundingOnEod;
private final Boolean disallowInterestCalculationOnPastDue;
public LoanProductInterestRecalculationData(final Long id, final Long productId,
final EnumOptionData interestRecalculationCompoundingType, final EnumOptionData rescheduleStrategyType,
@@ -59,7 +60,8 @@ public class LoanProductInterestRecalculationData implements Serializable {
final Integer recalculationCompoundingFrequencyInterval, final EnumOptionData recalculationCompoundingFrequencyNthDay,
final EnumOptionData recalculationCompoundingFrequencyWeekday, final Integer recalculationCompoundingFrequencyOnDay,
final boolean isArrearsBasedOnOriginalSchedule, boolean isCompoundingToBePostedAsTransaction,
final EnumOptionData preCloseInterestCalculationStrategy, final boolean allowCompoundingOnEod) {
final EnumOptionData preCloseInterestCalculationStrategy, final boolean allowCompoundingOnEod,
final Boolean disallowInterestCalculationOnPastDue) {
this.id = id;
this.productId = productId;
this.interestRecalculationCompoundingType = interestRecalculationCompoundingType;
@@ -78,6 +80,7 @@ public class LoanProductInterestRecalculationData implements Serializable {
this.preClosureInterestCalculationStrategy = preCloseInterestCalculationStrategy;
this.isCompoundingToBePostedAsTransaction = isCompoundingToBePostedAsTransaction;
this.allowCompoundingOnEod = allowCompoundingOnEod;
this.disallowInterestCalculationOnPastDue = disallowInterestCalculationOnPastDue;
}
public static LoanProductInterestRecalculationData sensibleDefaultsForNewLoanProductCreation() {
@@ -101,12 +104,15 @@ public class LoanProductInterestRecalculationData implements Serializable {
final EnumOptionData preCloseInterestCalculationStrategy = preCloseInterestCalculationStrategy(
LoanPreClosureInterestCalculationStrategy.TILL_PRE_CLOSURE_DATE);
final boolean allowCompoundingOnEod = false;
final boolean disallowInterestCalculationOnPastDue = false;
return new LoanProductInterestRecalculationData(id, productId, interestRecalculationCompoundingType, rescheduleStrategyType,
recalculationRestFrequencyType, recalculationRestFrequencyInterval, recalculationRestFrequencyNthDay,
recalculationRestFrequencyWeekday, recalculationRestFrequencyOnDay, recalculationCompoundingFrequencyType,
recalculationCompoundingFrequencyInterval, recalculationCompoundingFrequencyNthDay,
recalculationCompoundingFrequencyWeekday, recalculationCompoundingFrequencyOnDay, isArrearsBasedOnOriginalSchedule,
isCompoundingToBePostedAsTransaction, preCloseInterestCalculationStrategy, allowCompoundingOnEod);
isCompoundingToBePostedAsTransaction, preCloseInterestCalculationStrategy, allowCompoundingOnEod,
disallowInterestCalculationOnPastDue);
}
public boolean isArrearsBasedOnOriginalSchedule() {
@@ -124,4 +130,8 @@ public class LoanProductInterestRecalculationData implements Serializable {
public boolean isIsCompoundingToBePostedAsTransaction() {
return isCompoundingToBePostedAsTransaction;
}
public Boolean disallowInterestCalculationOnPastDue() {
return disallowInterestCalculationOnPastDue;
}
}
@@ -96,6 +96,9 @@ public class LoanProductInterestRecalculationDetails extends AbstractPersistable
@Column(name = "allow_compounding_on_eod")
private Boolean allowCompoundingOnEod;
@Column(name = "disallow_interest_calc_on_past_due")
private Boolean disallowInterestCalculationOnPastDue;
protected LoanProductInterestRecalculationDetails() {
//
}
@@ -162,11 +165,14 @@ public class LoanProductInterestRecalculationDetails extends AbstractPersistable
final boolean isCompoundingToBePostedAsTransaction = command
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.isCompoundingToBePostedAsTransactionParamName);
final boolean disallowInterestCalculationOnPastDue = command
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.disallowInterestCalculationOnPastDueParamName);
return new LoanProductInterestRecalculationDetails(interestRecalculationCompoundingMethod, loanRescheduleStrategyMethod,
recurrenceFrequency, recurrenceInterval, recurrenceOnNthDay, recurrenceOnDay, recurrenceOnWeekday,
compoundingRecurrenceFrequency, compoundingInterval, compoundingRecurrenceOnNthDay, compoundingRecurrenceOnDay,
compoundingRecurrenceOnWeekday, isArrearsBasedOnOriginalSchedule, preCloseInterestCalculationStrategy,
isCompoundingToBePostedAsTransaction, allowCompoundingOnEod);
isCompoundingToBePostedAsTransaction, allowCompoundingOnEod, disallowInterestCalculationOnPastDue);
}
private LoanProductInterestRecalculationDetails(final Integer interestRecalculationCompoundingMethod,
@@ -175,7 +181,8 @@ public class LoanProductInterestRecalculationDetails extends AbstractPersistable
Integer compoundingFrequencyType, Integer compoundingInterval, final Integer compoundingFrequencyNthDay,
final Integer compoundingFrequencyOnDay, final Integer compoundingFrequencyWeekday,
final boolean isArrearsBasedOnOriginalSchedule, final Integer preCloseInterestCalculationStrategy,
final boolean isCompoundingToBePostedAsTransaction, final boolean allowCompoundingOnEod) {
final boolean isCompoundingToBePostedAsTransaction, final boolean allowCompoundingOnEod,
final boolean disallowInterestCalculationOnPastDue) {
this.interestRecalculationCompoundingMethod = interestRecalculationCompoundingMethod;
this.rescheduleStrategyMethod = rescheduleStrategyMethod;
this.restFrequencyType = restFrequencyType;
@@ -192,6 +199,7 @@ public class LoanProductInterestRecalculationDetails extends AbstractPersistable
this.preClosureInterestCalculationStrategy = preCloseInterestCalculationStrategy;
this.isCompoundingToBePostedAsTransaction = isCompoundingToBePostedAsTransaction;
this.allowCompoundingOnEod = allowCompoundingOnEod;
this.disallowInterestCalculationOnPastDue = disallowInterestCalculationOnPastDue;
}
public void updateProduct(final LoanProduct loanProduct) {
@@ -406,6 +414,13 @@ public class LoanProductInterestRecalculationDetails extends AbstractPersistable
this.isCompoundingToBePostedAsTransaction = newValue;
}
if (command.isChangeInBooleanParameterNamed(LoanProductConstants.disallowInterestCalculationOnPastDueParamName,
this.disallowInterestCalculationOnPastDue)) {
final boolean newValue = command
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.disallowInterestCalculationOnPastDueParamName);
actualChanges.put(LoanProductConstants.disallowInterestCalculationOnPastDueParamName, newValue);
this.disallowInterestCalculationOnPastDue = newValue;
}
}
public RecalculationFrequencyType getRestFrequencyType() {
@@ -463,4 +478,8 @@ public class LoanProductInterestRecalculationDetails extends AbstractPersistable
public Boolean allowCompoundingOnEod() {
return this.allowCompoundingOnEod;
}
public Boolean disallowInterestCalculationOnPastDue() {
return disallowInterestCalculationOnPastDue;
}
}