FINERACT-1971: Loan re-aging foundational implementation
This commit is contained in:
committed by
Arnold Gálovics
parent
0d06e2bb2c
commit
4d4502fbe0
+30
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.api;
|
||||
|
||||
public interface LoanReAgingApiConstants {
|
||||
|
||||
String localeParameterName = "locale";
|
||||
String dateFormatParameterName = "dateFormat";
|
||||
String externalIdParameterName = "externalId";
|
||||
|
||||
String frequency = "frequency";
|
||||
String startDate = "startDate";
|
||||
String numberOfInstallments = "numberOfInstallments";
|
||||
}
|
||||
+3
@@ -19,6 +19,7 @@
|
||||
package org.apache.fineract.portfolio.loanaccount.data;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType;
|
||||
|
||||
/**
|
||||
* Immutable data object represent loan status enumerations.
|
||||
@@ -55,6 +56,7 @@ public class LoanTransactionEnumData {
|
||||
private final boolean chargeback;
|
||||
private final boolean chargeoff;
|
||||
private final boolean downPayment;
|
||||
private final boolean reAge;
|
||||
|
||||
public LoanTransactionEnumData(final Long id, final String code, final String value) {
|
||||
this.id = id;
|
||||
@@ -85,6 +87,7 @@ public class LoanTransactionEnumData {
|
||||
this.chargeAdjustment = Long.valueOf(26).equals(this.id);
|
||||
this.chargeoff = Long.valueOf(27).equals(this.id);
|
||||
this.downPayment = Long.valueOf(28).equals(this.id);
|
||||
this.reAge = Long.valueOf(LoanTransactionType.REAGE.getValue()).equals(this.id);
|
||||
}
|
||||
|
||||
public boolean isRepaymentType() {
|
||||
|
||||
@@ -4280,6 +4280,13 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
return cumulativePaid;
|
||||
}
|
||||
|
||||
public Money getTotalPrincipalOutstandingUntil(LocalDate date) {
|
||||
return getRepaymentScheduleInstallments().stream()
|
||||
.filter(installment -> installment.getDueDate().isBefore(date) || installment.getDueDate().isEqual(date))
|
||||
.map(installment -> installment.getPrincipalOutstanding(loanCurrency())).reduce(Money.zero(loanCurrency()), Money::add);
|
||||
|
||||
}
|
||||
|
||||
private Money getTotalInterestOutstandingOnLoan() {
|
||||
Money cumulativeInterest = Money.zero(loanCurrency());
|
||||
|
||||
|
||||
+5
-1
@@ -316,7 +316,7 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
&& loanTransaction.getOverPaymentPortion(currency).isEqualTo(newLoanTransaction.getOverPaymentPortion(currency));
|
||||
}
|
||||
|
||||
private LoanTransaction(final Loan loan, final Office office, final Integer typeOf, final LocalDate dateOf, final BigDecimal amount,
|
||||
public LoanTransaction(final Loan loan, final Office office, final Integer typeOf, final LocalDate dateOf, final BigDecimal amount,
|
||||
final BigDecimal principalPortion, final BigDecimal interestPortion, final BigDecimal feeChargesPortion,
|
||||
final BigDecimal penaltyChargesPortion, final BigDecimal overPaymentPortion, final boolean reversed,
|
||||
final PaymentDetail paymentDetail, final ExternalId externalId) {
|
||||
@@ -681,6 +681,10 @@ public class LoanTransaction extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
return getTypeOf().isChargeOff() && isNotReversed();
|
||||
}
|
||||
|
||||
public boolean isReAge() {
|
||||
return getTypeOf().isReAge() && isNotReversed();
|
||||
}
|
||||
|
||||
public boolean isIdentifiedBy(final Long identifier) {
|
||||
return getId().equals(identifier);
|
||||
}
|
||||
|
||||
+7
-1
@@ -60,7 +60,8 @@ public enum LoanTransactionType {
|
||||
CHARGEBACK(25, "loanTransactionType.chargeback"), //
|
||||
CHARGE_ADJUSTMENT(26, "loanTransactionType.chargeAdjustment"), //
|
||||
CHARGE_OFF(27, "loanTransactionType.chargeOff"), //
|
||||
DOWN_PAYMENT(28, "loanTransactionType.downPayment");
|
||||
DOWN_PAYMENT(28, "loanTransactionType.downPayment"), //
|
||||
REAGE(29, "loanTransactionType.reAge");
|
||||
|
||||
private final Integer value;
|
||||
private final String code;
|
||||
@@ -104,6 +105,7 @@ public enum LoanTransactionType {
|
||||
case 26 -> LoanTransactionType.CHARGE_ADJUSTMENT;
|
||||
case 27 -> LoanTransactionType.CHARGE_OFF;
|
||||
case 28 -> LoanTransactionType.DOWN_PAYMENT;
|
||||
case 29 -> LoanTransactionType.REAGE;
|
||||
default -> LoanTransactionType.INVALID;
|
||||
};
|
||||
}
|
||||
@@ -192,6 +194,10 @@ public enum LoanTransactionType {
|
||||
return this.equals(LoanTransactionType.CHARGE_OFF);
|
||||
}
|
||||
|
||||
public boolean isReAge() {
|
||||
return this.equals(LoanTransactionType.REAGE);
|
||||
}
|
||||
|
||||
public boolean isDownPayment() {
|
||||
return this.equals(LoanTransactionType.DOWN_PAYMENT);
|
||||
}
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.domain.reaging;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.Table;
|
||||
import java.time.LocalDate;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
|
||||
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
|
||||
|
||||
@Entity
|
||||
@Table(name = "m_loan_reage_parameter")
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class LoanReAgeParameter extends AbstractAuditableWithUTCDateTimeCustom {
|
||||
|
||||
// intentionally not doing a JPA relationship since it's not necessary
|
||||
@Column(name = "loan_transaction_id", nullable = false)
|
||||
private Long loanTransactionId;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
@Column(name = "frequency", nullable = false)
|
||||
private PeriodFrequencyType frequency;
|
||||
|
||||
@Column(name = "start_date", nullable = false)
|
||||
private LocalDate startDate;
|
||||
|
||||
@Column(name = "number_of_installments", nullable = false)
|
||||
private Integer numberOfInstallments;
|
||||
|
||||
// for JPA, don't use
|
||||
protected LoanReAgeParameter() {}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
package org.apache.fineract.portfolio.loanaccount.domain.reaging;
|
||||
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
public interface LoanReAgingParameterRepository extends JpaRepository<LoanReAgeParameter, Long> {
|
||||
|
||||
Optional<LoanReAgeParameter> findByLoanTransactionId(@Param("loanTransactionId") Long loanTransactionId);
|
||||
}
|
||||
+2
@@ -313,6 +313,8 @@ public final class LoanEnumerations {
|
||||
LoanTransactionType.CHARGE_OFF.getCode(), "Charge-off");
|
||||
case DOWN_PAYMENT -> new LoanTransactionEnumData(LoanTransactionType.DOWN_PAYMENT.getValue().longValue(),
|
||||
LoanTransactionType.DOWN_PAYMENT.getCode(), "Down Payment");
|
||||
case REAGE -> new LoanTransactionEnumData(LoanTransactionType.REAGE.getValue().longValue(), LoanTransactionType.REAGE.getCode(),
|
||||
"Re-age");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user