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 8b3c8280de210cea441354b4e3ba00b5ade8591e
Author: Adam Saghy <[email protected]>
AuthorDate: Wed Jan 7 20:01:30 2026 +0100

    FINERACT-2433: Fix interest and accrual calculation in case of last 
installment payment
---
 .../global/LoanProductGlobalInitializerStep.java   |   3 +-
 .../features/LoanAccrualTransaction.feature        | 372 ++++++++++++++++++++-
 .../resources/features/LoanDelinquency.feature     |   4 +-
 .../features/LoanInterestPaymentWaiver.feature     |   8 +-
 .../test/resources/features/LoanReAging.feature    |  27 +-
 .../loanproduct/calc/ProgressiveEMICalculator.java |  19 +-
 .../loanproduct/calc/data/RepaymentPeriod.java     |   9 +
 .../LoanTransactionProcessingServiceImpl.java      |   3 +-
 .../LoanWritePlatformServiceJpaRepositoryImpl.java |  12 +-
 9 files changed, 420 insertions(+), 37 deletions(-)

diff --git 
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
index 09fa976f5f..c2cd3b08c5 100644
--- 
a/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
+++ 
b/fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java
@@ -2600,7 +2600,8 @@ public class LoanProductGlobalInitializerStep implements 
FineractGlobalInitializ
                 .defaultLoanProductsRequestLP2InterestDailyRecalculation()//
                 .name(name105)//
                 .paymentAllocation(List.of(//
-                        createPaymentAllocation("DEFAULT", 
"NEXT_INSTALLMENT")))
+                        createPaymentAllocation("DEFAULT", "NEXT_INSTALLMENT"),
+                        createPaymentAllocation("MERCHANT_ISSUED_REFUND", 
"LAST_INSTALLMENT")))
                 .enableAccrualActivityPosting(true)//
                 .chargeOffBehaviour("ZERO_INTEREST");//
         PostLoanProductsResponse 
