Skip to content

Commit a10e489

Browse files
FINERACT-2319: Repayment allocation prefers future dated penalty first
1 parent 4c3da5b commit a10e489

File tree

4 files changed

+118
-1
lines changed

4 files changed

+118
-1
lines changed

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/DefaultLoanProduct.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public enum DefaultLoanProduct implements LoanProduct {
104104
LP2_ADV_PYMNT_ACCELERATE_MATURITY_CHARGE_OFF_BEHAVIOUR, //
105105
LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_INTEREST_FIRST, //
106106
LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_PRINCIPAL_FIRST, //
107+
LP2_NO_INTEREST_RECALCULATION_ALLOCATION_PENALTY_FIRST, //
107108
LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALC_EMI_360_30_CHARGEBACK_INTEREST_PENALTY_FEE_PRINCIPAL, //
108109
LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALC_EMI_360_30_CHARGEBACK_INTEREST_FEE_PRINCIPAL, //
109110
LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALC_EMI_360_30_CHARGEBACK_PRINCIPAL_INTEREST_FEE, //

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2953,6 +2953,38 @@ public void initialize() throws Exception {
29532953
.createLoanProduct(loanProductsRequestLP2ProgressiveAdvPaymentBuyDownFees).execute();
29542954
TestContext.INSTANCE.set(TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_PROGRESSIVE_ADV_PYMNT_BUYDOWN_FEES,
29552955
responseLoanProductsRequestLP2ProgressiveAdvPaymentBuyDownFees);
2956+
2957+
// LP2 without Down-payment + interest recalculation disabled + advanced payment allocation + progressive loan
2958+
// schedule + horizontal + allocation penalty first
2959+
// (LP2_NO_INTEREST_RECALCULATION_ALLOCATION_PENALTY_FIRST)
2960+
String name115 = DefaultLoanProduct.LP2_NO_INTEREST_RECALCULATION_ALLOCATION_PENALTY_FIRST.getName();
2961+
PostLoanProductsRequest loanProductsRequestNoInterestRecalculationAllocationPenaltyFirst = loanProductsRequestFactory
2962+
.defaultLoanProductsRequestLP2()//
2963+
.name(name115)//
2964+
.transactionProcessingStrategyCode(ADVANCED_PAYMENT_ALLOCATION.getValue())//
2965+
.loanScheduleType("PROGRESSIVE") //
2966+
.loanScheduleProcessingType("HORIZONTAL")//
2967+
.enableDownPayment(false)//
2968+
.enableAutoRepaymentForDownPayment(null)//
2969+
.disbursedAmountPercentageForDownPayment(null)//
2970+
.paymentAllocation(List.of(//
2971+
createPaymentAllocation("DEFAULT", "LAST_INSTALLMENT",
2972+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_PENALTY, //
2973+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_INTEREST, //
2974+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_PRINCIPAL, //
2975+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_FEE, //
2976+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_PENALTY, //
2977+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_INTEREST, //
2978+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_PRINCIPAL, //
2979+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_FEE, //
2980+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PENALTY, //
2981+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_INTEREST, //
2982+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PRINCIPAL, //
2983+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_FEE)));//
2984+
Response<PostLoanProductsResponse> responseLoanProductsRequestNoInterestRecalculationAllocationPenaltyFirst = loanProductsApi
2985+
.createLoanProduct(loanProductsRequestNoInterestRecalculationAllocationPenaltyFirst).execute();
2986+
TestContext.INSTANCE.set(TestContextKey.LP2_NO_INTEREST_RECALCULATION_ALLOCATION_PENALTY_FIRST_RESPONSE,
2987+
responseLoanProductsRequestNoInterestRecalculationAllocationPenaltyFirst);
29562988
}
29572989

29582990
public static AdvancedPaymentData createPaymentAllocation(String transactionType, String futureInstallmentAllocationRule,

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ public abstract class TestContextKey {
162162
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_360_30_INTEREST_RECALCULATION_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyInterestRecalculationZeroInterestChargeOffBehaviourAccrualActivity";
163163
public static final String LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_INTEREST_FIRST_RESPONSE = "loanProductCreateResponseLP2NoInterestRecalculationChargebackAllocationInterestFirst";
164164
public static final String LP2_NO_INTEREST_RECALCULATION_CHARGEBACK_ALLOCATION_PRINCIPAL_FIRST_RESPONSE = "loanProductCreateResponseLP2NoInterestRecalculationChargebackAllocationPrincipalFirst";
165+
public static final String LP2_NO_INTEREST_RECALCULATION_ALLOCATION_PENALTY_FIRST_RESPONSE = "loanProductCreateResponseLP2NoInterestRecalculationAllocationPenaltyFirst";
165166
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_INTEREST_RECALCULATION_ACCELERATE_MATURITY_CHARGE_OFF_BEHAVIOUR_LAST_INSTALLMENT_STRATEGY = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyInterestRecalculationAccelerateMaturityChargeOffBehaviourLastInstallmentStrategy";
166167
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_ACCELERATE_MATURITY_CHARGE_OFF_BEHAVIOUR_LAST_INSTALLMENT_STRATEGY = "loanProductCreateResponseLP2AdvancedPaymentAccelerateMaturityChargeOffBehaviourLastInstallmentStrategy";
167168
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_IR_DAILY_TILL_REST_FREQUENCY_DATE_LAST_INSTALLMENT = "loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmi36030InterestRecalculationDailyTillRestFrequencyDateLastInstallment";

fineract-e2e-tests-runner/src/test/resources/features/LoanRepayment.feature

Lines changed: 84 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5405,4 +5405,87 @@ Feature: LoanRepayment
54055405
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
54065406
| 01 January 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false |
54075407
| 01 February 2024 | Repayment | 40.0 | 39.42 | 0.58 | 0.0 | 0.0 | 60.58 | false | false |
5408-
When Admin set "LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL" loan product "DEFAULT" transaction type to "NEXT_INSTALLMENT" future installment allocation rule
5408+
When Admin set "LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL" loan product "DEFAULT" transaction type to "NEXT_INSTALLMENT" future installment allocation rule
5409+
5410+
Scenario: Verify progressive loan repayment reversals with penalty charge and backdated repayment
5411+
When Admin sets the business date to "20 October 2024"
5412+
When Admin creates a client with random data
5413+
When Admin creates a fully customized loan with the following data:
5414+
| LoanProduct | submitted on date | with Principal | ANNUAL interest rate % | interest type | interest calculation period | amortization type | loanTermFrequency | loanTermFrequencyType | repaymentEvery | repaymentFrequencyType | numberOfRepayments | graceOnPrincipalPayment | graceOnInterestPayment | interest free period | Payment strategy |
5415+
| LP2_NO_INTEREST_RECALCULATION_ALLOCATION_PENALTY_FIRST | 20 October 2024 | 100 | 0 | FLAT | SAME_AS_REPAYMENT_PERIOD | EQUAL_INSTALLMENTS | 30 | DAYS | 30 | DAYS | 1 | 0 | 0 | 0 | ADVANCED_PAYMENT_ALLOCATION |
5416+
And Admin successfully approves the loan on "20 October 2024" with "100" amount and expected disbursement date on "20 October 2024"
5417+
And Admin successfully disburse the loan on "20 October 2024" with "100" EUR transaction amount
5418+
Then Loan Repayment schedule has 1 periods, with the following data for periods:
5419+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
5420+
| | | 20 October 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
5421+
| 1 | 30 | 19 November 2024 | | 0.0 | 100.0 | 0.0 | 0.0 | 0.0 | 100.0 | 0.0 | 0.0 | 0.0 | 100.0 |
5422+
Then Loan Repayment schedule has the following data in Total row:
5423+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
5424+
| 100.0 | 0.0 | 0.0 | 0.0 | 100.0 | 0.0 | 0.0 | 0.0 | 100.0 |
5425+
When Admin sets the business date to "22 October 2024"
5426+
And Customer makes "AUTOPAY" repayment on "22 October 2024" with 100 EUR transaction amount
5427+
Then Loan status will be "CLOSED_OBLIGATIONS_MET"
5428+
Then Loan Repayment schedule has 1 periods, with the following data for periods:
5429+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
5430+
| | | 20 October 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
5431+
| 1 | 30 | 19 November 2024 | 22 October 2024 | 0.0 | 100.0 | 0.0 | 0.0 | 0.0 | 100.0 | 100.0 | 100.0 | 0.0 | 0.0 |
5432+
Then Loan Transactions tab has the following data:
5433+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance |
5434+
| 20 October 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 |
5435+
| 22 October 2024 | Repayment | 100.0 | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 |
5436+
When Admin sets the business date to "24 October 2024"
5437+
And Customer makes a repayment undo on "22 October 2024"
5438+
Then Loan status will be "ACTIVE"
5439+
And Loan has 100 outstanding amount
5440+
Then Loan Repayment schedule has 1 periods, with the following data for periods:
5441+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
5442+
| | | 20 October 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
5443+
| 1 | 30 | 19 November 2024 | | 0.0 | 100.0 | 0.0 | 0.0 | 0.0 | 100.0 | 0.0 | 0.0 | 0.0 | 100.0 |
5444+
Then Loan Transactions tab has the following data:
5445+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
5446+
| 20 October 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false |
5447+
| 22 October 2024 | Repayment | 100.0 | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | true | false |
5448+
When Admin sets the business date to "26 October 2024"
5449+
And Customer makes "AUTOPAY" repayment on "26 October 2024" with 100 EUR transaction amount
5450+
Then Loan status will be "CLOSED_OBLIGATIONS_MET"
5451+
Then Loan Repayment schedule has 1 periods, with the following data for periods:
5452+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
5453+
| | | 20 October 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
5454+
| 1 | 30 | 19 November 2024 | 26 October 2024 | 0.0 | 100.0 | 0.0 | 0.0 | 0.0 | 100.0 | 100.0 | 100.0 | 0.0 | 0.0 |
5455+
Then Loan Transactions tab has the following data:
5456+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
5457+
| 20 October 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false |
5458+
| 22 October 2024 | Repayment | 100.0 | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | true | false |
5459+
| 26 October 2024 | Repayment | 100.0 | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | false | false |
5460+
When Admin sets the business date to "28 October 2024"
5461+
And Customer makes a repayment undo on "26 October 2024"
5462+
Then Loan status will be "ACTIVE"
5463+
And Loan has 100 outstanding amount
5464+
Then Loan Repayment schedule has 1 periods, with the following data for periods:
5465+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
5466+
| | | 20 October 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
5467+
| 1 | 30 | 19 November 2024 | | 0.0 | 100.0 | 0.0 | 0.0 | 0.0 | 100.0 | 0.0 | 0.0 | 0.0 | 100.0 |
5468+
When Admin adds "LOAN_NSF_FEE" due date charge with "28 October 2024" due date and 10 EUR transaction amount
5469+
Then Loan Repayment schedule has 1 periods, with the following data for periods:
5470+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
5471+
| | | 20 October 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
5472+
| 1 | 30 | 19 November 2024 | | 0.0 | 100.0 | 0.0 | 0.0 | 10.0 | 110.0 | 0.0 | 0.0 | 0.0 | 110.0 |
5473+
Then Loan Repayment schedule has the following data in Total row:
5474+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
5475+
| 100.0 | 0.0 | 0.0 | 10.0 | 110.0 | 0.0 | 0.0 | 0.0 | 110.0 |
5476+
And Customer makes "AUTOPAY" repayment on "26 October 2024" with 101 EUR transaction amount
5477+
Then Loan Repayment schedule has 1 periods, with the following data for periods:
5478+
| Nr | Days | Date | Paid date | Balance of loan | Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
5479+
| | | 20 October 2024 | | 100.0 | | | 0.0 | | 0.0 | 0.0 | | | |
5480+
| 1 | 30 | 19 November 2024 | | 0.0 | 100.0 | 0.0 | 0.0 | 10.0 | 110.0 | 101.0 | 101.0 | 0.0 | 9.0 |
5481+
Then Loan Repayment schedule has the following data in Total row:
5482+
| Principal due | Interest | Fees | Penalties | Due | Paid | In advance | Late | Outstanding |
5483+
| 100.0 | 0.0 | 0.0 | 10.0 | 110.0 | 101.0 | 101.0 | 0.0 | 9.0 |
5484+
Then Loan Transactions tab has the following data:
5485+
| Transaction date | Transaction Type | Amount | Principal | Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
5486+
| 20 October 2024 | Disbursement | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | 100.0 | false | false |
5487+
| 22 October 2024 | Repayment | 100.0 | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | true | false |
5488+
| 26 October 2024 | Repayment | 100.0 | 100.0 | 0.0 | 0.0 | 0.0 | 0.0 | true | false |
5489+
| 26 October 2024 | Repayment | 101.0 | 91.0 | 0.0 | 0.0 | 10.0 | 9.0 | false | false |
5490+
When Customer makes "AUTOPAY" repayment on "27 October 2024" with 9 EUR transaction amount
5491+
Then Loan status will be "CLOSED_OBLIGATIONS_MET"

0 commit comments

Comments
 (0)