Skip to content

Commit a34eac0

Browse files
Jose Alberto Hernandezadamsaghy
authored andcommitted
FINERACT-2354: Re-aging: Interest handling configuration
1 parent 6d3e5fa commit a34eac0

File tree

18 files changed

+255
-8
lines changed

18 files changed

+255
-8
lines changed

fineract-core/src/main/java/org/apache/fineract/infrastructure/core/data/DataValidatorBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -983,7 +983,7 @@ public DataValidatorBuilder validateDateAfter(final LocalDate date) {
983983
final LocalDate dateVal = (LocalDate) this.value;
984984
if (DateUtils.isAfter(date, dateVal)) {
985985
String validationErrorCode = "validation.msg." + this.resource + "." + this.parameter + ".is.less.than.date";
986-
String defaultEnglishMessage = "The parameter `" + this.parameter + "` must be greater than the provided date" + date;
986+
String defaultEnglishMessage = "The parameter `" + this.parameter + "` must be greater than the provided date " + date;
987987
final ApiParameterError error = ApiParameterError.parameterError(validationErrorCode, defaultEnglishMessage, this.parameter,
988988
dateVal, date);
989989
this.dataValidationErrors.add(error);

fineract-core/src/main/java/org/apache/fineract/portfolio/common/service/CommonEnumerations.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828

2929
public final class CommonEnumerations {
3030

31+
public static final List<PeriodFrequencyType> BASIC_PERIOD_FREQUENCY_TYPES = List.of(PeriodFrequencyType.DAYS,
32+
PeriodFrequencyType.WEEKS, PeriodFrequencyType.MONTHS, PeriodFrequencyType.YEARS);
33+
3134
private CommonEnumerations() {
3235

3336
}

fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanApiConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ public interface LoanApiConstants {
140140
String WRITEOFFREASONS = "WriteOffReasons";
141141
// loan charge-off
142142
String CHARGE_OFF_REASONS = "ChargeOffReasons";
143+
// loan ReAge
144+
String REAGE_REASONS = "ReAgeReasons";
143145
// fore closure constants
144146
String transactionDateParamName = "transactionDate";
145147
String noteParamName = "note";
@@ -183,6 +185,7 @@ public interface LoanApiConstants {
183185
String UNDO_CONTRACT_TERMINATION_COMMAND = "undoContractTermination";
184186
String BUY_DOWN_FEE_COMMAND = "buyDownFee";
185187
String BUY_DOWN_FEE_ADJUSTMENT_COMMAND = "buyDownFeeAdjustment";
188+
String REAGE_COMMAND = "reAge";
186189

187190
// Data Validator names
188191
String LOAN_FRAUD_DATAVALIDATOR_PREFIX = "loans.fraud";

fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanReAgingApiConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,7 @@ public interface LoanReAgingApiConstants {
2828
String frequencyNumber = "frequencyNumber";
2929
String startDate = "startDate";
3030
String numberOfInstallments = "numberOfInstallments";
31+
32+
String reAgeInterestHandlingParamName = "reAgeInterestHandling";
33+
String reasonCodeValueIdParamName = "reasonCodeValueId";
3134
}

fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoanTransactionsApiResourceSwagger.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,11 @@ private PostLoansLoanIdTransactionsRequest() {}
368368
public String startDate;
369369
@Schema(example = "numberOfInstallments")
370370
public Integer numberOfInstallments;
371+
@Schema(example = "DEFAULT")
372+
public String reAgeInterestHandling;
373+
@Schema(example = "1")
374+
public Long reasonCodeValueId;
375+
371376
// command=reAge END
372377
@Schema(description = "Optional. Controls whether Interest Refund transaction should be created for this refund. If not provided, loan product config is used.", example = "false")
373378
public Boolean interestRefundCalculation;

fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/data/LoanTransactionData.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
import lombok.Getter;
3131
import lombok.Setter;
3232
import org.apache.fineract.infrastructure.codes.data.CodeValueData;
33+
import org.apache.fineract.infrastructure.core.data.StringEnumOptionData;
3334
import org.apache.fineract.infrastructure.core.domain.ExternalId;
3435
import org.apache.fineract.organisation.monetary.data.CurrencyData;
3536
import org.apache.fineract.portfolio.account.data.AccountTransferData;
37+
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
3638
import org.apache.fineract.portfolio.paymentdetail.data.PaymentDetailData;
3739
import org.apache.fineract.portfolio.paymenttype.data.PaymentTypeData;
3840

@@ -116,6 +118,10 @@ public class LoanTransactionData implements Serializable {
116118
private Collection<CodeValueData> classificationOptions = null;
117119
private CodeValueData classification;
118120

121+
private Collection<CodeValueData> reAgeReasonOptions = null;
122+
private Collection<PeriodFrequencyType> periodFrequencyOptions = null;
123+
private Collection<StringEnumOptionData> reAgeInterestHandlingOptions = null;
124+
119125
public static LoanTransactionData importInstance(BigDecimal repaymentAmount, LocalDate lastRepaymentDate, Long repaymentTypeId,
120126
Integer rowIndex, String locale, String dateFormat) {
121127
return LoanTransactionData.builder().transactionAmount(repaymentAmount).transactionDate(lastRepaymentDate)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.fineract.portfolio.loanaccount.domain.reaging;
20+
21+
import java.util.Arrays;
22+
import java.util.List;
23+
import lombok.Getter;
24+
import lombok.RequiredArgsConstructor;
25+
import org.apache.fineract.infrastructure.core.data.StringEnumOptionData;
26+
27+
@Getter
28+
@RequiredArgsConstructor
29+
public enum LoanReAgeInterestHandlingType {
30+
31+
DEFAULT("loanReAgeInterestHandlingType.default", "Default"), //
32+
WAIVE_INTEREST("loanReAgeInterestHandlingType.waiveInterest", "Waive Interest"), //
33+
EQUAL_AMORTIZATION("loanReAgeInterestHandlingType.equalAmortization", "Equal Amortization of Outstanding amount"), //
34+
;
35+
36+
private final String code;
37+
private final String humanReadableName;
38+
39+
public static List<StringEnumOptionData> getValuesAsEnumOptionDataList() {
40+
return Arrays.stream(values()).map(v -> new StringEnumOptionData(v.name(), v.getCode(), v.getHumanReadableName())).toList();
41+
}
42+
43+
public StringEnumOptionData asEnumOptionData() {
44+
return new StringEnumOptionData(name(), getCode(), getHumanReadableName());
45+
}
46+
47+
}

fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/reaging/LoanReAgeParameter.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@
2323
import jakarta.persistence.EnumType;
2424
import jakarta.persistence.Enumerated;
2525
import jakarta.persistence.JoinColumn;
26+
import jakarta.persistence.ManyToOne;
2627
import jakarta.persistence.OneToOne;
2728
import jakarta.persistence.Table;
2829
import java.time.LocalDate;
2930
import lombok.AllArgsConstructor;
3031
import lombok.Getter;
32+
import org.apache.fineract.infrastructure.codes.domain.CodeValue;
3133
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
3234
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
3335
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransaction;
@@ -56,10 +58,19 @@ public class LoanReAgeParameter extends AbstractAuditableWithUTCDateTimeCustom<L
5658
@Column(name = "number_of_installments", nullable = false)
5759
private Integer numberOfInstallments;
5860

61+
@Enumerated(EnumType.STRING)
62+
@Column(name = "interest_handling_type")
63+
private LoanReAgeInterestHandlingType interestHandlingType;
64+
65+
@ManyToOne
66+
@JoinColumn(name = "reage_reason_code_value_id", nullable = true)
67+
private CodeValue reageReason;
68+
5969
// for JPA, don't use
6070
protected LoanReAgeParameter() {}
6171

6272
public LoanReAgeParameter getCopy(LoanTransaction loanTransaction) {
63-
return new LoanReAgeParameter(loanTransaction, frequencyType, frequencyNumber, startDate, numberOfInstallments);
73+
return new LoanReAgeParameter(loanTransaction, frequencyType, frequencyNumber, startDate, numberOfInstallments,
74+
interestHandlingType, reageReason);
6475
}
6576
}

fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/mapper/LoanTransactionMapper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ public interface LoanTransactionMapper {
3333
@Mapping(target = "loanRepaymentScheduleInstallments", ignore = true)
3434
@Mapping(target = "writeOffReasonOptions", ignore = true)
3535
@Mapping(target = "chargeOffReasonOptions", ignore = true)
36+
@Mapping(target = "reAgeReasonOptions", ignore = true)
37+
@Mapping(target = "periodFrequencyOptions", ignore = true)
38+
@Mapping(target = "reAgeInterestHandlingOptions", ignore = true)
3639
@Mapping(target = "classificationOptions", ignore = true)
3740
@Mapping(target = "paymentTypeOptions", ignore = true)
3841
@Mapping(target = "overpaymentPortion", ignore = true)

fineract-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,5 @@ org.springframework.data.domain.Page<LoanTransactionData> retrieveLoanTransactio
165165

166166
Long getResolvedLoanTransactionId(Long transactionId, ExternalId externalTransactionId);
167167

168+
LoanTransactionData retrieveLoanReAgeTemplate(Long loanId);
168169
}

0 commit comments

Comments
 (0)