responseLoanProductsRequestAdvInterestRecalculationZeroInterestChargeOffBehaviourAccrualActivity
 = createLoanProductIdempotent(
diff --git 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanAccrualTransaction.feature
 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanAccrualTransaction.feature
index d012e2fe4e..27dce9c3cd 100644
--- 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanAccrualTransaction.feature
+++ 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanAccrualTransaction.feature
@@ -1590,4 +1590,374 @@ Feature: LoanAccrualTransaction
     Then Loan Transactions tab has a "ACCRUAL" transaction with date "12 May 
2025" which has the following Journal entries:
       | Type   | Account code | Account name            | Debit | Credit |
       | ASSET  | 112603       | Interest/Fee Receivable | 1.3   |        |
-      | INCOME | 404007       | Fee Income              |       | 1.3    |
\ No newline at end of file
+      | INCOME | 404007       | Fee Income              |       | 1.3    |
+
+  @TestRailId:C4516
+  Scenario: Verify Interest recalculation - EARLY repayment, adjust LAST 
installment - UC5: 360/30, interest and accruals are correctly calculated till 
and after maturity date
+    When Admin sets the business date to "01 January 2024"
+    When Admin creates a client with random data
+    When Admin set 
"LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY_ACCRUAL_ACTIVITY_POSTING"
 loan product "MERCHANT_ISSUED_REFUND" transaction type to "LAST_INSTALLMENT" 
future installment allocation rule
+    When 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_RECALCULATION_DAILY_ACCRUAL_ACTIVITY_POSTING
 | 01 January 2024   | 100            | 7                      | 
DECLINING_BALANCE | DAILY                       | EQUAL_INSTALLMENTS | 6        
         | MONTHS                | 1              | MONTHS                 | 6  
                | 0                       | 0                      | 0          
          | ADVANCED_PAYMENT_ALLOCATION |
+    And Admin successfully approves the loan on "01 January 2024" with "100" 
amount and expected disbursement date on "01 January 2024"
+    When Admin successfully disburse the loan on "01 January 2024" with "100" 
EUR transaction amount
+    Then Loan Repayment schedule has 6 periods, with the following data for 
periods:
+      | Nr | Days | Date             | Paid date | Balance of loan | Principal 
due | Interest | Fees | Penalties | Due   | Paid | In advance | Late | 
Outstanding |
+      |    |      | 01 January 2024  |           | 100.0           |           
    |          | 0.0  |           | 0.0   | 0.0  |            |      |          
   |
+      | 1  | 31   | 01 February 2024 |           | 83.57           | 16.43     
    | 0.58     | 0.0  | 0.0       | 17.01 | 0.0  | 0.0        | 0.0  | 17.01    
   |
+      | 2  | 29   | 01 March 2024    |           | 67.05           | 16.52     
    | 0.49     | 0.0  | 0.0       | 17.01 | 0.0  | 0.0        | 0.0  | 17.01    
   |
+      | 3  | 31   | 01 April 2024    |           | 50.43           | 16.62     
    | 0.39     | 0.0  | 0.0       | 17.01 | 0.0  | 0.0        | 0.0  | 17.01    
   |
+      | 4  | 30   | 01 May 2024      |           | 33.71           | 16.72     
    | 0.29     | 0.0  | 0.0       | 17.01 | 0.0  | 0.0        | 0.0  | 17.01    
   |
+      | 5  | 31   | 01 June 2024     |           | 16.9            | 16.81     
    | 0.2      | 0.0  | 0.0       | 17.01 | 0.0  | 0.0        | 0.0  | 17.01    
   |
+      | 6  | 30   | 01 July 2024     |           | 0.0             | 16.9      
    | 0.1      | 0.0  | 0.0       | 17.0  | 0.0  | 0.0        | 0.0  | 17.0     
   |
+    Then Loan Repayment schedule has the following data in Total row:
+      | Principal due | Interest | Fees | Penalties | Due    | Paid | In 
advance | Late | Outstanding |
+      | 100.0         | 2.05     | 0.0  | 0.0       | 102.05 | 0.0  | 0.0      
  | 0.0  | 102.05      |
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 01 January 2024  | Disbursement     | 100.0  | 0.0       | 0.0      | 
0.0  | 0.0       | 100.0        | false    | false    |
+#    --- Early repayment with 17.01 EUR on 15 Jan ---
+    When Admin sets the business date to "15 January 2024"
+    When Admin makes "MERCHANT_ISSUED_REFUND" transaction with "AUTOPAY" 
payment type on "15 January 2024" with 17.01 EUR transaction amount
+    Then Loan Repayment schedule has 6 periods, with the following data for 
periods:
+      | Nr | Days | Date             | Paid date       | Balance of loan | 
Principal due | Interest | Fees | Penalties | Due   | Paid  | In advance | Late 
| Outstanding |
+      |    |      | 01 January 2024  |                 | 100.0           |     
          |          | 0.0  |           | 0.0   | 0.0   |            |      |   
          |
+      | 1  | 31   | 01 February 2024 |                 | 83.52           | 
16.48         | 0.53     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 2  | 29   | 01 March 2024    |                 | 66.9            | 
16.62         | 0.39     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 3  | 31   | 01 April 2024    |                 | 50.18           | 
16.72         | 0.29     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 4  | 30   | 01 May 2024      |                 | 33.36           | 
16.82         | 0.19     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 5  | 31   | 01 June 2024     |                 | 17.01           | 
16.35         | 0.1      | 0.0  | 0.0       | 16.45 | 0.0   | 0.0        | 0.0  
| 16.45       |
+      | 6  | 30   | 01 July 2024     | 15 January 2024 | 0.0             | 
17.01         | 0.0      | 0.0  | 0.0       | 17.01 | 17.01 | 17.01      | 0.0  
| 0.0         |
+    Then Loan Repayment schedule has the following data in Total row:
+      | Principal due | Interest | Fees | Penalties | Due   | Paid  | In 
advance | Late | Outstanding |
+      | 100.0         | 1.5      | 0.0  | 0.0       | 101.5 | 17.01 | 17.01    
  | 0.0  | 84.49       |
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type       | Amount | Principal | 
Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 01 January 2024  | Disbursement           | 100.0  | 0.0       | 0.0   
   | 0.0  | 0.0       | 100.0        | false    | false    |
+      | 15 January 2024  | Merchant Issued Refund | 17.01  | 17.01     | 0.0   
   | 0.0  | 0.0       | 82.99        | false    | false    |
+    When Admin sets the business date to "01 June 2024"
+    And Admin runs inline COB job for Loan
+    Then Loan Repayment schedule has 6 periods, with the following data for 
periods:
+      | Nr | Days | Date             | Paid date       | Balance of loan | 
Principal due | Interest | Fees | Penalties | Due   | Paid  | In advance | Late 
| Outstanding |
+      |    |      | 01 January 2024  |                 | 100.0           |     
          |          | 0.0  |           | 0.0   | 0.0   |            |      |   
          |
+      | 1  | 31   | 01 February 2024 |                 | 83.52           | 
16.48         | 0.53     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 2  | 29   | 01 March 2024    |                 | 66.99           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 3  | 31   | 01 April 2024    |                 | 50.46           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 4  | 30   | 01 May 2024      |                 | 33.93           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 5  | 31   | 01 June 2024     |                 | 17.01           | 
16.92         | 0.48     | 0.0  | 0.0       | 17.4  | 0.0   | 0.0        | 0.0  
| 17.4        |
+      | 6  | 30   | 01 July 2024     | 15 January 2024 | 0.0             | 
17.01         | 0.0      | 0.0  | 0.0       | 17.01 | 17.01 | 17.01      | 0.0  
| 0.0         |
+    Then Loan Repayment schedule has the following data in Total row:
+      | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
+      | 100.0         | 2.45     | 0.0  | 0.0       | 102.45 | 17.01 | 17.01   
   | 0.0  | 85.44       |
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type          | Amount | Principal | 
Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 01 January 2024  | Disbursement              | 100.0  | 0.0       | 
0.0      | 0.0  | 0.0       | 100.0        | false    | false    |
+      | 15 January 2024  | Merchant Issued Refund    | 17.01  | 17.01     | 
0.0      | 0.0  | 0.0       | 82.99        | false    | false    |
+      | 01 February 2024 | Accrual Activity          | 0.53   |  0.0      | 
0.53     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 March 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 April 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 May 2024      | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 31 May 2024      | Accrual                   | 1.87   |  0.0      | 
1.87     | 0.0  | 0.0       |  0.0         | false    | false    |
+    When Admin sets the business date to "02 June 2024"
+    And Admin runs inline COB job for Loan
+    Then Loan Repayment schedule has 6 periods, with the following data for 
periods:
+      | Nr | Days | Date             | Paid date       | Balance of loan | 
Principal due | Interest | Fees | Penalties | Due   | Paid  | In advance | Late 
| Outstanding |
+      |    |      | 01 January 2024  |                 | 100.0           |     
          |          | 0.0  |           | 0.0   | 0.0   |            |      |   
          |
+      | 1  | 31   | 01 February 2024 |                 | 83.52           | 
16.48         | 0.53     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 2  | 29   | 01 March 2024    |                 | 66.99           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 3  | 31   | 01 April 2024    |                 | 50.46           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 4  | 30   | 01 May 2024      |                 | 33.93           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 5  | 31   | 01 June 2024     |                 | 17.01           | 
16.92         | 0.5      | 0.0  | 0.0       | 17.42 | 0.0   | 0.0        | 0.0  
| 17.42       |
+      | 6  | 30   | 01 July 2024     | 15 January 2024 | 0.0             | 
17.01         | 0.0      | 0.0  | 0.0       | 17.01 | 17.01 | 17.01      | 0.0  
| 0.0         |
+    Then Loan Repayment schedule has the following data in Total row:
+      | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
+      | 100.0         | 2.47     | 0.0  | 0.0       | 102.47 | 17.01 | 17.01   
   | 0.0  | 85.46       |
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type          | Amount | Principal | 
Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 01 January 2024  | Disbursement              | 100.0  | 0.0       | 
0.0      | 0.0  | 0.0       | 100.0        | false    | false    |
+      | 15 January 2024  | Merchant Issued Refund    | 17.01  | 17.01     | 
0.0      | 0.0  | 0.0       | 82.99        | false    | false    |
+      | 01 February 2024 | Accrual Activity          | 0.53   |  0.0      | 
0.53     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 March 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 April 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 May 2024      | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 31 May 2024      | Accrual                   | 1.87   |  0.0      | 
1.87     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual                   | 0.58   |  0.0      | 
0.58     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+    When Admin sets the business date to "01 July 2024"
+    And Admin runs inline COB job for Loan
+    Then Loan Repayment schedule has 6 periods, with the following data for 
periods:
+      | Nr | Days | Date             | Paid date       | Balance of loan | 
Principal due | Interest | Fees | Penalties | Due   | Paid  | In advance | Late 
| Outstanding |
+      |    |      | 01 January 2024  |                 | 100.0           |     
          |          | 0.0  |           | 0.0   | 0.0   |            |      |   
          |
+      | 1  | 31   | 01 February 2024 |                 | 83.52           | 
16.48         | 0.53     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 2  | 29   | 01 March 2024    |                 | 66.99           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 3  | 31   | 01 April 2024    |                 | 50.46           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 4  | 30   | 01 May 2024      |                 | 33.93           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 5  | 31   | 01 June 2024     |                 | 17.01           | 
16.92         | 0.96     | 0.0  | 0.0       | 17.88 | 0.0   | 0.0        | 0.0  
| 17.88       |
+      | 6  | 30   | 01 July 2024     | 15 January 2024 | 0.0             | 
17.01         | 0.0      | 0.0  | 0.0       | 17.01 | 17.01 | 17.01      | 0.0  
| 0.0         |
+    Then Loan Repayment schedule has the following data in Total row:
+      | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
+      | 100.0         | 2.93     | 0.0  | 0.0       | 102.93 | 17.01 | 17.01   
   | 0.0  | 85.92       |
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type          | Amount | Principal | 
Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 01 January 2024  | Disbursement              | 100.0  | 0.0       | 
0.0      | 0.0  | 0.0       | 100.0        | false    | false    |
+      | 15 January 2024  | Merchant Issued Refund    | 17.01  | 17.01     | 
0.0      | 0.0  | 0.0       | 82.99        | false    | false    |
+      | 01 February 2024 | Accrual Activity          | 0.53   |  0.0      | 
0.53     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 March 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 April 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 May 2024      | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 31 May 2024      | Accrual                   | 1.87   |  0.0      | 
1.87     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual                   | 0.58   |  0.0      | 
0.58     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual Activity          | 0.95   |  0.0      | 
0.95     | 0.0  | 0.0       |  0.0         | false    | true     |
+      | 02 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 03 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 04 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 05 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 06 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 07 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 08 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 09 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 10 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 11 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 12 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 13 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 14 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 15 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 16 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 17 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 18 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 19 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 20 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 21 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 22 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 23 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 24 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 25 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 26 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 27 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 28 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 29 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 30 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+    When Admin sets the business date to "02 July 2024"
+    And Admin runs inline COB job for Loan
+    Then Loan Repayment schedule has 6 periods, with the following data for 
periods:
+      | Nr | Days | Date             | Paid date       | Balance of loan | 
Principal due | Interest | Fees | Penalties | Due   | Paid  | In advance | Late 
| Outstanding |
+      |    |      | 01 January 2024  |                 | 100.0           |     
          |          | 0.0  |           | 0.0   | 0.0   |            |      |   
          |
+      | 1  | 31   | 01 February 2024 |                 | 83.52           | 
16.48         | 0.53     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 2  | 29   | 01 March 2024    |                 | 66.99           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 3  | 31   | 01 April 2024    |                 | 50.46           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 4  | 30   | 01 May 2024      |                 | 33.93           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 5  | 31   | 01 June 2024     |                 | 17.01           | 
16.92         | 0.96     | 0.0  | 0.0       | 17.88 | 0.0   | 0.0        | 0.0  
| 17.88       |
+      | 6  | 30   | 01 July 2024     | 15 January 2024 | 0.0             | 
17.01         | 0.0      | 0.0  | 0.0       | 17.01 | 17.01 | 17.01      | 0.0  
| 0.0         |
+    Then Loan Repayment schedule has the following data in Total row:
+      | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
+      | 100.0         | 2.93     | 0.0  | 0.0       | 102.93 | 17.01 | 17.01   
   | 0.0  | 85.92       |
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type          | Amount | Principal | 
Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 01 January 2024  | Disbursement              | 100.0  | 0.0       | 
0.0      | 0.0  | 0.0       | 100.0        | false    | false    |
+      | 15 January 2024  | Merchant Issued Refund    | 17.01  | 17.01     | 
0.0      | 0.0  | 0.0       | 82.99        | false    | false    |
+      | 01 February 2024 | Accrual Activity          | 0.53   |  0.0      | 
0.53     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 March 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 April 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 May 2024      | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 31 May 2024      | Accrual                   | 1.87   |  0.0      | 
1.87     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual                   | 0.58   |  0.0      | 
0.58     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual Activity          | 0.96   |  0.0      | 
0.96     | 0.0  | 0.0       |  0.0         | false    | true     |
+      | 02 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 03 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 04 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 05 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 06 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 07 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 08 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 09 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 10 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 11 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 12 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 13 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 14 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 15 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 16 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 17 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 18 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 19 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 20 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 21 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 22 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 23 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 24 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 25 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 26 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 27 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 28 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 29 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 30 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 July 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+    When Admin sets the business date to "03 July 2024"
+    And Admin runs inline COB job for Loan
+    Then Loan Repayment schedule has 6 periods, with the following data for 
periods:
+      | Nr | Days | Date             | Paid date       | Balance of loan | 
Principal due | Interest | Fees | Penalties | Due   | Paid  | In advance | Late 
| Outstanding |
+      |    |      | 01 January 2024  |                 | 100.0           |     
          |          | 0.0  |           | 0.0   | 0.0   |            |      |   
          |
+      | 1  | 31   | 01 February 2024 |                 | 83.52           | 
16.48         | 0.53     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 2  | 29   | 01 March 2024    |                 | 66.99           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 3  | 31   | 01 April 2024    |                 | 50.46           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 4  | 30   | 01 May 2024      |                 | 33.93           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 5  | 31   | 01 June 2024     |                 | 17.01           | 
16.92         | 0.96     | 0.0  | 0.0       | 17.88 | 0.0   | 0.0        | 0.0  
| 17.88       |
+      | 6  | 30   | 01 July 2024     | 15 January 2024 | 0.0             | 
17.01         | 0.0      | 0.0  | 0.0       | 17.01 | 17.01 | 17.01      | 0.0  
| 0.0         |
+    Then Loan Repayment schedule has the following data in Total row:
+      | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
+      | 100.0         | 2.93     | 0.0  | 0.0       | 102.93 | 17.01 | 17.01   
   | 0.0  | 85.92       |
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type          | Amount | Principal | 
Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 01 January 2024  | Disbursement              | 100.0  | 0.0       | 
0.0      | 0.0  | 0.0       | 100.0        | false    | false    |
+      | 15 January 2024  | Merchant Issued Refund    | 17.01  | 17.01     | 
0.0      | 0.0  | 0.0       | 82.99        | false    | false    |
+      | 01 February 2024 | Accrual Activity          | 0.53   |  0.0      | 
0.53     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 March 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 April 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 May 2024      | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 31 May 2024      | Accrual                   | 1.87   |  0.0      | 
1.87     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual                   | 0.58   |  0.0      | 
0.58     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual Activity          | 0.96   |  0.0      | 
0.96     | 0.0  | 0.0       |  0.0         | false    | true     |
+      | 02 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 03 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 04 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 05 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 06 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 07 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 08 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 09 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 10 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 11 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 12 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 13 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 14 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 15 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 16 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 17 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 18 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 19 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 20 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 21 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 22 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 23 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 24 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 25 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 26 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 27 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 28 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 29 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 30 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 July 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+    When Admin sets the business date to "01 August 2024"
+    And Admin runs inline COB job for Loan
+    Then Loan Repayment schedule has 6 periods, with the following data for 
periods:
+      | Nr | Days | Date             | Paid date       | Balance of loan | 
Principal due | Interest | Fees | Penalties | Due   | Paid  | In advance | Late 
| Outstanding |
+      |    |      | 01 January 2024  |                 | 100.0           |     
          |          | 0.0  |           | 0.0   | 0.0   |            |      |   
          |
+      | 1  | 31   | 01 February 2024 |                 | 83.52           | 
16.48         | 0.53     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 2  | 29   | 01 March 2024    |                 | 66.99           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 3  | 31   | 01 April 2024    |                 | 50.46           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 4  | 30   | 01 May 2024      |                 | 33.93           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 5  | 31   | 01 June 2024     |                 | 17.01           | 
16.92         | 0.96     | 0.0  | 0.0       | 17.88 | 0.0   | 0.0        | 0.0  
| 17.88       |
+      | 6  | 30   | 01 July 2024     | 15 January 2024 | 0.0             | 
17.01         | 0.0      | 0.0  | 0.0       | 17.01 | 17.01 | 17.01      | 0.0  
| 0.0         |
+    Then Loan Repayment schedule has the following data in Total row:
+      | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
+      | 100.0         | 2.93     | 0.0  | 0.0       | 102.93 | 17.01 | 17.01   
   | 0.0  | 85.92       |
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type          | Amount | Principal | 
Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 01 January 2024  | Disbursement              | 100.0  | 0.0       | 
0.0      | 0.0  | 0.0       | 100.0        | false    | false    |
+      | 15 January 2024  | Merchant Issued Refund    | 17.01  | 17.01     | 
0.0      | 0.0  | 0.0       | 82.99        | false    | false    |
+      | 01 February 2024 | Accrual Activity          | 0.53   |  0.0      | 
0.53     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 March 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 April 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 May 2024      | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 31 May 2024      | Accrual                   | 1.87   |  0.0      | 
1.87     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual                   | 0.58   |  0.0      | 
0.58     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual Activity          | 0.96   |  0.0      | 
0.96     | 0.0  | 0.0       |  0.0         | false    | true     |
+      | 02 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 03 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 04 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 05 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 06 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 07 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 08 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 09 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 10 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 11 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 12 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 13 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 14 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 15 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 16 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 17 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 18 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 19 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 20 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 21 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 22 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 23 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 24 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 25 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 26 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 27 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 28 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 29 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 30 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 July 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+    When Admin sets the business date to "02 August 2024"
+    And Admin runs inline COB job for Loan
+    Then Loan Repayment schedule has 6 periods, with the following data for 
periods:
+      | Nr | Days | Date             | Paid date       | Balance of loan | 
Principal due | Interest | Fees | Penalties | Due   | Paid  | In advance | Late 
| Outstanding |
+      |    |      | 01 January 2024  |                 | 100.0           |     
          |          | 0.0  |           | 0.0   | 0.0   |            |      |   
          |
+      | 1  | 31   | 01 February 2024 |                 | 83.52           | 
16.48         | 0.53     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 2  | 29   | 01 March 2024    |                 | 66.99           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 3  | 31   | 01 April 2024    |                 | 50.46           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 4  | 30   | 01 May 2024      |                 | 33.93           | 
16.53         | 0.48     | 0.0  | 0.0       | 17.01 | 0.0   | 0.0        | 0.0  
| 17.01       |
+      | 5  | 31   | 01 June 2024     |                 | 17.01           | 
16.92         | 0.96     | 0.0  | 0.0       | 17.88 | 0.0   | 0.0        | 0.0  
| 17.88       |
+      | 6  | 30   | 01 July 2024     | 15 January 2024 | 0.0             | 
17.01         | 0.0      | 0.0  | 0.0       | 17.01 | 17.01 | 17.01      | 0.0  
| 0.0         |
+    Then Loan Repayment schedule has the following data in Total row:
+      | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
+      | 100.0         | 2.93     | 0.0  | 0.0       | 102.93 | 17.01 | 17.01   
   | 0.0  | 85.92       |
+    Then Loan Transactions tab has the following data:
+      | Transaction date | Transaction Type          | Amount | Principal | 
Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
+      | 01 January 2024  | Disbursement              | 100.0  | 0.0       | 
0.0      | 0.0  | 0.0       | 100.0        | false    | false    |
+      | 15 January 2024  | Merchant Issued Refund    | 17.01  | 17.01     | 
0.0      | 0.0  | 0.0       | 82.99        | false    | false    |
+      | 01 February 2024 | Accrual Activity          | 0.53   |  0.0      | 
0.53     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 March 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 April 2024    | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 May 2024      | Accrual Activity          | 0.48   |  0.0      | 
0.48     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 31 May 2024      | Accrual                   | 1.87   |  0.0      | 
1.87     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual                   | 0.58   |  0.0      | 
0.58     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 June 2024     | Accrual Activity          | 0.96   |  0.0      | 
0.96     | 0.0  | 0.0       |  0.0         | false    | true     |
+      | 02 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 03 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 04 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 05 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 06 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 07 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 08 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 09 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 10 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 11 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 12 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 13 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 14 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 15 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 16 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 17 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 18 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 19 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 20 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 21 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 22 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 23 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 24 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 25 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 26 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 27 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 28 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 29 June 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 30 June 2024     | Accrual                   | 0.02   |  0.0      | 
0.02     | 0.0  | 0.0       |  0.0         | false    | false    |
+      | 01 July 2024     | Accrual                   | 0.01   |  0.0      | 
0.01     | 0.0  | 0.0       |  0.0         | false    | false    |
+    When Loan Pay-off is made on "01 July 2024"
+    Then Loan is closed with zero outstanding balance and it's all 
installments have obligations met
+    When Admin set 
"LP2_ADV_PYMNT_INTEREST_DAILY_EMI_360_30_INTEREST_RECALCULATION_DAILY_ACCRUAL_ACTIVITY_POSTING"
 loan product "MERCHANT_ISSUED_REFUND" transaction type to "REAMORTIZATION" 
future installment allocation rule
diff --git 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanDelinquency.feature 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanDelinquency.feature
index e94a899490..b3444a6d68 100644
--- 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanDelinquency.feature
+++ 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanDelinquency.feature
@@ -1496,8 +1496,8 @@ Feature: LoanDelinquency
     Then Loan Transactions tab has the following data:
       | Transaction date | Transaction Type        | Amount | Principal | 
Interest | Fees | Penalties | Loan Balance |
       | 01 June 2024     | Disbursement            | 1000.0 | 0.0       | 0.0  
    | 0.0  | 0.0       | 1000.0       |
-      | 14 July 2024     | Accrual                 | 10.0   | 0.0       | 10.0 
    | 0.0  | 0.0       | 0.0          |
-      | 15 July 2024     | Repayment               | 343.33 | 333.33    | 10.0 
    | 0.0  | 0.0       | 666.67        |
+      | 14 July 2024     | Accrual                 | 14.19  | 0.0       | 
14.19    | 0.0  | 0.0       | 0.0          |
+      | 15 July 2024     | Repayment               | 343.33 | 333.33    | 10.0 
    | 0.0  | 0.0       | 666.67       |
     Then Loan has the following LOAN level next payment due data:
       | classification | nextPaymentDueDate | nextPaymentAmount |
       | NO_DELINQUENCY | 01 August 2024     | 343.33            |
diff --git 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanInterestPaymentWaiver.feature
 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanInterestPaymentWaiver.feature
index bd3dae122a..6e6ebed860 100644
--- 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanInterestPaymentWaiver.feature
+++ 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanInterestPaymentWaiver.feature
@@ -1017,11 +1017,11 @@ Feature: LoanInterestWaiver
       | 20 | 31   | 18 September 2023 |                   |  47.25          | 
19.23         | 0.7      | 0.0  | 0.0       | 19.93 |  0.0  |  0.0        | 0.0 
  | 19.93       |
       | 21 | 30   | 18 October 2023   |                   |  27.99          | 
19.26         | 0.67     | 0.0  | 0.0       | 19.93 |  0.0  |  0.0        | 0.0 
  | 19.93       |
       | 22 | 31   | 18 November 2023  |                   |   8.76          | 
19.23         | 0.7      | 0.0  | 0.0       | 19.93 |  0.0  |  0.0        | 0.0 
  | 19.93       |
-      | 23 | 30   | 18 December 2023  |                   |   0.0           | 
8.76          | 0.67     | 0.0  | 0.0       |  9.43 |  0.0  |  0.0        | 0.0 
  |  9.43       |
+      | 23 | 30   | 18 December 2023  |                   |   0.0           | 
8.76          | 1.37     | 0.0  | 0.0       | 10.13 |  0.0  |  0.0        | 0.0 
  | 10.13       |
       | 24 | 31   | 18 January 2024   | 20 January 2022   |   0.0           |  
0.0          | 0.0      | 0.0  | 0.0       |  0.0  |  0.0  |  0.0        | 0.0  
 | 0.0         |
     Then Loan Repayment schedule has the following data in Total row:
       | Principal due | Interest | Fees | Penalties | Due    | Paid   | In 
advance | Late    | Outstanding |
-      | 431.98        | 15.91    | 0.0  | 0.0       | 447.89 | 350.19 | 350.19 
    | 0.0     | 97.7        |
+      | 431.98        | 16.61    | 0.0  | 0.0       | 448.59 | 350.19 | 350.19 
    | 0.0     | 98.4        |
     Then Loan Transactions tab has the following data:
       | Transaction date   | Transaction Type        | Amount  | Principal  | 
Interest | Fees | Penalties | Loan Balance | Reverted | Replayed |
       | 18 January 2022    | Disbursement            | 431.98  |   0.0      |  
0.0     | 0.0  | 0.0       | 431.98       | false    | false    |
@@ -1233,12 +1233,12 @@ Feature: LoanInterestWaiver
       | 7  | 31   | 18 August 2022    |                   | 171.12          | 
37.28         | 0.69     | 0.0  | 0.0       | 37.97 | 29.17 | 29.17       | 0.0 
  | 8.8         |
       | 8  | 31   | 18 September 2022 |                   | 133.84          | 
37.28         | 0.69     | 0.0  | 0.0       | 37.97 | 29.17 | 29.17       | 0.0 
  | 8.8         |
       | 9  | 30   | 18 October 2022   |                   |  96.54          | 
37.3          | 0.67     | 0.0  | 0.0       | 37.97 | 29.17 | 29.17       | 0.0 
  | 8.8         |
-      | 10 | 31   | 18 November 2022  |                   |  58.29          | 
38.25         | 0.69     | 0.0  | 0.0       | 38.94 | 29.17 | 29.17       | 0.0 
  | 9.77        |
+      | 10 | 31   | 18 November 2022  |                   |  58.29          | 
38.25         | 2.05     | 0.0  | 0.0       | 40.3  | 29.17 | 29.17       | 0.0 
  |11.13        |
       | 11 | 30   | 18 December 2022  | 20 January 2022   |  29.12          | 
29.17         | 0.0      | 0.0  | 0.0       | 29.17 | 29.17 | 29.17       | 0.0 
  | 0.0         |
       | 12 | 31   | 18 January 2023   | 20 January 2022   |   0.0           | 
29.12         | 0.0      | 0.0  | 0.0       | 29.12 | 29.12 | 29.12       | 0.0 
  | 0.0         |
     Then Loan Repayment schedule has the following data in Total row:
       | Principal due | Interest | Fees | Penalties | Due    | Paid   | In 
advance | Late    | Outstanding |
-      | 431.98        | 6.98     | 0.0  | 0.0       | 438.96 | 350.19 | 350.19 
    | 0.0     | 88.77       |
+      | 431.98        | 8.34     | 0.0  | 0.0       | 440.32 | 350.19 | 350.19 
    | 0.0     | 90.13       |
     Then Loan Transactions tab has the following data:
       | Transaction date   | Transaction Type        | Amount  | Principal  | 
Interest | Fees | Penalties | Loan Balance |
       | 18 January 2022    | Disbursement            | 431.98  |   0.0      |  
0.0     | 0.0  | 0.0       | 431.98       |
diff --git 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanReAging.feature 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanReAging.feature
index f24b08ffaf..08811d80f2 100644
--- a/fineract-e2e-tests-runner/src/test/resources/features/LoanReAging.feature
+++ b/fineract-e2e-tests-runner/src/test/resources/features/LoanReAging.feature
@@ -8657,17 +8657,18 @@ Then Loan Repayment schedule has 4 periods, with the 
following data for periods:
     #  --- Charge-off ---
     When Admin sets the business date to "15 April 2024"
     And Admin does charge-off the loan on "15 April 2024"
-    Then Loan Repayment schedule has 8 periods, with the following data for 
periods:
-      | Nr | Days | Date              | Paid date     | Balance of loan | 
Principal due | Interest | Fees | Penalties | Due   | Paid  | In advance | Late 
| Outstanding |
-      |    |      | 01 January 2024   |               | 100.0           |      
         |          | 0.0  |           | 0.0   | 0.0   |            |      |    
         |
-      | 1  | 31   | 01 February 2024  | 15 March 2024 | 83.57           | 
16.43         | 0.58     | 0.0  | 0.0       | 17.01 | 17.01 | 0.0        | 0.0  
| 0.0         |
-      | 2  | 29   | 01 March 2024     | 15 March 2024 | 83.57           | 0.0  
         | 0.0      | 0.0  | 0.0       | 0.0   | 0.0   | 0.0        | 0.0  | 
0.0         |
-      | 3  | 31   | 01 April 2024     |               | 69.84           | 
13.73         | 0.48     | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
-      | 4  | 30   | 01 May 2024       |               | 55.73           | 
14.11         | 0.13     | 0.0  | 0.0       | 14.24 | 0.0   | 0.0        | 0.0  
| 14.24       |
-      | 5  | 31   | 01 June 2024      |               | 41.49           | 
14.24         | 0.0      | 0.0  | 0.0       | 14.24 | 0.0   | 0.0        | 0.0  
| 14.24       |
-      | 6  | 30   | 01 July 2024      |               | 27.25           | 
14.24         | 0.0      | 0.0  | 0.0       | 14.24 | 0.0   | 0.0        | 0.0  
| 14.24       |
-      | 7  | 31   | 01 August 2024    |               | 13.12           | 
14.13         | 0.11     | 0.0  | 0.0       | 14.24 | 0.0   | 0.0        | 0.0  
| 14.24       |
-      | 8  | 31   | 01 September 2024 |               | 0.0             | 
13.12         | 0.08     | 0.0  | 0.0       | 13.2  | 0.0   | 0.0        | 0.0  
| 13.2        |
+    Then Loan Repayment schedule has 9 periods, with the following data for 
periods:
+      | Nr | Days | Date              | Paid date       | Balance of loan | 
Principal due | Interest | Fees | Penalties | Due   | Paid  | In advance | Late 
| Outstanding |
+      |    |      | 01 January 2024   |                 | 100.0           |    
           |          | 0.0  |           | 0.0   | 0.0   |            |      |  
           |
+      | 1  | 31   | 01 February 2024  | 01 February 2024| 83.57           | 
16.43         | 0.58     | 0.0  | 0.0       | 17.01 | 17.01 | 0.0        | 0.0  
| 0.0         |
+      | 2  | 29   | 01 March 2024     | 15 March 2024   | 83.57           | 
0.0           | 0.0      | 0.0  | 0.0       | 0.0   | 0.0   | 0.0        | 0.0  
| 0.0         |
+      | 3  | 14   | 15 March 2024     | 15 March 2024   | 83.57           | 
0.0           | 0.0      | 0.0  | 0.0       | 0.0   | 0.0   | 0.0        | 0.0  
| 0.0         |
+      | 4  | 17   | 01 April 2024     |                 | 69.84           | 
13.73         | 0.48     | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 5  | 30   | 01 May 2024       |                 | 55.76           | 
14.08         | 0.13     | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 6  | 31   | 01 June 2024      |                 | 41.55           | 
14.21         | 0.0      | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 7  | 30   | 01 July 2024      |                 | 27.34           | 
14.21         | 0.0      | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 8  | 31   | 01 August 2024    |                 | 13.24           | 
14.1          | 0.11     | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 9  | 31   | 01 September 2024 |                 | 0.0             | 
13.24         | 0.08     | 0.0  | 0.0       | 13.32 | 0.0   | 0.0        | 0.0  
| 13.32       |
     And Loan Repayment schedule has the following data in Total row:
       | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
       | 100.0         | 1.38     | 0.0  | 0.0       | 101.38 | 17.01 | 0.0     
   | 0.0  | 84.37       |
@@ -8675,7 +8676,7 @@ Then Loan Repayment schedule has 4 periods, with the 
following data for periods:
       | Transaction date | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
       | 01 January 2024  | Disbursement     | 100.0  | 0.0       | 0.0      | 
0.0  | 0.0       | 100.0        | false    | false    |
       | 01 February 2024 | Repayment        | 17.01  | 16.43     | 0.58     | 
0.0  | 0.0       | 83.57        | false    | false    |
-      | 15 March 2024    | Re-age           | 83.7   | 83.57     | 0.13     | 
0.0  | 0.0       | 0.0          | false    | true     |
+      | 15 March 2024    | Re-age           | 83.78  | 83.57     | 0.21     | 
0.0  | 0.0       | 0.0          | false    | false    |
       | 15 April 2024    | Accrual          | 1.19   | 0.0       | 1.19     | 
0.0  | 0.0       | 0.0          | false    | false    |
       | 15 April 2024    | Charge-off       | 84.37  | 83.57     | 0.8      | 
0.0  | 0.0       | 0.0          | false    | false    |
 #    --- Charge-off undo ---
@@ -8700,7 +8701,7 @@ Then Loan Repayment schedule has 4 periods, with the 
following data for periods:
       | Transaction date | Transaction Type | Amount | Principal | Interest | 
Fees | Penalties | Loan Balance | Reverted | Replayed |
       | 01 January 2024  | Disbursement     | 100.0  | 0.0       | 0.0      | 
0.0  | 0.0       | 100.0        | false    | false    |
       | 01 February 2024 | Repayment        | 17.01  | 16.43     | 0.58     | 
0.0  | 0.0       | 83.57        | false    | false    |
-      | 15 March 2024    | Re-age           | 83.78  | 83.57     | 0.21     | 
0.0  | 0.0       | 0.0          | false    | true     |
+      | 15 March 2024    | Re-age           | 83.78  | 83.57     | 0.21     | 
0.0  | 0.0       | 0.0          | false    | false    |
       | 15 April 2024    | Accrual          | 1.19   | 0.0       | 1.19     | 
0.0  | 0.0       | 0.0          | false    | false    |
       | 15 April 2024    | Charge-off       | 84.37  | 83.57     | 0.8      | 
0.0  | 0.0       | 0.0          | true     | false    |
 #   --- Close loan ---
diff --git 
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/ProgressiveEMICalculator.java
 
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/ProgressiveEMICalculator.java
index 55faa01d8a..041e7c97f7 100644
--- 
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/ProgressiveEMICalculator.java
+++ 
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/ProgressiveEMICalculator.java
@@ -601,17 +601,20 @@ public final class ProgressiveEMICalculator implements 
EMICalculator {
     public boolean recalculateModelOverdueAmountsTillDate(final 
ProgressiveLoanInterestScheduleModel scheduleModel,
             final LocalDate targetDate, boolean prepayAttempt) {
         boolean hasChange = false;
-        final List<RepaymentPeriod> 
overdueInstallmentsSortedByInstallmentNumber = 
findPossiblyOverdueRepaymentPeriods(targetDate,
-                scheduleModel);
+        LocalDate recalculatedTargetDate = DateUtils.isAfter(targetDate, 
scheduleModel.getLastRepaymentPeriod().getDueDate())
+                ? scheduleModel.getLastRepaymentPeriod().getDueDate()
+                : targetDate;
+        final List<RepaymentPeriod> 
overdueInstallmentsSortedByInstallmentNumber = 
findPossiblyOverdueRepaymentPeriods(
+                recalculatedTargetDate, scheduleModel);
         if (!overdueInstallmentsSortedByInstallmentNumber.isEmpty()) {
             final RepaymentPeriod lastPeriod = 
scheduleModel.getLastRepaymentPeriod();
-            final RepaymentPeriod currentPeriod = 
scheduleModel.findRepaymentPeriod(targetDate).orElse(lastPeriod);
+            final RepaymentPeriod currentPeriod = 
scheduleModel.findRepaymentPeriod(recalculatedTargetDate).orElse(lastPeriod);
             Money overDuePrincipal = scheduleModel.zero();
             Money aggregatedOverDuePrincipal = scheduleModel.zero();
             for (RepaymentPeriod processingPeriod : 
overdueInstallmentsSortedByInstallmentNumber) {
                 // add and subtract outstanding principal
                 if (!overDuePrincipal.isZero()) {
-                    final boolean currentChanges = 
adjustOverduePrincipal(targetDate, processingPeriod, overDuePrincipal,
+                    final boolean currentChanges = 
adjustOverduePrincipal(recalculatedTargetDate, processingPeriod, 
overDuePrincipal,
                             aggregatedOverDuePrincipal, scheduleModel, 
prepayAttempt);
 
                     hasChange = hasChange || currentChanges;
@@ -621,15 +624,15 @@ public final class ProgressiveEMICalculator implements 
EMICalculator {
                 aggregatedOverDuePrincipal = 
aggregatedOverDuePrincipal.add(overDuePrincipal);
             }
 
-            if (!currentPeriod.equals(lastPeriod) || 
!targetDate.isAfter(lastPeriod.getDueDate())) {
-                final boolean currentChanges = 
adjustOverduePrincipal(targetDate, currentPeriod, overDuePrincipal,
+            if (!currentPeriod.equals(lastPeriod) || 
!recalculatedTargetDate.isAfter(lastPeriod.getDueDate())) {
+                final boolean currentChanges = 
adjustOverduePrincipal(recalculatedTargetDate, currentPeriod, overDuePrincipal,
                         aggregatedOverDuePrincipal, scheduleModel, 
prepayAttempt);
                 hasChange = hasChange || currentChanges;
 
             }
             if (aggregatedOverDuePrincipal.isGreaterThanZero() && 
(scheduleModel.lastOverdueBalanceChange() == null
-                    || 
scheduleModel.lastOverdueBalanceChange().isBefore(targetDate))) {
-                scheduleModel.lastOverdueBalanceChange(targetDate);
+                    || 
scheduleModel.lastOverdueBalanceChange().isBefore(recalculatedTargetDate))) {
+                scheduleModel.lastOverdueBalanceChange(recalculatedTargetDate);
             }
         }
 
diff --git 
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/RepaymentPeriod.java
 
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/RepaymentPeriod.java
index 755f47a74d..2f785373f8 100644
--- 
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/RepaymentPeriod.java
+++ 
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/RepaymentPeriod.java
@@ -87,6 +87,7 @@ public class RepaymentPeriod {
     @Getter
     private final ILoanConfigurationDetails loanProductRelatedDetail;
     @JsonExclude
+    @Setter
     private MonetaryCurrency currency;
 
     @Getter
@@ -154,6 +155,10 @@ public class RepaymentPeriod {
                 repaymentPeriod.isReAgedEarlyRepaymentHolder(), 
repaymentPeriod.getReAgedInterest());
         
newRepaymentPeriod.setCreditedPrincipalMovedDueReAge(repaymentPeriod.getCreditedPrincipalMovedDueReAge());
         
newRepaymentPeriod.setCreditedInterestMovedDueReAge(repaymentPeriod.getCreditedInterestMovedDueReAge());
+        
newRepaymentPeriod.setTotalDisbursedAmount(repaymentPeriod.getTotalDisbursedAmount());
+        
newRepaymentPeriod.setTotalCapitalizedIncomeAmount(repaymentPeriod.getTotalCapitalizedIncomeAmount());
+        newRepaymentPeriod.setInterestMoved(repaymentPeriod.isInterestMoved());
+        newRepaymentPeriod.setCurrency(repaymentPeriod.getCurrency());
         // There is always at least 1 interest period, by default with same 
from-due date as repayment period
         for (InterestPeriod interestPeriod : 
repaymentPeriod.getInterestPeriods()) {
             
newRepaymentPeriod.getInterestPeriods().add(InterestPeriod.copy(newRepaymentPeriod,
 interestPeriod, mc));
@@ -169,6 +174,10 @@ public class RepaymentPeriod {
                 repaymentPeriod.isReAged(), 
repaymentPeriod.isReAgedEarlyRepaymentHolder(), 
repaymentPeriod.getReAgedInterest());
         
newRepaymentPeriod.setCreditedPrincipalMovedDueReAge(repaymentPeriod.getCreditedPrincipalMovedDueReAge());
         
newRepaymentPeriod.setCreditedInterestMovedDueReAge(repaymentPeriod.getCreditedInterestMovedDueReAge());
+        
newRepaymentPeriod.setTotalDisbursedAmount(repaymentPeriod.getTotalDisbursedAmount());
+        
newRepaymentPeriod.setTotalCapitalizedIncomeAmount(repaymentPeriod.getTotalCapitalizedIncomeAmount());
+        newRepaymentPeriod.setInterestMoved(repaymentPeriod.isInterestMoved());
+        newRepaymentPeriod.setCurrency(repaymentPeriod.getCurrency());
         // There is always at least 1 interest period, by default with same 
from-due date as repayment period
         for (InterestPeriod interestPeriod : 
repaymentPeriod.getInterestPeriods()) {
             var interestPeriodCopy = InterestPeriod.copy(newRepaymentPeriod, 
interestPeriod);
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanTransactionProcessingServiceImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanTransactionProcessingServiceImpl.java
index 41d7f4a1f0..e4cfcfa507 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanTransactionProcessingServiceImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanTransactionProcessingServiceImpl.java
@@ -131,7 +131,8 @@ public class LoanTransactionProcessingServiceImpl 
implements LoanTransactionProc
 
     @Override
     public LoanScheduleDTO getRecalculatedSchedule(final ScheduleGeneratorDTO 
generatorDTO, Loan loan) {
-        if (!loan.isInterestBearingAndInterestRecalculationEnabled() || 
loan.isNpa() || loan.isChargedOff()) {
+        if (!loan.isInterestBearingAndInterestRecalculationEnabled() || 
loan.isNpa()
+                || (loan.isChargedOff() && loan.isCumulativeSchedule())) {
             return null;
         }
         final InterestMethod interestMethod = 
loan.getLoanRepaymentScheduleDetail().getInterestMethod();
diff --git 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
index 444f089b41..5bda35834e 100644
--- 
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
+++ 
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
@@ -2742,24 +2742,22 @@ public class LoanWritePlatformServiceJpaRepositoryImpl 
implements LoanWritePlatf
                     businessEventNotifierService.notifyPostBusinessEvent(new 
LoanAdjustTransactionBusinessEvent(data));
                 });
 
-        final LoanTransaction chargeOffTransaction = 
LoanTransaction.chargeOff(loan, transactionDate, txnExternalId);
+        final LoanTransaction chargeOffTransaction;
 
         if (loan.isInterestBearingAndInterestRecalculationEnabled()) {
-            if (loan.isCumulativeSchedule()) {
-                final ScheduleGeneratorDTO scheduleGeneratorDTO = 
this.loanUtilService.buildScheduleGeneratorDTO(loan, null, null);
-                
loanScheduleService.regenerateRepaymentScheduleWithInterestRecalculation(loan, 
scheduleGeneratorDTO);
-            }
+            final ScheduleGeneratorDTO scheduleGeneratorDTO = 
this.loanUtilService.buildScheduleGeneratorDTO(loan, null, null);
+            
loanScheduleService.regenerateRepaymentScheduleWithInterestRecalculation(loan, 
scheduleGeneratorDTO);
+            chargeOffTransaction = LoanTransaction.chargeOff(loan, 
transactionDate, txnExternalId);
             reprocessLoanTransactionsService.reprocessTransactions(loan, 
List.of(chargeOffTransaction));
             loan.addLoanTransaction(chargeOffTransaction);
         } else {
+            chargeOffTransaction = LoanTransaction.chargeOff(loan, 
transactionDate, txnExternalId);
             
reprocessLoanTransactionsService.processLatestTransaction(chargeOffTransaction, 
loan);
             loan.addLoanTransaction(chargeOffTransaction);
         }
         loanTransactionRepository.saveAndFlush(chargeOffTransaction);
         
journalEntryPoster.postJournalEntriesForLoanTransaction(chargeOffTransaction, 
false, false);
 
-        saveAndFlushLoanWithDataIntegrityViolationChecks(loan);
-
         String noteText = 
command.stringValueOfParameterNamed(LoanApiConstants.noteParameterName);
         if (StringUtils.isNotBlank(noteText)) {
             changes.put(LoanApiConstants.noteParameterName, noteText);

Reply via email to