FINERACT-2042 Configurable Allocation Rules for Chargeback Transaction. PR 1 of 3 - Persistence Layer
This commit is contained in:
committed by
Peter Bagrij
parent
a77ece75f8
commit
b01ccc4619
+11
@@ -243,6 +243,9 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
|
|||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch = FetchType.LAZY)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch = FetchType.LAZY)
|
||||||
private List<LoanPaymentAllocationRule> paymentAllocationRules = new ArrayList<>();
|
private List<LoanPaymentAllocationRule> paymentAllocationRules = new ArrayList<>();
|
||||||
|
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loan", orphanRemoval = true, fetch = FetchType.LAZY)
|
||||||
|
private List<LoanCreditAllocationRule> creditAllocationRules = new ArrayList<>();
|
||||||
|
|
||||||
@Embedded
|
@Embedded
|
||||||
private LoanProductRelatedDetail loanRepaymentScheduleDetail;
|
private LoanProductRelatedDetail loanRepaymentScheduleDetail;
|
||||||
|
|
||||||
@@ -7183,6 +7186,14 @@ public class Loan extends AbstractAuditableWithUTCDateTimeCustom {
|
|||||||
this.paymentAllocationRules = loanPaymentAllocationRules;
|
this.paymentAllocationRules = loanPaymentAllocationRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<LoanCreditAllocationRule> getCreditAllocationRules() {
|
||||||
|
return creditAllocationRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreditAllocationRules(List<LoanCreditAllocationRule> loanCreditAllocationRules) {
|
||||||
|
this.creditAllocationRules = loanCreditAllocationRules;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTransactionProcessingStrategyCode() {
|
public String getTransactionProcessingStrategyCode() {
|
||||||
return transactionProcessingStrategyCode;
|
return transactionProcessingStrategyCode;
|
||||||
}
|
}
|
||||||
|
|||||||
+62
@@ -0,0 +1,62 @@
|
|||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Convert;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EnumType;
|
||||||
|
import jakarta.persistence.Enumerated;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.persistence.UniqueConstraint;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
|
||||||
|
import org.apache.fineract.portfolio.loanproduct.domain.AllocationType;
|
||||||
|
import org.apache.fineract.portfolio.loanproduct.domain.AllocationTypeListConverter;
|
||||||
|
import org.apache.fineract.portfolio.loanproduct.domain.CreditAllocationTransactionType;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Entity
|
||||||
|
@Table(name = "m_loan_credit_allocation_rule", uniqueConstraints = {
|
||||||
|
@UniqueConstraint(columnNames = { "loan_id", "transaction_type" }, name = "uq_m_loan_credit_allocation_rule") })
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
|
public class LoanCreditAllocationRule extends AbstractAuditableWithUTCDateTimeCustom {
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "loan_id", nullable = false)
|
||||||
|
private Loan loan;
|
||||||
|
|
||||||
|
@Column(name = "transaction_type", nullable = false)
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private CreditAllocationTransactionType transactionType;
|
||||||
|
|
||||||
|
@Convert(converter = AllocationTypeListConverter.class)
|
||||||
|
@Column(name = "allocation_types", nullable = false)
|
||||||
|
private List<AllocationType> allocationTypes;
|
||||||
|
|
||||||
|
}
|
||||||
+2
-2
@@ -34,10 +34,10 @@ import lombok.Getter;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
|
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
|
||||||
import org.apache.fineract.portfolio.loanproduct.domain.AllocationTypeListConverter;
|
|
||||||
import org.apache.fineract.portfolio.loanproduct.domain.FutureInstallmentAllocationRule;
|
import org.apache.fineract.portfolio.loanproduct.domain.FutureInstallmentAllocationRule;
|
||||||
import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationTransactionType;
|
import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationTransactionType;
|
||||||
import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType;
|
import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationType;
|
||||||
|
import org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationTypeListConverter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@@ -56,7 +56,7 @@ public class LoanPaymentAllocationRule extends AbstractAuditableWithUTCDateTimeC
|
|||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private PaymentAllocationTransactionType transactionType;
|
private PaymentAllocationTransactionType transactionType;
|
||||||
|
|
||||||
@Convert(converter = AllocationTypeListConverter.class)
|
@Convert(converter = PaymentAllocationTypeListConverter.class)
|
||||||
@Column(name = "allocation_types", nullable = false)
|
@Column(name = "allocation_types", nullable = false)
|
||||||
private List<PaymentAllocationType> allocationTypes;
|
private List<PaymentAllocationType> allocationTypes;
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -24,8 +24,8 @@ import java.util.List;
|
|||||||
import org.apache.fineract.infrastructure.core.data.GenericEnumListConverter;
|
import org.apache.fineract.infrastructure.core.data.GenericEnumListConverter;
|
||||||
|
|
||||||
@Converter(autoApply = true)
|
@Converter(autoApply = true)
|
||||||
public class AllocationTypeListConverter extends GenericEnumListConverter<PaymentAllocationType>
|
public class AllocationTypeListConverter extends GenericEnumListConverter<AllocationType>
|
||||||
implements AttributeConverter<List<PaymentAllocationType>, String> {
|
implements AttributeConverter<List<AllocationType>, String> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUnique() {
|
public boolean isUnique() {
|
||||||
@@ -33,7 +33,7 @@ public class AllocationTypeListConverter extends GenericEnumListConverter<Paymen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AllocationTypeListConverter() {
|
public AllocationTypeListConverter() {
|
||||||
super(PaymentAllocationType.class);
|
super(AllocationType.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
/**
|
||||||
|
* 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.loanproduct.domain;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.apache.fineract.infrastructure.core.data.EnumOptionData;
|
||||||
|
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public enum CreditAllocationTransactionType {
|
||||||
|
|
||||||
|
CHARGEBACK(LoanTransactionType.CHARGEBACK, "Chargeback");
|
||||||
|
|
||||||
|
private final LoanTransactionType loanTransactionType;
|
||||||
|
private final String humanReadableName;
|
||||||
|
|
||||||
|
public static List<EnumOptionData> getValuesAsEnumOptionDataList() {
|
||||||
|
return Arrays.stream(values()).map(v -> new EnumOptionData((long) (v.ordinal() + 1), v.name(), v.getHumanReadableName())).toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
+26
-21
@@ -95,6 +95,9 @@ public class LoanProduct extends AbstractPersistableCustom {
|
|||||||
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loanProduct", orphanRemoval = true, fetch = FetchType.EAGER)
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loanProduct", orphanRemoval = true, fetch = FetchType.EAGER)
|
||||||
private List<LoanProductPaymentAllocationRule> paymentAllocationRules = new ArrayList<>();
|
private List<LoanProductPaymentAllocationRule> paymentAllocationRules = new ArrayList<>();
|
||||||
|
|
||||||
|
@OneToMany(cascade = CascadeType.ALL, mappedBy = "loanProduct", orphanRemoval = true, fetch = FetchType.EAGER)
|
||||||
|
private List<LoanProductCreditAllocationRule> creditAllocationRules = new ArrayList<>();
|
||||||
|
|
||||||
@Column(name = "name", nullable = false, unique = true)
|
@Column(name = "name", nullable = false, unique = true)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@@ -223,7 +226,8 @@ public class LoanProduct extends AbstractPersistableCustom {
|
|||||||
|
|
||||||
public static LoanProduct assembleFromJson(final Fund fund, final String loanTransactionProcessingStrategy,
|
public static LoanProduct assembleFromJson(final Fund fund, final String loanTransactionProcessingStrategy,
|
||||||
final List<Charge> productCharges, final JsonCommand command, final AprCalculator aprCalculator, FloatingRate floatingRate,
|
final List<Charge> productCharges, final JsonCommand command, final AprCalculator aprCalculator, FloatingRate floatingRate,
|
||||||
final List<Rate> productRates, List<LoanProductPaymentAllocationRule> loanProductPaymentAllocationRules) {
|
final List<Rate> productRates, List<LoanProductPaymentAllocationRule> loanProductPaymentAllocationRules,
|
||||||
|
List<LoanProductCreditAllocationRule> loanProductCreditAllocationRules) {
|
||||||
|
|
||||||
final String name = command.stringValueOfParameterNamed("name");
|
final String name = command.stringValueOfParameterNamed("name");
|
||||||
final String shortName = command.stringValueOfParameterNamed(LoanProductConstants.SHORT_NAME);
|
final String shortName = command.stringValueOfParameterNamed(LoanProductConstants.SHORT_NAME);
|
||||||
@@ -425,25 +429,25 @@ public class LoanProduct extends AbstractPersistableCustom {
|
|||||||
final boolean enableInstallmentLevelDelinquency = command
|
final boolean enableInstallmentLevelDelinquency = command
|
||||||
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.ENABLE_INSTALLMENT_LEVEL_DELINQUENCY);
|
.booleanPrimitiveValueOfParameterNamed(LoanProductConstants.ENABLE_INSTALLMENT_LEVEL_DELINQUENCY);
|
||||||
|
|
||||||
return new LoanProduct(fund, loanTransactionProcessingStrategy, loanProductPaymentAllocationRules, name, shortName, description,
|
return new LoanProduct(fund, loanTransactionProcessingStrategy, loanProductPaymentAllocationRules, loanProductCreditAllocationRules,
|
||||||
currency, principal, minPrincipal, maxPrincipal, interestRatePerPeriod, minInterestRatePerPeriod, maxInterestRatePerPeriod,
|
name, shortName, description, currency, principal, minPrincipal, maxPrincipal, interestRatePerPeriod,
|
||||||
interestFrequencyType, annualInterestRate, interestMethod, interestCalculationPeriodMethod,
|
minInterestRatePerPeriod, maxInterestRatePerPeriod, interestFrequencyType, annualInterestRate, interestMethod,
|
||||||
allowPartialPeriodInterestCalcualtion, repaymentEvery, repaymentFrequencyType, numberOfRepayments, minNumberOfRepayments,
|
interestCalculationPeriodMethod, allowPartialPeriodInterestCalcualtion, repaymentEvery, repaymentFrequencyType,
|
||||||
maxNumberOfRepayments, graceOnPrincipalPayment, recurringMoratoriumOnPrincipalPeriods, graceOnInterestPayment,
|
numberOfRepayments, minNumberOfRepayments, maxNumberOfRepayments, graceOnPrincipalPayment,
|
||||||
graceOnInterestCharged, amortizationMethod, inArrearsTolerance, productCharges, accountingRuleType, includeInBorrowerCycle,
|
recurringMoratoriumOnPrincipalPeriods, graceOnInterestPayment, graceOnInterestCharged, amortizationMethod,
|
||||||
startDate, closeDate, externalId, useBorrowerCycle, loanProductBorrowerCycleVariations, multiDisburseLoan, maxTrancheCount,
|
inArrearsTolerance, productCharges, accountingRuleType, includeInBorrowerCycle, startDate, closeDate, externalId,
|
||||||
outstandingLoanBalance, graceOnArrearsAgeing, overdueDaysForNPA, daysInMonthType, daysInYearType,
|
useBorrowerCycle, loanProductBorrowerCycleVariations, multiDisburseLoan, maxTrancheCount, outstandingLoanBalance,
|
||||||
isInterestRecalculationEnabled, interestRecalculationSettings, minimumDaysBetweenDisbursalAndFirstRepayment,
|
graceOnArrearsAgeing, overdueDaysForNPA, daysInMonthType, daysInYearType, isInterestRecalculationEnabled,
|
||||||
holdGuarantorFunds, loanProductGuaranteeDetails, principalThresholdForLastInstallment,
|
interestRecalculationSettings, minimumDaysBetweenDisbursalAndFirstRepayment, holdGuarantorFunds,
|
||||||
accountMovesOutOfNPAOnlyOnArrearsCompletion, canDefineEmiAmount, installmentAmountInMultiplesOf, loanConfigurableAttributes,
|
loanProductGuaranteeDetails, principalThresholdForLastInstallment, accountMovesOutOfNPAOnlyOnArrearsCompletion,
|
||||||
isLinkedToFloatingInterestRates, floatingRate, interestRateDifferential, minDifferentialLendingRate,
|
canDefineEmiAmount, installmentAmountInMultiplesOf, loanConfigurableAttributes, isLinkedToFloatingInterestRates,
|
||||||
maxDifferentialLendingRate, defaultDifferentialLendingRate, isFloatingInterestRateCalculationAllowed,
|
floatingRate, interestRateDifferential, minDifferentialLendingRate, maxDifferentialLendingRate,
|
||||||
isVariableInstallmentsAllowed, minimumGapBetweenInstallments, maximumGapBetweenInstallments,
|
defaultDifferentialLendingRate, isFloatingInterestRateCalculationAllowed, isVariableInstallmentsAllowed,
|
||||||
syncExpectedWithDisbursementDate, canUseForTopup, isEqualAmortization, productRates, fixedPrincipalPercentagePerInstallment,
|
minimumGapBetweenInstallments, maximumGapBetweenInstallments, syncExpectedWithDisbursementDate, canUseForTopup,
|
||||||
disallowExpectedDisbursements, allowApprovedDisbursedAmountsOverApplied, overAppliedCalculationType, overAppliedNumber,
|
isEqualAmortization, productRates, fixedPrincipalPercentagePerInstallment, disallowExpectedDisbursements,
|
||||||
dueDaysForRepaymentEvent, overDueDaysForRepaymentEvent, enableDownPayment, disbursedAmountPercentageDownPayment,
|
allowApprovedDisbursedAmountsOverApplied, overAppliedCalculationType, overAppliedNumber, dueDaysForRepaymentEvent,
|
||||||
enableAutoRepaymentForDownPayment, repaymentStartDateType, enableInstallmentLevelDelinquency, loanScheduleType,
|
overDueDaysForRepaymentEvent, enableDownPayment, disbursedAmountPercentageDownPayment, enableAutoRepaymentForDownPayment,
|
||||||
loanScheduleProcessingType);
|
repaymentStartDateType, enableInstallmentLevelDelinquency, loanScheduleType, loanScheduleProcessingType);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -626,7 +630,8 @@ public class LoanProduct extends AbstractPersistableCustom {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LoanProduct(final Fund fund, final String transactionProcessingStrategyCode,
|
public LoanProduct(final Fund fund, final String transactionProcessingStrategyCode,
|
||||||
final List<LoanProductPaymentAllocationRule> paymentAllocationRules, final String name, final String shortName,
|
final List<LoanProductPaymentAllocationRule> paymentAllocationRules,
|
||||||
|
final List<LoanProductCreditAllocationRule> creditAllocationRules, final String name, final String shortName,
|
||||||
final String description, final MonetaryCurrency currency, final BigDecimal defaultPrincipal,
|
final String description, final MonetaryCurrency currency, final BigDecimal defaultPrincipal,
|
||||||
final BigDecimal defaultMinPrincipal, final BigDecimal defaultMaxPrincipal,
|
final BigDecimal defaultMinPrincipal, final BigDecimal defaultMaxPrincipal,
|
||||||
final BigDecimal defaultNominalInterestRatePerPeriod, final BigDecimal defaultMinNominalInterestRatePerPeriod,
|
final BigDecimal defaultNominalInterestRatePerPeriod, final BigDecimal defaultMinNominalInterestRatePerPeriod,
|
||||||
|
|||||||
+59
@@ -0,0 +1,59 @@
|
|||||||
|
/**
|
||||||
|
* 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.loanproduct.domain;
|
||||||
|
|
||||||
|
import jakarta.persistence.Column;
|
||||||
|
import jakarta.persistence.Convert;
|
||||||
|
import jakarta.persistence.Entity;
|
||||||
|
import jakarta.persistence.EnumType;
|
||||||
|
import jakarta.persistence.Enumerated;
|
||||||
|
import jakarta.persistence.JoinColumn;
|
||||||
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.Table;
|
||||||
|
import jakarta.persistence.UniqueConstraint;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.apache.fineract.infrastructure.core.domain.AbstractAuditableWithUTCDateTimeCustom;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Entity
|
||||||
|
@Table(name = "m_loan_product_credit_allocation_rule", uniqueConstraints = {
|
||||||
|
@UniqueConstraint(columnNames = { "loan_product_id", "transaction_type" }, name = "uq_m_loan_product_credit_allocation_rule") })
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor(access = AccessLevel.PROTECTED)
|
||||||
|
public class LoanProductCreditAllocationRule extends AbstractAuditableWithUTCDateTimeCustom {
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name = "loan_product_id", nullable = false)
|
||||||
|
private LoanProduct loanProduct;
|
||||||
|
|
||||||
|
@Column(name = "transaction_type", nullable = false)
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private CreditAllocationTransactionType transactionType;
|
||||||
|
|
||||||
|
@Convert(converter = AllocationTypeListConverter.class)
|
||||||
|
@Column(name = "allocation_types", nullable = false)
|
||||||
|
private List<AllocationType> allocationTypes;
|
||||||
|
|
||||||
|
}
|
||||||
+1
-1
@@ -52,7 +52,7 @@ public class LoanProductPaymentAllocationRule extends AbstractAuditableWithUTCDa
|
|||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private PaymentAllocationTransactionType transactionType;
|
private PaymentAllocationTransactionType transactionType;
|
||||||
|
|
||||||
@Convert(converter = AllocationTypeListConverter.class)
|
@Convert(converter = PaymentAllocationTypeListConverter.class)
|
||||||
@Column(name = "allocation_types", nullable = false)
|
@Column(name = "allocation_types", nullable = false)
|
||||||
private List<PaymentAllocationType> allocationTypes;
|
private List<PaymentAllocationType> allocationTypes;
|
||||||
|
|
||||||
|
|||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* 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.loanproduct.domain;
|
||||||
|
|
||||||
|
import jakarta.persistence.AttributeConverter;
|
||||||
|
import jakarta.persistence.Converter;
|
||||||
|
import java.util.List;
|
||||||
|
import org.apache.fineract.infrastructure.core.data.GenericEnumListConverter;
|
||||||
|
|
||||||
|
@Converter(autoApply = true)
|
||||||
|
public class PaymentAllocationTypeListConverter extends GenericEnumListConverter<PaymentAllocationType>
|
||||||
|
implements AttributeConverter<List<PaymentAllocationType>, String> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isUnique() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PaymentAllocationTypeListConverter() {
|
||||||
|
super(PaymentAllocationType.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+1
@@ -38,4 +38,5 @@
|
|||||||
<include relativeToChangelogFile="true" file="parts/1013_add_loan_account_delinquency_pause_changed_event.xml"/>
|
<include relativeToChangelogFile="true" file="parts/1013_add_loan_account_delinquency_pause_changed_event.xml"/>
|
||||||
<include relativeToChangelogFile="true" file="parts/1014_add_loan_account_custom_snapshot_event.xml"/>
|
<include relativeToChangelogFile="true" file="parts/1014_add_loan_account_custom_snapshot_event.xml"/>
|
||||||
<include relativeToChangelogFile="true" file="parts/1015_remove_disable_schedule_extension_column.xml"/>
|
<include relativeToChangelogFile="true" file="parts/1015_remove_disable_schedule_extension_column.xml"/>
|
||||||
|
<include relativeToChangelogFile="true" file="parts/1016_add_credit_allocation_rule.xml"/>
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
+135
@@ -0,0 +1,135 @@
|
|||||||
|
<?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="1016-1">
|
||||||
|
<createTable tableName="m_loan_product_credit_allocation_rule">
|
||||||
|
<column autoIncrement="true" name="id" type="BIGINT">
|
||||||
|
<constraints nullable="false" primaryKey="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="loan_product_id" type="BIGINT">
|
||||||
|
<constraints nullable="false" foreignKeyName="m_loan_product_credit_allocation_rule_fk" referencedTableName="m_product_loan" referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
<column name="transaction_type" type="VARCHAR(255)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="allocation_types" type="TEXT">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="created_by" type="BIGINT">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="last_modified_by" type="BIGINT">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
<createTable tableName="m_loan_credit_allocation_rule">
|
||||||
|
<column autoIncrement="true" name="id" type="BIGINT">
|
||||||
|
<constraints nullable="false" primaryKey="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="loan_id" type="BIGINT">
|
||||||
|
<constraints nullable="false" foreignKeyName="m_loan_credit_allocation_rule_fk" referencedTableName="m_loan" referencedColumnNames="id"/>
|
||||||
|
</column>
|
||||||
|
<column name="transaction_type" type="VARCHAR(255)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="allocation_types" type="TEXT">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="created_by" type="BIGINT">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="last_modified_by" type="BIGINT">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="fineract" id="1016-2" context="mysql">
|
||||||
|
<addColumn tableName="m_loan_product_credit_allocation_rule">
|
||||||
|
<column name="created_on_utc" type="DATETIME(6)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="last_modified_on_utc" type="DATETIME(6)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="m_loan_credit_allocation_rule">
|
||||||
|
<column name="created_on_utc" type="DATETIME(6)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="last_modified_on_utc" type="DATETIME(6)">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="fineract" id="1016-2" context="postgresql">
|
||||||
|
<addColumn tableName="m_loan_product_credit_allocation_rule">
|
||||||
|
<column name="created_on_utc" type="TIMESTAMP WITH TIME ZONE">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="last_modified_on_utc" type="TIMESTAMP WITH TIME ZONE">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</addColumn>
|
||||||
|
<addColumn tableName="m_loan_credit_allocation_rule">
|
||||||
|
<column name="created_on_utc" type="TIMESTAMP WITH TIME ZONE">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="last_modified_on_utc" type="TIMESTAMP WITH TIME ZONE">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="fineract" id="1016-3">
|
||||||
|
<addUniqueConstraint tableName="m_loan_product_credit_allocation_rule" columnNames="loan_product_id,transaction_type" constraintName="uq_m_loan_product_credit_allocation_rule"/>
|
||||||
|
<addUniqueConstraint tableName="m_loan_credit_allocation_rule" columnNames="loan_id,transaction_type" constraintName="uq_m_loan_credit_allocation_rule"/>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet author="fineract" id="1016-4">
|
||||||
|
<addForeignKeyConstraint baseColumnNames="created_by" baseTableName="m_loan_product_credit_allocation_rule"
|
||||||
|
constraintName="FK_loan_product_credit_allocation_rule_created_by" deferrable="false" initiallyDeferred="false"
|
||||||
|
onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
|
||||||
|
referencedTableName="m_appuser" validate="true"/>
|
||||||
|
<addForeignKeyConstraint baseColumnNames="last_modified_by" baseTableName="m_loan_product_credit_allocation_rule"
|
||||||
|
constraintName="FK_loan_product_credit_allocation_rule_last_modified_by" deferrable="false"
|
||||||
|
initiallyDeferred="false"
|
||||||
|
onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
|
||||||
|
referencedTableName="m_appuser" validate="true"/>
|
||||||
|
<addForeignKeyConstraint baseColumnNames="created_by" baseTableName="m_loan_credit_allocation_rule"
|
||||||
|
constraintName="FK_loan_credit_allocation_rule_created_by" deferrable="false" initiallyDeferred="false"
|
||||||
|
onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
|
||||||
|
referencedTableName="m_appuser" validate="true"/>
|
||||||
|
<addForeignKeyConstraint baseColumnNames="last_modified_by" baseTableName="m_loan_credit_allocation_rule"
|
||||||
|
constraintName="FK_loan_credit_allocation_rule_last_modified_by" deferrable="false"
|
||||||
|
initiallyDeferred="false"
|
||||||
|
onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id"
|
||||||
|
referencedTableName="m_appuser" validate="true"/>
|
||||||
|
</changeSet>
|
||||||
|
<changeSet id="fineract" author="1016-5">
|
||||||
|
<createIndex tableName="m_loan_product_credit_allocation_rule" indexName="IND_loan_product_credit_allocation_rule_loan_product_id">
|
||||||
|
<column name="loan_product_id"/>
|
||||||
|
</createIndex>
|
||||||
|
<createIndex tableName="m_loan_credit_allocation_rule" indexName="IND_loan_credit_allocation_rule_loan_id">
|
||||||
|
<column name="loan_id"/>
|
||||||
|
</createIndex>
|
||||||
|
</changeSet>
|
||||||
|
</databaseChangeLog>
|
||||||
+7
-1
@@ -55,6 +55,7 @@ import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.AprCalculat
|
|||||||
import org.apache.fineract.portfolio.loanproduct.LoanProductConstants;
|
import org.apache.fineract.portfolio.loanproduct.LoanProductConstants;
|
||||||
import org.apache.fineract.portfolio.loanproduct.domain.AdvancedPaymentAllocationsJsonParser;
|
import org.apache.fineract.portfolio.loanproduct.domain.AdvancedPaymentAllocationsJsonParser;
|
||||||
import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
|
import org.apache.fineract.portfolio.loanproduct.domain.LoanProduct;
|
||||||
|
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductCreditAllocationRule;
|
||||||
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductPaymentAllocationRule;
|
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductPaymentAllocationRule;
|
||||||
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository;
|
import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRepository;
|
||||||
import org.apache.fineract.portfolio.loanproduct.exception.InvalidCurrencyException;
|
import org.apache.fineract.portfolio.loanproduct.exception.InvalidCurrencyException;
|
||||||
@@ -109,13 +110,18 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
|
|||||||
final List<Rate> rates = assembleListOfProductRates(command);
|
final List<Rate> rates = assembleListOfProductRates(command);
|
||||||
final List<LoanProductPaymentAllocationRule> loanProductPaymentAllocationRules = advancedPaymentJsonParser
|
final List<LoanProductPaymentAllocationRule> loanProductPaymentAllocationRules = advancedPaymentJsonParser
|
||||||
.assembleLoanProductPaymentAllocationRules(command, loanTransactionProcessingStrategyCode);
|
.assembleLoanProductPaymentAllocationRules(command, loanTransactionProcessingStrategyCode);
|
||||||
|
List<LoanProductCreditAllocationRule> loanProductCreditAllocationRules = new ArrayList<>(); // TODO: this
|
||||||
|
// shall be
|
||||||
|
// parsed from
|
||||||
|
// the json
|
||||||
|
// command
|
||||||
FloatingRate floatingRate = null;
|
FloatingRate floatingRate = null;
|
||||||
if (command.parameterExists("floatingRatesId")) {
|
if (command.parameterExists("floatingRatesId")) {
|
||||||
floatingRate = this.floatingRateRepository
|
floatingRate = this.floatingRateRepository
|
||||||
.findOneWithNotFoundDetection(command.longValueOfParameterNamed("floatingRatesId"));
|
.findOneWithNotFoundDetection(command.longValueOfParameterNamed("floatingRatesId"));
|
||||||
}
|
}
|
||||||
final LoanProduct loanProduct = LoanProduct.assembleFromJson(fund, loanTransactionProcessingStrategyCode, charges, command,
|
final LoanProduct loanProduct = LoanProduct.assembleFromJson(fund, loanTransactionProcessingStrategyCode, charges, command,
|
||||||
this.aprCalculator, floatingRate, rates, loanProductPaymentAllocationRules);
|
this.aprCalculator, floatingRate, rates, loanProductPaymentAllocationRules, loanProductCreditAllocationRules);
|
||||||
loanProduct.updateLoanProductInRelatedClasses();
|
loanProduct.updateLoanProductInRelatedClasses();
|
||||||
loanProduct.setTransactionProcessingStrategyName(
|
loanProduct.setTransactionProcessingStrategyName(
|
||||||
loanRepaymentScheduleTransactionProcessorFactory.determineProcessor(loanTransactionProcessingStrategyCode).getName());
|
loanRepaymentScheduleTransactionProcessorFactory.determineProcessor(loanTransactionProcessingStrategyCode).getName());
|
||||||
|
|||||||
@@ -114,6 +114,10 @@
|
|||||||
<class>org.apache.fineract.portfolio.loanproduct.domain.AllocationTypeListConverter</class>
|
<class>org.apache.fineract.portfolio.loanproduct.domain.AllocationTypeListConverter</class>
|
||||||
<class>org.apache.fineract.portfolio.loanproduct.domain.LoanProductPaymentAllocationRule</class>
|
<class>org.apache.fineract.portfolio.loanproduct.domain.LoanProductPaymentAllocationRule</class>
|
||||||
<class>org.apache.fineract.portfolio.loanaccount.domain.LoanPaymentAllocationRule</class>
|
<class>org.apache.fineract.portfolio.loanaccount.domain.LoanPaymentAllocationRule</class>
|
||||||
|
<class>org.apache.fineract.portfolio.loanproduct.domain.LoanProductCreditAllocationRule</class>
|
||||||
|
<class>org.apache.fineract.portfolio.loanaccount.domain.LoanCreditAllocationRule</class>
|
||||||
|
<class>org.apache.fineract.portfolio.loanproduct.domain.CreditAllocationTransactionType</class>
|
||||||
|
<class>org.apache.fineract.portfolio.loanproduct.domain.PaymentAllocationTypeListConverter</class>
|
||||||
<exclude-unlisted-classes>false</exclude-unlisted-classes>
|
<exclude-unlisted-classes>false</exclude-unlisted-classes>
|
||||||
<properties>
|
<properties>
|
||||||
<property name="eclipselink.weaving" value="static" />
|
<property name="eclipselink.weaving" value="static" />
|
||||||
|
|||||||
Reference in New Issue
Block a user