This is an automated email from the ASF dual-hosted git repository.

adamsaghy pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git

commit f7a90d87760c3cf852f813cfdf22ee2c9e6a220b
Author: Rustam Zeinalov <[email protected]>
AuthorDate: Thu Jan 22 18:33:08 2026 +0100

    FINERACT-2421: added e2e test covering manual interest refund on closed 
loan generates exception
---
 .../test/data/loanproduct/DefaultLoanProduct.java  |   1 +
 .../fineract/test/stepdef/loan/LoanStepDef.java    |  33 ++++
 .../fineract/test/support/TestContextKey.java      |   1 +
 .../global/LoanProductGlobalInitializerStep.java   |  22 +++
 .../features/LoanMerchantIssuedRefund.feature      | 199 +++++++++++++++++++++
 5 files changed, 256 insertions(+)

diff --git 
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/DefaultLoanProduct.java
 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/DefaultLoanProduct.java
index f3df476b8f..ba6258ae0b 100644
--- 
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/DefaultLoanProduct.java
+++ 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/loanproduct/DefaultLoanProduct.java
@@ -129,6 +129,7 @@ public enum DefaultLoanProduct implements LoanProduct {
     
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_MULTIDISBURSE_CHARGEBACK,
 //
     
LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CASH_ACCOUNTING_DISBURSEMENT_CHARGES,
 //
     
LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF, 
//
+    
LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF_ACCRUAL_ACTIVITY,
 //
     
LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ACCELERATE_MATURITY_CHARGE_OFF,
 //
     
LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_NO_INTEREST_RECALC_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF,
 //
     
LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_NO_INTEREST_RECALC_INT_REFUND_FULL_ACC_MATUR_CHARGE_OFF,
 //
diff --git 
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java
 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java
index f9302c6e5d..2c3891ad87 100644
--- 
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java
+++ 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/stepdef/loan/LoanStepDef.java
@@ -458,6 +458,39 @@ public class LoanStepDef extends AbstractStepDef {
         eventCheckHelper.loanBalanceChangedEventCheck(loanId);
     }
 
+    @When("Admin manually adds Interest Refund for {string}th {string} 
transaction made on {string} with {double} EUR interest refund amount")
+    public void addInterestRefundTransactionManuallyNth(final String 
nthTransaction, final String transactionTypeInput,
+            final String transactionDate, final double amount) throws 
IOException {
+        final PostLoansResponse loanResponse = 
testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+        final long loanId = loanResponse.getLoanId();
+        final TransactionType transactionType = 
TransactionType.valueOf(transactionTypeInput);
+
+        final GetLoansLoanIdResponse loanDetailsResponse = ok(() -> 
fineractClient.loans().retrieveLoan(loanId,
+                Map.of("staffInSelectedOfficeOnly", "false", "associations", 
"transactions")));
+        assert loanDetailsResponse != null;
+        final List<GetLoansLoanIdTransactions> transactions = 
loanDetailsResponse.getTransactions();
+        assert transactions != null;
+
+        final int nthItem = Integer.parseInt(nthTransaction) - 1;
+        final List<GetLoansLoanIdTransactions> matchingTransactions = 
transactions.stream()
+                .filter(t -> t.getType() != null
+                        && 
(transactionType.equals(TransactionType.PAYOUT_REFUND) ? "Payout Refund" : 
"Merchant Issued Refund")
+                                .equals(t.getType().getValue())
+                        && t.getDate() != null && 
transactionDate.equals(FORMATTER.format(t.getDate())))
+                .toList();
+
+        if (nthItem < 0 || nthItem >= matchingTransactions.size()) {
+            throw new IllegalStateException("No " + nthTransaction + "th 
refund transaction found on " + transactionDate + " for loan "
+                    + loanId + ". Found " + matchingTransactions.size() + " 
matching transactions.");
+        }
+        final GetLoansLoanIdTransactions refundTransaction = 
matchingTransactions.get(nthItem);
+
+        final PostLoansLoanIdTransactionsResponse adjustmentResponse = 
addInterestRefundTransaction(amount, refundTransaction.getId());
+        testContext().set(TestContextKey.LOAN_INTEREST_REFUND_RESPONSE, 
adjustmentResponse);
+        eventCheckHelper.transactionEventCheck(adjustmentResponse, 
TransactionType.INTEREST_REFUND, null);
+        eventCheckHelper.loanBalanceChangedEventCheck(loanId);
+    }
+
     @When("Admin manually adds Interest Refund for {string} transaction made 
on invalid date {string} with {double} EUR interest refund amount")
     public void addInterestRefundTransactionManuallyWithInvalidDate(final 
String transactionTypeInput, final String transactionDate,
             final double amount) {
diff --git 
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java
 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java
index a558de1327..5c2b348abe 100644
--- 
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java
+++ 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/support/TestContextKey.java
@@ -116,6 +116,7 @@ public abstract class TestContextKey {
     public static final String 
DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_INTEREST_REFUND_FULL
 = 
"loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmiActualActualInterestRefundFull";
     public static final String 
DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INTEREST_DAILY_EMI_ACTUAL_ACTUAL_NO_INTEREST_RECALC_REFUND_FULL
 = 
"loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmiActualActualNoInterestRecalcRefundFull";
     public static final String 
DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF
 = 
"loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmiActualActualInterestRefundFullZeroInterestChargeOff";
+    public static final String 
DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF_ACCRUAL_ACTIVITY
 = 
"loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmiActualActualInterestRefundFullZeroInterestChargeOffAccrualActivity";
     public static final String 
DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_NO_INTEREST_RECALC_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF
 = 
"loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmiActualActualNoInterestRecalcInterestRefundFullZeroInterestChargeOff";
     public static final String 
DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ACCELERATE_MATURITY_CHARGE_OFF
 = 
"loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmiActualActualInterestRefundFullAccelerateMaturityChargeOff";
     public static final String 
DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_NO_INTEREST_RECALC_INT_REFUND_FULL_ACC_MATUR_CHARGE_OFF
 = 
"loanProductCreateResponseLP2AdvancedPaymentInterestDailyEmiActualActualNoInterestRecalcInterestRefundFullAccelerateMaturityChargeOff";
diff --git 
a/fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
 
b/fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
index 840b409a60..f519957178 100644
--- 
a/fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
+++ 
b/fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
@@ -4429,6 +4429,28 @@ public class LoanProductGlobalInitializerStep implements 
FineractGlobalInitializ
         TestContext.INSTANCE.set(
                 
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_360_30_INT_RECALC_DAILY_MULTIDISB_FULL_TERM_TRANCHE_DOWNPAYMENT_AUTO,
                 
responseLoanProductsRequestLP2AdvPymntIntEmi36030IntRecalcDailyMultiDisbFullTermTrancheDownPaymentAuto);
+
+        // LP2 + zero-interest chargeOff behaviour + progressive loan schedule 
+ horizontal + interest recalculation +
+        // accrual activity posting
+        // 
(LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF_ACCRUAL_ACTIVITY)
+        final String name173 = 
DefaultLoanProduct.LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF_ACCRUAL_ACTIVITY
+                .getName();
+        final PostLoanProductsRequest 
loanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullZeroIntChargeOffAccrualActivity
 = 
loanProductsRequestLP2AdvancedpaymentInterestEmiActualActualInterestRefundFull
+                .name(name173)//
+                
.shortName(loanProductsRequestFactory.generateShortNameSafely())//
+                .enableAccrualActivityPosting(true)//
+                .allowApprovedDisbursedAmountsOverApplied(true)//
+                
.overAppliedCalculationType(OverAppliedCalculationType.FIXED_SIZE.value)//
+                .overAppliedNumber(1000)//
+                .enableInstallmentLevelDelinquency(true)//
+                .interestRecognitionOnDisbursementDate(true)//
+                .maxTrancheCount(500)//
+                .chargeOffBehaviour("ZERO_INTEREST");//
+        PostLoanProductsResponse 
responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullZeroIntChargeOffAccrualActivity
 = createLoanProductIdempotent(
+                
loanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullZeroIntChargeOffAccrualActivity);
+        TestContext.INSTANCE.set(
+                
TestContextKey.DEFAULT_LOAN_PRODUCT_CREATE_RESPONSE_LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF_ACCRUAL_ACTIVITY,
+                
responseLoanProductsRequestLP2AdvPaymentIntEmiActualActualIntRefundFullZeroIntChargeOff);
     }
 
     public static AdvancedPaymentData createPaymentAllocation(String 
transactionType, String futureInstallmentAllocationRule,
diff --git 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanMerchantIssuedRefund.feature
 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanMerchantIssuedRefund.feature
index 81dfa1f8a9..864225de97 100644
--- 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanMerchantIssuedRefund.feature
+++ 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanMerchantIssuedRefund.feature
@@ -695,3 +695,202 @@ Feature: MerchantIssuedRefund
       | 01 February 2025 | Interest Refund        | 1.46   | 1.46      | 0.0   
   | 0.0  | 0.0       | 23.34        | false    | true     |
     #following steps will fail if Interest Refund is not recalculated properly
     Then Loan has 23.97 outstanding amount
+
+  @TestRailId:C4542
+  Scenario: Verify adding manual Interest Refund on closed loan with multiple 
tranches
+    When Admin sets the business date to "07 March 2025"
+    And Admin creates a client with random data
+    And Admin creates a fully customized loan with the following data:
+      | 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            |
+      | 
LP2_ADV_PYMNT_INT_DAILY_EMI_ACTUAL_ACTUAL_INT_REFUND_FULL_ZERO_INT_CHARGE_OFF_ACCRUAL_ACTIVITY
 | 07 March 2025     | 915.88         | 24.99                  | 
DECLINING_BALANCE | DAILY                       | EQUAL_INSTALLMENTS | 24       
         | MONTHS                | 1              | MONTHS                 | 24 
                | 0                       | 0                      | 0          
          | ADVANCED_PAYMENT_ALLOCATION |
+    And Admin successfully approves the loan on "07 March 2025" with "915.88" 
amount and expected disbursement date on "07 March 2025"
+    When Admin sets the business date to "11 March 2025"
+    And Admin successfully disburse the loan on "11 March 2025" with "228.97" 
EUR transaction amount
+    And Admin successfully disburse the loan on "11 March 2025" with "228.97" 
EUR transaction amount
+    And Admin successfully disburse the loan on "11 March 2025" with "228.97" 
EUR transaction amount
+    And Admin successfully disburse the loan on "11 March 2025" with "228.97" 
EUR transaction amount
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 228.97       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 457.94       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 686.91       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 915.88       | false    | false    |
+    Then Loan status will be "ACTIVE"
+    # ========== REPAYMENT 1: 04 April 2025 ==========
+    When Admin sets the business date to "04 April 2025"
+    #And Admin runs inline COB job for Loan
+    And Customer makes "REPAYMENT" transaction with "AUTOPAY" payment type on 
"04 April 2025" with 48.91 EUR transaction amount and system-generated 
Idempotency key
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 228.97       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 457.94       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 686.91       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 915.88       | false    | false    |
+      | 04 April 2025    | Repayment        | 48.91  | 33.86     | 15.05    | 
0.0  | 0.0       | 882.02       | false    | false    |
+    Then Loan status will be "ACTIVE"
+
+    # ========== REPAYMENT 2: 02 May 2025 ==========
+    When Admin sets the business date to "02 May 2025"
+    And Customer makes "REPAYMENT" transaction with "AUTOPAY" payment type on 
"02 May 2025" with 48.91 EUR transaction amount and system-generated 
Idempotency key
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 228.97       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 457.94       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 686.91       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 915.88       | false    | false    |
+      | 04 April 2025    | Repayment        | 48.91  | 33.86     | 15.05    | 
0.0  | 0.0       | 882.02       | false    | false    |
+      | 02 May 2025      | Repayment        | 48.91  | 32.0      | 16.91    | 
0.0  | 0.0       | 850.02       | false    | false    |
+    Then Loan status will be "ACTIVE"
+
+    # ========== REPAYMENT 3: 30 May 2025 ==========
+    When Admin sets the business date to "30 May 2025"
+    And Customer makes "REPAYMENT" transaction with "AUTOPAY" payment type on 
"30 May 2025" with 48.91 EUR transaction amount and system-generated 
Idempotency key
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 228.97       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 457.94       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 686.91       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 915.88       | false    | false    |
+      | 04 April 2025    | Repayment        | 48.91  | 33.86     | 15.05    | 
0.0  | 0.0       | 882.02       | false    | false    |
+      | 02 May 2025      | Repayment        | 48.91  | 32.0      | 16.91    | 
0.0  | 0.0       | 850.02       | false    | false    |
+      | 30 May 2025      | Repayment        | 48.91  | 32.61     | 16.3     | 
0.0  | 0.0       | 817.41       | false    | false    |
+    Then Loan status will be "ACTIVE"
+
+    # ========== REPAYMENT 4: 27 June 2025 ==========
+    When Admin sets the business date to "27 June 2025"
+    And Customer makes "REPAYMENT" transaction with "AUTOPAY" payment type on 
"27 June 2025" with 48.91 EUR transaction amount and system-generated 
Idempotency key
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 228.97       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 457.94       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 686.91       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 915.88       | false    | false    |
+      | 04 April 2025    | Repayment        | 48.91  | 33.86     | 15.05    | 
0.0  | 0.0       | 882.02       | false    | false    |
+      | 02 May 2025      | Repayment        | 48.91  | 32.0      | 16.91    | 
0.0  | 0.0       | 850.02       | false    | false    |
+      | 30 May 2025      | Repayment        | 48.91  | 32.61     | 16.3     | 
0.0  | 0.0       | 817.41       | false    | false    |
+      | 27 June 2025     | Repayment        | 48.91  | 33.25     | 15.66    | 
0.0  | 0.0       | 784.16       | false    | false    |
+    Then Loan status will be "ACTIVE"
+
+    # ========== REPAYMENT 5: 08 August 2025 ==========
+    When Admin sets the business date to "08 August 2025"
+    And Customer makes "REPAYMENT" transaction with "AUTOPAY" payment type on 
"08 August 2025" with 48.91 EUR transaction amount and system-generated 
Idempotency key
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 228.97       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 457.94       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 686.91       | false    | false    |
+      | 11 March 2025    | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 915.88       | false    | false    |
+      | 04 April 2025    | Repayment        | 48.91  | 33.86     | 15.05    | 
0.0  | 0.0       | 882.02       | false    | false    |
+      | 02 May 2025      | Repayment        | 48.91  | 32.0      | 16.91    | 
0.0  | 0.0       | 850.02       | false    | false    |
+      | 30 May 2025      | Repayment        | 48.91  | 32.61     | 16.3     | 
0.0  | 0.0       | 817.41       | false    | false    |
+      | 27 June 2025     | Repayment        | 48.91  | 33.25     | 15.66    | 
0.0  | 0.0       | 784.16       | false    | false    |
+      | 08 August 2025   | Repayment        | 48.91  | 26.36     | 22.55    | 
0.0  | 0.0       | 757.8        | false    | false    |
+    Then Loan status will be "ACTIVE"
+
+    # ========== REPAYMENT 6: 05 September 2025 ==========
+    When Admin sets the business date to "05 September 2025"
+    And Customer makes "REPAYMENT" transaction with "AUTOPAY" payment type on 
"05 September 2025" with 48.91 EUR transaction amount and system-generated 
Idempotency key
+    Then Loan Transactions tab has the following data:
+      | Transaction date  | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 228.97       | false    | false    |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 457.94       | false    | false    |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 686.91       | false    | false    |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 915.88       | false    | false    |
+      | 04 April 2025     | Repayment        | 48.91  | 33.86     | 15.05    | 
0.0  | 0.0       | 882.02       | false    | false    |
+      | 02 May 2025       | Repayment        | 48.91  | 32.0      | 16.91    | 
0.0  | 0.0       | 850.02       | false    | false    |
+      | 30 May 2025       | Repayment        | 48.91  | 32.61     | 16.3     | 
0.0  | 0.0       | 817.41       | false    | false    |
+      | 27 June 2025      | Repayment        | 48.91  | 33.25     | 15.66    | 
0.0  | 0.0       | 784.16       | false    | false    |
+      | 08 August 2025    | Repayment        | 48.91  | 26.36     | 22.55    | 
0.0  | 0.0       | 757.8        | false    | false    |
+      | 05 September 2025 | Repayment        | 48.91  | 34.38     | 14.53    | 
0.0  | 0.0       | 723.42       | false    | false    |
+    Then Loan status will be "ACTIVE"
+
+    # ========== REPAYMENT 7: 03 October 2025 ==========
+    When Admin sets the business date to "03 October 2025"
+    And Customer makes "REPAYMENT" transaction with "AUTOPAY" payment type on 
"03 October 2025" with 48.91 EUR transaction amount and system-generated 
Idempotency key
+    Then Loan Transactions tab has the following data:
+      | Transaction date  | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 228.97       | false    | false    |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 457.94       | false    | false    |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 686.91       | false    | false    |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 915.88       | false    | false    |
+      | 04 April 2025     | Repayment        | 48.91  | 33.86     | 15.05    | 
0.0  | 0.0       | 882.02       | false    | false    |
+      | 02 May 2025       | Repayment        | 48.91  | 32.0      | 16.91    | 
0.0  | 0.0       | 850.02       | false    | false    |
+      | 30 May 2025       | Repayment        | 48.91  | 32.61     | 16.3     | 
0.0  | 0.0       | 817.41       | false    | false    |
+      | 27 June 2025      | Repayment        | 48.91  | 33.25     | 15.66    | 
0.0  | 0.0       | 784.16       | false    | false    |
+      | 08 August 2025    | Repayment        | 48.91  | 26.36     | 22.55    | 
0.0  | 0.0       | 757.8        | false    | false    |
+      | 05 September 2025 | Repayment        | 48.91  | 34.38     | 14.53    | 
0.0  | 0.0       | 723.42       | false    | false    |
+      | 03 October 2025   | Repayment        | 48.91  | 35.04     | 13.87    | 
0.0  | 0.0       | 688.38       | false    | false    |
+    Then Loan status will be "ACTIVE"
+
+    # ========== 4 MERCHANT ISSUED REFUNDS: 08 October 2025 ==========
+    When Admin sets the business date to "08 October 2025"
+    When Admin sets the business date to "09 October 2025"
+    And Customer makes "MERCHANT_ISSUED_REFUND" transaction with "AUTOPAY" 
payment type on "08 October 2025" with 228.97 EUR transaction amount and 
system-generated Idempotency key and interestRefundCalculation false
+    And Customer makes "MERCHANT_ISSUED_REFUND" transaction with "AUTOPAY" 
payment type on "08 October 2025" with 228.97 EUR transaction amount and 
system-generated Idempotency key and interestRefundCalculation false
+    And Customer makes "MERCHANT_ISSUED_REFUND" transaction with "AUTOPAY" 
payment type on "08 October 2025" with 228.97 EUR transaction amount and 
system-generated Idempotency key and interestRefundCalculation false
+    And Customer makes "MERCHANT_ISSUED_REFUND" transaction with "AUTOPAY" 
payment type on "08 October 2025" with 228.97 EUR transaction amount and 
system-generated Idempotency key and interestRefundCalculation false
+    Then Loan Transactions tab has the following data:
+      | Transaction date  | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 228.97       | false    | false    |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 457.94       | false    | false    |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 686.91       | false    | false    |
+      | 11 March 2025     | Disbursement     | 228.97 | 0.0       | 0.0      | 
0.0  | 0.0       | 915.88       | false    | false    |
+      | 04 April 2025     | Repayment        | 48.91  | 33.86     | 15.05    | 
0.0  | 0.0       | 882.02       | false    | false    |
+      | 11 April 2025     | Accrual Activity | 15.05  | 0.0       | 15.05    | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 02 May 2025       | Repayment        | 48.91  | 32.0      | 16.91    | 
0.0  | 0.0       | 850.02       | false    | false    |
+      | 11 May 2025       | Accrual Activity | 16.91  | 0.0       | 16.91    | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 30 May 2025       | Repayment        | 48.91  | 32.61     | 16.3     | 
0.0  | 0.0       | 817.41       | false    | false    |
+      | 11 June 2025      | Accrual Activity | 16.3   | 0.0       | 16.3     | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 27 June 2025      | Repayment        | 48.91  | 33.25     | 15.66    | 
0.0  | 0.0       | 784.16       | false    | false    |
+      | 11 July 2025      | Accrual Activity | 15.66  | 0.0       | 15.66    | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 08 August 2025    | Repayment        | 48.91  | 26.36     | 22.55    | 
0.0  | 0.0       | 757.8        | false    | false    |
+      | 11 August 2025    | Accrual Activity | 22.55  | 0.0       | 22.55    | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 05 September 2025 | Repayment        | 48.91  | 34.38     | 14.53    | 
0.0  | 0.0       | 723.42       | false    | false    |
+      | 11 September 2025 | Accrual Activity | 14.53  | 0.0       | 14.53    | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 03 October 2025   | Repayment        | 48.91  | 35.04     | 13.87    | 
0.0  | 0.0       | 688.38       | false    | false    |
+      | 08 October 2025   | Merchant Issued Refund | 228.97 | 226.62    | 2.35 
    | 0.0  | 0.0       | 461.76       | false    | false    |
+      | 08 October 2025   | Merchant Issued Refund | 228.97 | 228.97    | 0.0  
    | 0.0  | 0.0       | 232.79       | false    | false    |
+      | 08 October 2025   | Merchant Issued Refund | 228.97 | 228.97    | 0.0  
    | 0.0  | 0.0       | 3.82         | false    | false    |
+      | 08 October 2025   | Merchant Issued Refund | 228.97 | 3.82      | 0.0  
    | 0.0  | 0.0       | 0.0          | false    | false    |
+      | 08 October 2025   | Accrual Activity       | 16.22  | 0.0       | 
16.22    | 0.0  | 0.0       | 0.0          | false    | false    |
+      | 09 October 2025   | Accrual                | 117.22 | 0.0       | 
117.22   | 0.0  | 0.0       | 0.0          | false    | false    |
+    Then Loan status will be "OVERPAID"
+
+    # ========== CREDIT BALANCE REFUND TO CLOSE LOAN: 09 October 2025 
==========
+    When Admin sets the business date to "09 October 2025"
+    And Admin runs inline COB job for Loan
+    And Admin makes Credit Balance Refund transaction on "09 October 2025" 
with 225.15 EUR transaction amount
+    Then Loan Transactions tab has the following data:
+      | Transaction date  | Transaction Type       | Amount | Principal | 
Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 11 March 2025     | Disbursement           | 228.97 | 0.0       | 0.0  
    | 0.0  | 0.0       | 228.97       | false    | false    |
+      | 11 March 2025     | Disbursement           | 228.97 | 0.0       | 0.0  
    | 0.0  | 0.0       | 457.94       | false    | false    |
+      | 11 March 2025     | Disbursement           | 228.97 | 0.0       | 0.0  
    | 0.0  | 0.0       | 686.91       | false    | false    |
+      | 11 March 2025     | Disbursement           | 228.97 | 0.0       | 0.0  
    | 0.0  | 0.0       | 915.88       | false    | false    |
+      | 04 April 2025     | Repayment              | 48.91  | 33.86     | 
15.05    | 0.0  | 0.0       | 882.02       | false    | false    |
+      | 11 April 2025     | Accrual Activity       | 15.05  | 0.0       | 
15.05    | 0.0  | 0.0       | 0.0          | false    | false    |
+      | 02 May 2025       | Repayment              | 48.91  | 32.0      | 
16.91    | 0.0  | 0.0       | 850.02       | false    | false    |
+      | 11 May 2025       | Accrual Activity       | 16.91  | 0.0       | 
16.91    | 0.0  | 0.0       | 0.0          | false    | false    |
+      | 30 May 2025       | Repayment              | 48.91  | 32.61     | 16.3 
    | 0.0  | 0.0       | 817.41       | false    | false    |
+      | 11 June 2025      | Accrual Activity       | 16.3   | 0.0       | 16.3 
    | 0.0  | 0.0       | 0.0          | false    | false    |
+      | 27 June 2025      | Repayment              | 48.91  | 33.25     | 
15.66    | 0.0  | 0.0       | 784.16       | false    | false    |
+      | 11 July 2025      | Accrual Activity       | 15.66  | 0.0       | 
15.66    | 0.0  | 0.0       | 0.0          | false    | false    |
+      | 08 August 2025    | Repayment              | 48.91  | 26.36     | 
22.55    | 0.0  | 0.0       | 757.8        | false    | false    |
+      | 11 August 2025    | Accrual Activity       | 22.55  | 0.0       | 
22.55    | 0.0  | 0.0       | 0.0          | false    | false    |
+      | 05 September 2025 | Repayment              | 48.91  | 34.38     | 
14.53    | 0.0  | 0.0       | 723.42       | false    | false    |
+      | 11 September 2025 | Accrual Activity       | 14.53  | 0.0       | 
14.53    | 0.0  | 0.0       | 0.0          | false    | false    |
+      | 03 October 2025   | Repayment              | 48.91  | 35.04     | 
13.87    | 0.0  | 0.0       | 688.38       | false    | false    |
+      | 08 October 2025   | Merchant Issued Refund | 228.97 | 226.62    | 2.35 
    | 0.0  | 0.0       | 461.76       | false    | false    |
+      | 08 October 2025   | Merchant Issued Refund | 228.97 | 228.97    | 0.0  
    | 0.0  | 0.0       | 232.79       | false    | false    |
+      | 08 October 2025   | Merchant Issued Refund | 228.97 | 228.97    | 0.0  
    | 0.0  | 0.0       | 3.82         | false    | false    |
+      | 08 October 2025   | Merchant Issued Refund | 228.97 | 3.82      | 0.0  
    | 0.0  | 0.0       | 0.0          | false    | false    |
+      | 08 October 2025   | Accrual Activity       | 16.22  | 0.0       | 
16.22    | 0.0  | 0.0       | 0.0          | false    | false    |
+      | 09 October 2025   | Accrual                | 117.22 | 0.0       | 
117.22   | 0.0  | 0.0       | 0.0          | false    | false    |
+      | 09 October 2025   | Credit Balance Refund  | 225.15 | 0.0       | 0.0  
    | 0.0  | 0.0       | 0.0          | false    | false    |
+    Then Loan status will be "CLOSED_OBLIGATIONS_MET"
+
+    # ========== MANUAL INTEREST REFUNDS ON CLOSED LOAN ==========
+    When Admin manually adds Interest Refund for "1"th 
"MERCHANT_ISSUED_REFUND" transaction made on "08 October 2025" with 0.01 EUR 
interest refund amount
+    When Admin manually adds Interest Refund for "2"th 
"MERCHANT_ISSUED_REFUND" transaction made on "08 October 2025" with 0.01 EUR 
interest refund amount
+    When Admin manually adds Interest Refund for "3"th 
"MERCHANT_ISSUED_REFUND" transaction made on "08 October 2025" with 0.01 EUR 
interest refund amount
+    When Admin manually adds Interest Refund for "4"th 
"MERCHANT_ISSUED_REFUND" transaction made on "08 October 2025" with 0.01 EUR 
interest refund amount
+    Then Loan status will be "OVERPAID"
\ No newline at end of file

Reply via email to