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 009d7b71a9a026477be5d0d0381373c8c3606062
Author: Peter Kovacs <[email protected]>
AuthorDate: Fri Jun 6 12:01:40 2025 +0200

    FINERACT-2232: Capitalized income - Business events - E2E
---
 ...eAdjustmentTransactionCreatedBusinessEvent.java | 27 +++++++++++++++
 ...lizedIncomeTransactionCreatedBusinessEvent.java | 27 +++++++++++++++
 .../fineract/test/stepdef/loan/LoanStepDef.java    | 38 ++++++++++++++++++++++
 .../features/LoanCapitalizedIncome.feature         | 26 +++++++++++++++
 4 files changed, 118 insertions(+)

diff --git 
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/loan/transaction/LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent.java
 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/loan/transaction/LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent.java
new file mode 100644
index 0000000000..6bbc797e0e
--- /dev/null
+++ 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/loan/transaction/LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent.java
@@ -0,0 +1,27 @@
+/**
+ * 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.test.messaging.event.loan.transaction;
+
+public class LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent 
extends AbstractLoanTransactionEvent {
+
+    @Override
+    public String getEventName() {
+        return 
"LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent";
+    }
+}
diff --git 
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/loan/transaction/LoanCapitalizedIncomeTransactionCreatedBusinessEvent.java
 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/loan/transaction/LoanCapitalizedIncomeTransactionCreatedBusinessEvent.java
new file mode 100644
index 0000000000..7aaf0fd9c7
--- /dev/null
+++ 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/messaging/event/loan/transaction/LoanCapitalizedIncomeTransactionCreatedBusinessEvent.java
@@ -0,0 +1,27 @@
+/**
+ * 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.test.messaging.event.loan.transaction;
+
+public class LoanCapitalizedIncomeTransactionCreatedBusinessEvent extends 
AbstractLoanTransactionEvent {
+
+    @Override
+    public String getEventName() {
+        return "LoanCapitalizedIncomeTransactionCreatedBusinessEvent";
+    }
+}
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 ce94999490..2a282b0346 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
@@ -138,8 +138,10 @@ import 
org.apache.fineract.test.messaging.event.loan.transaction.BulkBusinessEve
 import 
org.apache.fineract.test.messaging.event.loan.transaction.LoanAccrualAdjustmentTransactionBusinessEvent;
 import 
org.apache.fineract.test.messaging.event.loan.transaction.LoanAccrualTransactionCreatedBusinessEvent;
 import 
org.apache.fineract.test.messaging.event.loan.transaction.LoanAdjustTransactionBusinessEvent;
+import 
org.apache.fineract.test.messaging.event.loan.transaction.LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent;
 import 
org.apache.fineract.test.messaging.event.loan.transaction.LoanCapitalizedIncomeAmortizationAdjustmentTransactionCreatedBusinessEvent;
 import 
org.apache.fineract.test.messaging.event.loan.transaction.LoanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent;
+import 
org.apache.fineract.test.messaging.event.loan.transaction.LoanCapitalizedIncomeTransactionCreatedBusinessEvent;
 import 
org.apache.fineract.test.messaging.event.loan.transaction.LoanChargeAdjustmentPostBusinessEvent;
 import 
org.apache.fineract.test.messaging.event.loan.transaction.LoanChargeOffEvent;
 import 
org.apache.fineract.test.messaging.event.loan.transaction.LoanChargeOffUndoEvent;
@@ -4240,6 +4242,42 @@ public class LoanStepDef extends AbstractStepDef {
                 finalAmortizationTransactionId);
     }
 
+    @Then("LoanCapitalizedIncomeTransactionCreatedBusinessEvent is raised on 
{string}")
+    public void 
checkLoanCapitalizedIncomeTransactionCreatedBusinessEvent(final String date) 
throws IOException {
+        Response<PostLoansResponse> loanCreateResponse = 
testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+        long loanId = loanCreateResponse.body().getLoanId();
+
+        Response<GetLoansLoanIdResponse> loanDetailsResponse = 
loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
+        ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
+
+        List<GetLoansLoanIdTransactions> transactions = 
loanDetailsResponse.body().getTransactions();
+        GetLoansLoanIdTransactions finalAmortizationTransaction = 
transactions.stream()
+                .filter(t -> date.equals(FORMATTER.format(t.getDate())) && 
"Capitalized Income".equals(t.getType().getValue())).findFirst()
+                .orElseThrow(() -> new IllegalStateException(String.format("No 
Capitalized Income transaction found on %s", date)));
+        Long finalAmortizationTransactionId = 
finalAmortizationTransaction.getId();
+
+        
eventAssertion.assertEventRaised(LoanCapitalizedIncomeTransactionCreatedBusinessEvent.class,
 finalAmortizationTransactionId);
+    }
+
+    @Then("LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent is 
raised on {string}")
+    public void 
checkLoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent(final 
String date) throws IOException {
+        Response<PostLoansResponse> loanCreateResponse = 
testContext().get(TestContextKey.LOAN_CREATE_RESPONSE);
+        long loanId = loanCreateResponse.body().getLoanId();
+
+        Response<GetLoansLoanIdResponse> loanDetailsResponse = 
loansApi.retrieveLoan(loanId, false, "transactions", "", "").execute();
+        ErrorHelper.checkSuccessfulApiCall(loanDetailsResponse);
+
+        List<GetLoansLoanIdTransactions> transactions = 
loanDetailsResponse.body().getTransactions();
+        GetLoansLoanIdTransactions finalAmortizationTransaction = 
transactions.stream()
+                .filter(t -> date.equals(FORMATTER.format(t.getDate())) && 
"Capitalized Income Adjustment".equals(t.getType().getValue()))
+                .findFirst().orElseThrow(
+                        () -> new IllegalStateException(String.format("No 
Capitalized Income Adjustment transaction found on %s", date)));
+        Long finalAmortizationTransactionId = 
finalAmortizationTransaction.getId();
+
+        
eventAssertion.assertEventRaised(LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent.class,
+                finalAmortizationTransactionId);
+    }
+
     @And("Admin adds capitalized income adjustment with {string} payment type 
to the loan on {string} with {string} EUR transaction amount")
     public void adminAddsCapitalizedIncomeAdjustmentToTheLoan(final String 
transactionPaymentType, final String transactionDate,
             final String amount) throws IOException {
diff --git 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanCapitalizedIncome.feature
 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanCapitalizedIncome.feature
index e983cf545c..708fc07b56 100644
--- 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanCapitalizedIncome.feature
+++ 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanCapitalizedIncome.feature
@@ -4653,3 +4653,29 @@ Feature: Capitalized Income
       | 31 January 2024  | Capitalized Income Amortization | 17.03  | 0.0      
 | 17.03    | 0.0  | 0.0       | 0.0          | false    | false    |
       | 01 February 2024 | Accrual                         | 0.31   | 0.0      
 | 0.31     | 0.0  | 0.0       | 0.0          | false    | false    |
       | 01 February 2024 | Capitalized Income Amortization | 17.77  | 0.0      
 | 17.77    | 0.0  | 0.0       | 0.0          | false    | false    |
+
+  @TestRailId:C3735
+  Scenario: Verify Capitalized Income business events
+    When Admin sets the business date to "01 January 2024"
+    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_INTEREST_DAILY_EMI_360_30_INTEREST_RECALC_DAILY_CAPITALIZED_INCOME_ADJ_CUSTOM_ALLOC
 | 01 January 2024   | 150            | 7                      | 
DECLINING_BALANCE | DAILY                       | EQUAL_INSTALLMENTS | 3        
         | MONTHS                | 1              | MONTHS                 | 3  
                | 0                       | 0                      | 0          
          | ADVANCED_PAYMENT_ALLOCATION |
+    And Admin successfully approves the loan on "01 January 2024" with "150" 
amount and expected disbursement date on "01 January 2024"
+    And Admin successfully disburse the loan on "01 January 2024" with "90" 
EUR transaction amount
+    And Admin adds capitalized income with "AUTOPAY" payment type to the loan 
on "01 January 2024" with "60" EUR transaction amount
+    And Admin sets the business date to "02 January 2024"
+    Then LoanCapitalizedIncomeTransactionCreatedBusinessEvent is raised on "01 
January 2024"
+    When Admin runs inline COB job for Loan
+    Then LoanCapitalizedIncomeAmortizationTransactionCreatedBusinessEvent is 
raised on "01 January 2024"
+    And Loan status will be "ACTIVE"
+    When Admin adds capitalized income adjustment with "AUTOPAY" payment type 
to the loan on "02 January 2024" with "10" EUR transaction amount
+    And Admin sets the business date to "03 January 2024"
+    Then LoanCapitalizedIncomeAdjustmentTransactionCreatedBusinessEvent is 
raised on "02 January 2024"
+    When Admin runs inline COB job for Loan
+    And Admin sets the business date to "04 January 2024"
+    And Admin runs inline COB job for Loan
+    And Customer undo "1"th capitalized income adjustment on "02 January 2024"
+    When Customer undo "1"th "Capitalized Income" transaction made on "01 
January 2024"
+    And Admin sets the business date to "05 January 2024"
+    And Admin runs inline COB job for Loan

Reply via email to