Skip to content

Commit 630f41f

Browse files
oleksii-novikov-onixadamsaghy
authored andcommitted
FINERACT-2413: Re-amortization reverse replay handling
1 parent e8e9fb1 commit 630f41f

File tree

8 files changed

+182
-152
lines changed

8 files changed

+182
-152
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
@@ -179,6 +179,7 @@ public enum DefaultLoanProduct implements LoanProduct {
179179
LP1_INTEREST_FLAT_DAILY_RECALCULATION_SAR_MULTIDISB_EXPECT_TRANCHES, //
180180
LP1_INTEREST_FLAT_DAILY_ACTUAL_ACTUAL_MULTIDISB_EXPECT_TRANCHES, //
181181
LP2_ADV_PYMNT_360_30_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY, //
182+
LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL_PRINCIPAL_FIRST, //
182183
;
183184

184185
@Override

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4229,6 +4229,39 @@ public void initialize() throws Exception {
42294229
TestContext.INSTANCE.set(
42304230
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_CHARGEBACK,
42314231
responseLoanProductsRequestLP2AdvancedpaymentInterestEmi36030InterestRecalcDailyMultiDisburseChargeback);
4232+
4233+
// LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL_PRINCIPAL_FIRST
4234+
// Same as LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL but with PRINCIPAL before INTEREST
4235+
// in payment allocation order
4236+
String name168 = DefaultLoanProduct.LP2_ADV_CUSTOM_PMT_ALLOC_PROGRESSIVE_LOAN_SCHEDULE_HORIZONTAL_PRINCIPAL_FIRST.getName();
4237+
4238+
PostLoanProductsRequest loanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedulePrincipalFirst = loanProductsRequestFactory
4239+
.defaultLoanProductsRequestLP2InterestDailyRecalculation()//
4240+
.name(name168)//
4241+
.supportedInterestRefundTypes(Arrays.asList("MERCHANT_ISSUED_REFUND", "PAYOUT_REFUND"))//
4242+
.enableAccrualActivityPosting(true) //
4243+
.paymentAllocation(List.of(//
4244+
createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT",
4245+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_PRINCIPAL, //
4246+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_INTEREST, //
4247+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_PENALTY, //
4248+
LoanProductPaymentAllocationRule.AllocationTypesEnum.PAST_DUE_FEE, //
4249+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_PRINCIPAL, //
4250+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_INTEREST, //
4251+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_PENALTY, //
4252+
LoanProductPaymentAllocationRule.AllocationTypesEnum.DUE_FEE, //
4253+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PRINCIPAL, //
4254+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_INTEREST, //
4255+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_PENALTY, //
4256+
LoanProductPaymentAllocationRule.AllocationTypesEnum.IN_ADVANCE_FEE), //
4257+
createPaymentAllocation("GOODWILL_CREDIT", "REAMORTIZATION"), //
4258+
createPaymentAllocation("MERCHANT_ISSUED_REFUND", "LAST_INSTALLMENT"), //
4259+
createPaymentAllocation("PAYOUT_REFUND", "NEXT_INSTALLMENT")));//
4260+
PostLoanProductsResponse responseLoanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedulePrincipalFirst = createLoanProductIdempotent(
4261+
loanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedulePrincipalFirst);
4262+
TestContext.INSTANCE.set(
4263+
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADVANCED_CUSTOM_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE_PRINCIPAL_FIRST,
4264+
responseLoanProductsRequestAdvCustomPaymentAllocationProgressiveLoanSchedulePrincipalFirst);
42324265
}
42334266

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

fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanReAmortizationStepDef.java

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class LoanReAmortizationStepDef extends AbstractStepDef {
5656
private final FineractFeignClient fineractClient;
5757
private final EventAssertion eventAssertion;
5858

59-
@When("When Admin creates a Loan re-amortization transaction on current business date")
59+
@When("Admin creates a Loan re-amortization transaction on current business date")
6060
public void createLoanReAmortization() {
6161
PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
6262
long loanId = loanResponse.getLoanId();
@@ -68,18 +68,6 @@ public void createLoanReAmortization() {
6868
testContext().set(TestContextKey.LOAN_REAMORTIZATION_RESPONSE, response);
6969
}
7070

71-
@When("Admin creates a Loan re-amortization transaction on {string} date")
72-
public void createLoanReAmortization(final String date) {
73-
PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
74-
long loanId = loanResponse.getLoanId();
75-
76-
PostLoansLoanIdTransactionsRequest reAmortizationRequest = LoanRequestFactory.defaultLoanReAmortizationRequest().startDate(date);
77-
78-
PostLoansLoanIdTransactionsResponse response = ok(() -> fineractClient.loanTransactions().executeLoanTransaction(loanId,
79-
reAmortizationRequest, Map.of("command", "reAmortize")));
80-
testContext().set(TestContextKey.LOAN_REAMORTIZATION_RESPONSE, response);
81-
}
82-
8371
@When("Admin creates a Loan re-amortization transaction on current business date with reAmortizationInterestHandling {string}")
8472
public void createLoanReAmortizationWithInterestHandling(final String reAmortizationInterestHandling) {
8573
final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
@@ -93,20 +81,7 @@ public void createLoanReAmortizationWithInterestHandling(final String reAmortiza
9381
testContext().set(TestContextKey.LOAN_REAMORTIZATION_RESPONSE, response);
9482
}
9583

96-
@When("Admin creates a Loan re-amortization transaction on {string} date with reAmortizationInterestHandling {string}")
97-
public void createLoanReAmortizationWithInterestHandling(final String date, final String reAmortizationInterestHandling) {
98-
final PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
99-
final Long loanId = loanResponse.getLoanId();
100-
101-
final PostLoansLoanIdTransactionsRequest reAmortizationRequest = LoanRequestFactory.defaultLoanReAmortizationRequest()
102-
.reAmortizationInterestHandling(reAmortizationInterestHandling).startDate(date);
103-
104-
final PostLoansLoanIdTransactionsResponse response = ok(() -> fineractClient.loanTransactions().executeLoanTransaction(loanId,
105-
reAmortizationRequest, Map.of("command", "reAmortize")));
106-
testContext().set(TestContextKey.LOAN_REAMORTIZATION_RESPONSE, response);
107-
}
108-
109-
@When("When Admin creates a Loan re-amortization transaction on current business date by loan external ID")
84+
@When("Admin creates a Loan re-amortization transaction on current business date by loan external ID")
11085
public void createLoanReAmortizationByLoanExternalId() {
11186
PostLoansResponse loanResponse = testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
11287
String loanExternalId = loanResponse.getResourceExternalId();

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
@@ -291,4 +291,5 @@ public abstract class TestContextKey {
291291
public static final String LP1_INTEREST_FLAT_DAILY_RECALCULATION_SAR_MULTIDISB_EXPECT_TRANCHES = "loanProductCreateResponseLP1InterestFlatDailyRecalculationSameAsRepaymentMultiDisbursementExpectTranches";
292292
public static final String LP1_INTEREST_FLAT_DAILY_ACTUAL_ACTUAL_MULTIDISB_EXPECT_TRANCHES = "loanProductCreateResponseLP1InterestFlatDailyActualActualMultiDisbursementExpectTranches";
293293
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_360_30_ZERO_INTEREST_CHARGE_OFF_ACCRUAL_ACTIVITY = "loanProductCreateResponseLP2AdvancedPaymentZeroInterestChargeOffBehaviourAccrualActivity";
294+
public static final String DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADVANCED_CUSTOM_PAYMENT_ALLOCATION_PROGRESSIVE_LOAN_SCHEDULE_PRINCIPAL_FIRST = "loanProductCreateResponseLP2AdvancedPaymentHorizontalPrincipalFirst";
294295
}

0 commit comments

Comments
 (0)