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


The following commit(s) were added to refs/heads/develop by this push:
     new ddc82f1b68 FINERACT-2389: loan is not closed with outstanding amount 
during pay-off loan with reschedule trns
ddc82f1b68 is described below

commit ddc82f1b68b30153c470baae76c888bd786e1ec8
Author: mariiaKraievska <[email protected]>
AuthorDate: Wed Jan 21 15:43:30 2026 +0200

    FINERACT-2389: loan is not closed with outstanding amount during pay-off 
loan with reschedule trns
---
 .../test/resources/features/LoanReAging.feature    | 65 +++++++++++-----------
 .../resources/features/LoanReAgingAccruals.feature | 15 +++--
 .../features/LoanReAgingEqualAmortization.feature  | 10 ++--
 .../resources/features/LoanReAmortization.feature  | 51 +++++++++++++++--
 .../loanproduct/calc/ProgressiveEMICalculator.java |  7 ++-
 .../data/ProgressiveLoanInterestScheduleModel.java | 13 ++---
 6 files changed, 102 insertions(+), 59 deletions(-)

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 e92701e8b1..b4457c8078 100644
--- a/fineract-e2e-tests-runner/src/test/resources/features/LoanReAging.feature
+++ b/fineract-e2e-tests-runner/src/test/resources/features/LoanReAging.feature
@@ -8005,14 +8005,14 @@ Then Loan Repayment schedule has 4 periods, with the 
following data for periods:
       | 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     |                  | 70.25           | 
13.32         | 0.98     | 0.0  | 0.0       | 14.3  | 0.0   | 0.0        | 0.0  
| 14.3        |
-      | 5  | 30   | 01 May 2024       |                  | 56.08           | 
14.17         | 0.13     | 0.0  | 0.0       | 14.3  | 0.0   | 0.0        | 0.0  
| 14.3        |
-      | 6  | 31   | 01 June 2024      |                  | 41.78           | 
14.3          | 0.0      | 0.0  | 0.0       | 14.3  | 0.0   | 0.0        | 0.0  
| 14.3        |
-      | 7  | 30   | 01 July 2024      |                  | 27.65           | 
14.13         | 0.17     | 0.0  | 0.0       | 14.3  | 0.0   | 0.0        | 0.0  
| 14.3        |
-      | 8  | 31   | 01 August 2024    |                  | 13.51           | 
14.14         | 0.16     | 0.0  | 0.0       | 14.3  | 0.0   | 0.0        | 0.0  
| 14.3        |
-      | 9  | 31   | 01 September 2024 |                  | 0.0             | 
13.51         | 0.08     | 0.0  | 0.0       | 13.59 | 0.0   | 0.0        | 0.0  
| 13.59       |
+      | 5  | 30   | 01 May 2024       |                  | 56.06           | 
14.19         | 0.11     | 0.0  | 0.0       | 14.3  | 0.0   | 0.0        | 0.0  
| 14.3        |
+      | 6  | 31   | 01 June 2024      |                  | 41.76           | 
14.3          | 0.0      | 0.0  | 0.0       | 14.3  | 0.0   | 0.0        | 0.0  
| 14.3        |
+      | 7  | 30   | 01 July 2024      |                  | 27.63           | 
14.13         | 0.17     | 0.0  | 0.0       | 14.3  | 0.0   | 0.0        | 0.0  
| 14.3        |
+      | 8  | 31   | 01 August 2024    |                  | 13.49           | 
14.14         | 0.16     | 0.0  | 0.0       | 14.3  | 0.0   | 0.0        | 0.0  
| 14.3        |
+      | 9  | 31   | 01 September 2024 |                  | 0.0             | 
13.49         | 0.08     | 0.0  | 0.0       | 13.57 | 0.0   | 0.0        | 0.0  
| 13.57       |
     And Loan Repayment schedule has the following data in Total row:
-      | Principal due | Interest | Fees | Penalties | Due   | Paid  | In 
advance | Late | Outstanding |
-      | 100.0         | 2.1      | 0.0  | 0.0       | 102.1 | 17.01 | 0.0      
  | 0.0  | 85.09       |
+      | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
+      | 100.0         | 2.08     | 0.0  | 0.0       | 102.08 | 17.01 | 0.0     
   | 0.0  | 85.07       |
     And 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    |
@@ -8473,14 +8473,14 @@ Then Loan Repayment schedule has 4 periods, with the 
following data for periods:
       | 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       |
+      | 5  | 30   | 01 May 2024       |                  | 55.74           | 
14.1          | 0.11     | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 6  | 31   | 01 June 2024      |                  | 41.53           | 
14.21         | 0.0      | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 7  | 30   | 01 July 2024      |                  | 27.32           | 
14.21         | 0.0      | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 8  | 31   | 01 August 2024    |                  | 13.22           | 
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.22         | 0.08     | 0.0  | 0.0       | 13.3  | 0.0   | 0.0        | 0.0  
| 13.3        |
     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       |
+      | 100.0         | 1.36     | 0.0  | 0.0       | 101.36 | 17.01 | 0.0     
   | 0.0  | 84.35       |
     And 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    |
@@ -8643,14 +8643,14 @@ Then Loan Repayment schedule has 4 periods, with the 
following data for periods:
       | 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       |
+      | 5  | 30   | 01 May 2024       |                  | 55.74           | 
14.1          | 0.11     | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 6  | 31   | 01 June 2024      |                  | 41.53           | 
14.21         | 0.0      | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 7  | 30   | 01 July 2024      |                  | 27.32           | 
14.21         | 0.0      | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 8  | 31   | 01 August 2024    |                  | 13.22           | 
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.22         | 0.08     | 0.0  | 0.0       | 13.3  | 0.0   | 0.0        | 0.0  
| 13.3        |
     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       |
+      | 100.0         | 1.36     | 0.0  | 0.0       | 101.36 | 17.01 | 0.0     
   | 0.0  | 84.35       |
     And 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    |
@@ -8825,14 +8825,14 @@ Then Loan Repayment schedule has 4 periods, with the 
following data for periods:
       | 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       |
+      | 5  | 30   | 01 May 2024       |                  | 55.74           | 
14.1          | 0.11     | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 6  | 31   | 01 June 2024      |                  | 41.53           | 
14.21         | 0.0      | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 7  | 30   | 01 July 2024      |                  | 27.32           | 
14.21         | 0.0      | 0.0  | 0.0       | 14.21 | 0.0   | 0.0        | 0.0  
| 14.21       |
+      | 8  | 31   | 01 August 2024    |                  | 13.22           | 
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.22         | 0.08     | 0.0  | 0.0       | 13.3  | 0.0   | 0.0        | 0.0  
| 13.3        |
     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       |
+      | 100.0         | 1.36     | 0.0  | 0.0       | 101.36 | 17.01 | 0.0     
   | 0.0  | 84.35       |
     And 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    |
@@ -9564,19 +9564,22 @@ Then Loan Repayment schedule has 4 periods, with the 
following data for periods:
       | 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     |                  | 70.33           | 
13.24         | 1.18     | 0.0  | 0.0       | 14.42 | 0.0   | 0.0        | 0.0  
| 14.42       |
-      | 5  | 30   | 01 May 2024       |                  | 56.56           | 
13.77         | 0.7      | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
-      | 6  | 31   | 01 June 2024      |                  | 42.66           | 
13.9          | 0.57     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
-      | 7  | 30   | 01 July 2024      |                  | 28.62           | 
14.04         | 0.43     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
-      | 8  | 31   | 01 August 2024    |                  | 14.44           | 
14.18         | 0.29     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
-      | 9  | 31   | 01 September 2024 |                  | 0.0             | 
14.44         | 0.14     | 0.0  | 0.0       | 14.58 | 0.0   | 0.0        | 0.0  
| 14.58       |
+      | 5  | 30   | 01 May 2024       |                  | 56.45           | 
13.88         | 0.59     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
+      | 6  | 31   | 01 June 2024      |                  | 42.54           | 
13.91         | 0.56     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
+      | 7  | 30   | 01 July 2024      |                  | 28.5            | 
14.04         | 0.43     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
+      | 8  | 31   | 01 August 2024    |                  | 14.31           | 
14.19         | 0.28     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
+      | 9  | 31   | 01 September 2024 |                  | 0.0             | 
14.31         | 0.14     | 0.0  | 0.0       | 14.45 | 0.0   | 0.0        | 0.0  
| 14.45       |
     And Loan Repayment schedule has the following data in Total row:
       | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
-      | 100.0         | 3.89     | 0.0  | 0.0       | 103.89 | 17.01 | 0.0     
   | 0.0  | 86.88       |
+      | 100.0         | 3.76     | 0.0  | 0.0       | 103.76 | 17.01 | 0.0     
   | 0.0  | 86.75       |
     And 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    |
       | 01 February 2024 | Repayment        | 17.01  | 16.43     | 0.58     | 
0.0  | 0.0       | 83.57        | false    | false    |
       | 15 March 2024    | Re-age           | 84.37  | 83.57     | 0.8      | 
0.0  | 0.0       | 0.0          | false    | false    |
+# --- close the loan --- #
+    When Loan Pay-off is made on "02 April 2024"
+    Then Loan is closed with zero outstanding balance and it's all 
installments have obligations met
 
   @TestRailId:C4295
   Scenario: Verify Re-aging with loan reschedule: UC4: Interest handling: 
DEFAULT, reschedule, N+1 installment
diff --git 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanReAgingAccruals.feature
 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanReAgingAccruals.feature
index 1e4cdc56c0..3093912e4b 100644
--- 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanReAgingAccruals.feature
+++ 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanReAgingAccruals.feature
@@ -3286,14 +3286,14 @@ Feature: LoanReAgingAccruals
       | 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     |                  | 70.33           | 
13.24         | 1.18     | 0.0  | 0.0       | 14.42 | 0.0   | 0.0        | 0.0  
| 14.42       |
-      | 5  | 30   | 01 May 2024       |                  | 56.56           | 
13.77         | 0.7      | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
-      | 6  | 31   | 01 June 2024      |                  | 42.66           | 
13.9          | 0.57     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
-      | 7  | 30   | 01 July 2024      |                  | 28.62           | 
14.04         | 0.43     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
-      | 8  | 31   | 01 August 2024    |                  | 14.44           | 
14.18         | 0.29     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
-      | 9  | 31   | 01 September 2024 |                  | 0.0             | 
14.44         | 0.14     | 0.0  | 0.0       | 14.58 | 0.0   | 0.0        | 0.0  
| 14.58       |
+      | 5  | 30   | 01 May 2024       |                  | 56.45           | 
13.88         | 0.59     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
+      | 6  | 31   | 01 June 2024      |                  | 42.54           | 
13.91         | 0.56     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
+      | 7  | 30   | 01 July 2024      |                  | 28.5            | 
14.04         | 0.43     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
+      | 8  | 31   | 01 August 2024    |                  | 14.31           | 
14.19         | 0.28     | 0.0  | 0.0       | 14.47 | 0.0   | 0.0        | 0.0  
| 14.47       |
+      | 9  | 31   | 01 September 2024 |                  | 0.0             | 
14.31         | 0.14     | 0.0  | 0.0       | 14.45 | 0.0   | 0.0        | 0.0  
| 14.45       |
     And Loan Repayment schedule has the following data in Total row:
       | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
-      | 100.0         | 3.89     | 0.0  | 0.0       | 103.89 | 17.01 | 0.0     
   | 0.0  | 86.88       |
+      | 100.0         | 3.76     | 0.0  | 0.0       | 103.76 | 17.01 | 0.0     
   | 0.0  | 86.75       |
     And Loan Transactions tab has the following data without accruals:
       | 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    |
@@ -3324,8 +3324,7 @@ Feature: LoanReAgingAccruals
 
 #   --- Close loan ---
   #  When Loan Pay-off is made on "02 April 2024"
-    When Admin sets the business date to "01 May 2024"
-    And Customer makes "AUTOPAY" repayment on "01 May 2024" with 85.45 EUR 
transaction amount
+    When Loan Pay-off is made on "02 April 2024"
     Then Loan is closed with zero outstanding balance and it's all 
installments have obligations met
 
   @TestRailId:4436 @AdvancedPaymentAllocation
diff --git 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanReAgingEqualAmortization.feature
 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanReAgingEqualAmortization.feature
index ae4bb8cf9f..ad108b1401 100644
--- 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanReAgingEqualAmortization.feature
+++ 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanReAgingEqualAmortization.feature
@@ -9347,13 +9347,13 @@ Feature: LoanReAgingEqualAmortization
       |    |      | 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    |                  | 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.47           | 
16.58         | 0.49     | 0.0  | 0.0       | 17.07 | 0.0   | 0.0        | 0.0  
| 17.07       |
-      | 4  | 30   | 01 May 2024      |                  | 33.82           | 
16.65         | 0.42     | 0.0  | 0.0       | 17.07 | 0.0   | 0.0        | 0.0  
| 17.07       |
-      | 5  | 31   | 01 June 2024     |                  | 17.03           | 
16.79         | 0.28     | 0.0  | 0.0       | 17.07 | 0.0   | 0.0        | 0.0  
| 17.07       |
-      | 6  | 30   | 01 July 2024     |                  | 0.0             | 
17.03         | 0.14     | 0.0  | 0.0       | 17.17 | 0.0   | 0.0        | 0.0  
| 17.17       |
+      | 3  | 31   | 01 April 2024    |                  | 50.42           | 
16.63         | 0.44     | 0.0  | 0.0       | 17.07 | 0.0   | 0.0        | 0.0  
| 17.07       |
+      | 4  | 30   | 01 May 2024      |                  | 33.77           | 
16.65         | 0.42     | 0.0  | 0.0       | 17.07 | 0.0   | 0.0        | 0.0  
| 17.07       |
+      | 5  | 31   | 01 June 2024     |                  | 16.98           | 
16.79         | 0.28     | 0.0  | 0.0       | 17.07 | 0.0   | 0.0        | 0.0  
| 17.07       |
+      | 6  | 30   | 01 July 2024     |                  | 0.0             | 
16.98         | 0.14     | 0.0  | 0.0       | 17.12 | 0.0   | 0.0        | 0.0  
| 17.12       |
     And Loan Repayment schedule has the following data in Total row:
       | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
-      | 100.0         | 2.4      | 0.0  | 0.0       | 102.4  | 17.01 | 0.0     
   | 0.0  | 85.39       |
+      | 100.0         | 2.35     | 0.0  | 0.0       | 102.35 | 17.01 | 0.0     
   | 0.0  | 85.34       |
     And 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    |
diff --git 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanReAmortization.feature
 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanReAmortization.feature
index 4c487746b2..26d3ad54e3 100644
--- 
a/fineract-e2e-tests-runner/src/test/resources/features/LoanReAmortization.feature
+++ 
b/fineract-e2e-tests-runner/src/test/resources/features/LoanReAmortization.feature
@@ -4878,7 +4878,6 @@ Feature: LoanReAmortization
     When Loan Pay-off is made on "01 May 2024"
     Then Loan is closed with zero outstanding balance and it's all 
installments have obligations met
 
-  @Skip
   @TestRailId:C4508
   Scenario: Verify Re-amortization with reschedulereschedule with 
adjustedDueDate with last installment strategy - interest bearing loan with 
equal amortization + interest split - UC4.3
     When Admin sets the business date to "01 January 2024"
@@ -4968,8 +4967,26 @@ Feature: LoanReAmortization
     When Admin sets the business date to "01 May 2024"
     When Loan Pay-off is made on "01 May 2024"
     Then Loan is closed with zero outstanding balance and it's all 
installments have obligations met
+    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  | 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  | 45   | 15 April 2024     | 01 May 2024      | 63.08           | 
20.49         | 0.83     | 0.0  | 0.0       | 21.32 | 21.32 | 0.0        | 
21.32 | 0.0         |
+      | 4  | 30   | 15 May 2024       | 01 May 2024      | 42.4            | 
20.68         | 0.38     | 0.0  | 0.0       | 21.06 | 21.06 | 21.06      | 0.0  
 | 0.0         |
+      | 5  | 31   | 15 June 2024      | 01 May 2024      | 21.2            | 
21.2          | 0.12     | 0.0  | 0.0       | 21.32 | 21.32 | 21.32      | 0.0  
 | 0.0         |
+      | 6  | 30   | 15 July 2024      | 01 May 2024      |  0.0            | 
21.2          | 0.12     | 0.0  | 0.0       | 21.32 | 21.32 | 21.32      | 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.03     | 0.0  | 0.0       | 102.03 | 102.03 | 63.7   
    | 21.32 | 0.0         |
+    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    |
+      | 01 February 2024 | Repayment        | 17.01  | 16.43     | 0.58     | 
0.0  | 0.0       | 83.57        | false    | false    |
+      | 15 March 2024    | Re-amortize      | 17.01  | 16.52     | 0.49     | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 01 May 2024      | Repayment        | 85.02  | 83.57     | 1.45     | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 01 May 2024      | Accrual          | 2.03   | 0.0       | 2.03     | 
0.0  | 0.0       | 0.0          | false    | false    |
 
-  @Skip
   @TestRailId:C4509
   Scenario: Verify Re-amortization with loan reschedule with newInterestRate - 
interest bearing loan with equal amortization + interest split - UC4.4
     When Admin sets the business date to "01 January 2024"
@@ -5083,12 +5100,12 @@ Feature: LoanReAmortization
       | 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  | 31   | 01 April 2024     |                  | 62.94           | 
20.63         | 0.82     | 0.0  | 0.0       | 21.45 | 0.0   | 0.0        | 0.0  
| 21.45       |
-      | 4  | 30   | 01 May 2024       |                  | 42.26           | 
20.68         | 0.81     | 0.0  | 0.0       | 21.49 | 0.0   | 0.0        | 0.0  
| 21.49       |
-      | 5  | 31   | 01 June 2024      |                  | 21.31           | 
20.95         | 0.54     | 0.0  | 0.0       | 21.49 | 0.0   | 0.0        | 0.0  
| 21.49       |
-      | 6  | 30   | 01 July 2024      |                  |  0.0            | 
21.31         | 0.33     | 0.0  | 0.0       | 21.64 | 0.0   | 0.0        | 0.0  
| 21.64       |
+      | 4  | 30   | 01 May 2024       |                  | 42.1            | 
20.84         | 0.65     | 0.0  | 0.0       | 21.49 | 0.0   | 0.0        | 0.0  
| 21.49       |
+      | 5  | 31   | 01 June 2024      |                  | 21.15           | 
20.95         | 0.54     | 0.0  | 0.0       | 21.49 | 0.0   | 0.0        | 0.0  
| 21.49       |
+      | 6  | 30   | 01 July 2024      |                  |  0.0            | 
21.15         | 0.33     | 0.0  | 0.0       | 21.48 | 0.0   | 0.0        | 0.0  
| 21.48       |
     Then Loan Repayment schedule has the following data in Total row:
       | Principal due | Interest | Fees | Penalties | Due    | Paid  | In 
advance | Late | Outstanding |
-      | 100.0         | 3.08     | 0.0  | 0.0       | 103.08 | 17.01 | 0.0     
   | 0.0  | 86.07      |
+      | 100.0         | 2.92     | 0.0  | 0.0       | 102.92 | 17.01 | 0.0     
   | 0.0  | 85.91       |
     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    |
@@ -5097,6 +5114,28 @@ Feature: LoanReAmortization
 # --- close the loan --- #
     When Loan Pay-off is made on "02 April 2024"
     Then Loan is closed with zero outstanding balance and it's all 
installments have obligations met
+    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  | 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  | 31   | 01 April 2024     | 02 April 2024    | 62.94           | 
20.63         | 0.82     | 0.0  | 0.0       | 21.45 | 21.45 | 0.0        | 
21.45 | 0.0         |
+      | 4  | 30   | 01 May 2024       | 02 April 2024    | 41.59           | 
21.35         | 0.14     | 0.0  | 0.0       | 21.49 | 21.49 | 21.49      | 0.0  
 | 0.0         |
+      | 5  | 31   | 01 June 2024      | 02 April 2024    | 20.22           | 
21.37         | 0.12     | 0.0  | 0.0       | 21.49 | 21.49 | 21.49      | 0.0  
 | 0.0         |
+      | 6  | 30   | 01 July 2024      | 02 April 2024    |  0.0            | 
20.22         | 0.12     | 0.0  | 0.0       | 20.34 | 20.34 | 20.34      | 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.78     | 0.0  | 0.0       | 101.78 | 101.78 | 63.32  
    | 21.45 | 0.0         |
+    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    |
+      | 01 February 2024 | Repayment        | 17.01  | 16.43     | 0.58     | 
0.0  | 0.0       | 83.57        | false    | false    |
+      | 01 February 2024 | Accrual Activity | 0.58   | 0.0       | 0.58     | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 15 March 2024    | Re-amortize      | 17.09  | 16.6      | 0.49     | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 01 April 2024    | Accrual Activity | 0.82   | 0.0       | 0.82     | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 02 April 2024    | Repayment        | 84.77  | 83.57     | 1.2      | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 02 April 2024    | Accrual          | 1.78   | 0.0       | 1.78     | 
0.0  | 0.0       | 0.0          | false    | false    |
+      | 02 April 2024    | Accrual Activity | 0.38   | 0.0       | 0.38     | 
0.0  | 0.0       | 0.0          | false    | false    |
 
   @TestRailId:C4510 @AdvancedPaymentAllocation
   Scenario: Verify re-amortization on same day as disbursement is rejected 
when no overdue exists - interest bearing loan with default interest handling - 
UC5.1
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 98c6ee0b70..cbcf713f36 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
@@ -1104,7 +1104,12 @@ public final class ProgressiveEMICalculator implements 
EMICalculator {
             Money diff = totalDisbursedAmount.plus(totalCapitalizedIncome, 
mc).plus(scheduleModel.getTotalCreditedPrincipal(), mc)
                     .plus(totalDueInterest, mc).minus(totalEMI, mc);
 
-            repaymentPeriod.setEmi(repaymentPeriod.getEmi().add(diff, mc));
+            Money adjustedEmi = repaymentPeriod.getEmi().add(diff, mc);
+            if (repaymentPeriod.getFixedInterest().isGreaterThanZero()
+                    && 
adjustedEmi.isLessThan(repaymentPeriod.getPaidPrincipal().add(repaymentPeriod.getFixedInterest())))
 {
+                adjustedEmi = 
repaymentPeriod.getPaidPrincipal().add(repaymentPeriod.getFixedInterest());
+            }
+            repaymentPeriod.setEmi(adjustedEmi);
             if (repaymentPeriod.getEmi()
                     
.isLessThan(repaymentPeriod.getTotalPaidAmount().minus(repaymentPeriod.getTotalCreditedAmount(),
 mc))) {
                 
repaymentPeriod.setEmi(repaymentPeriod.getTotalPaidAmount().minus(repaymentPeriod.getTotalCreditedAmount(),
 mc));
diff --git 
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/ProgressiveLoanInterestScheduleModel.java
 
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/ProgressiveLoanInterestScheduleModel.java
index 0af304fc0e..5b0863c1d5 100644
--- 
a/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/ProgressiveLoanInterestScheduleModel.java
+++ 
b/fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanproduct/calc/data/ProgressiveLoanInterestScheduleModel.java
@@ -248,7 +248,9 @@ public class ProgressiveLoanInterestScheduleModel {
         previousInterestPeriod.addBalanceCorrectionAmount(correctionAmount);
 
         final InterestPeriod interestPeriod = 
InterestPeriod.withEmptyAmounts(repaymentPeriod, newDueDate, originalDueDate, 
isPaused);
-        repaymentPeriod.getInterestPeriods().add(interestPeriod);
+        final List<InterestPeriod> interestPeriods = 
repaymentPeriod.getInterestPeriods();
+        final int previousIndex = 
interestPeriods.indexOf(previousInterestPeriod);
+        interestPeriods.add(previousIndex + 1, interestPeriod);
     }
 
     private void insertInterestPausePeriods(final RepaymentPeriod 
repaymentPeriod, final LocalDate pauseStart, final LocalDate pauseEnd) {
@@ -287,13 +289,8 @@ public class ProgressiveLoanInterestScheduleModel {
     }
 
     private InterestPeriod findPreviousInterestPeriod(final RepaymentPeriod 
repaymentPeriod, final LocalDate date) {
-        if (date.isAfter(repaymentPeriod.getFromDate())) {
-            return repaymentPeriod.getLastInterestPeriod();
-        } else {
-            return repaymentPeriod.getInterestPeriods().stream()
-                    .filter(ip -> date.isAfter(ip.getFromDate()) && 
!date.isAfter(ip.getDueDate())).reduce((first, second) -> second)
-                    .orElse(repaymentPeriod.getInterestPeriods().getFirst());
-        }
+        return repaymentPeriod.getInterestPeriods().stream().filter(ip -> 
date.isAfter(ip.getFromDate()) && !date.isAfter(ip.getDueDate()))
+                .reduce((first, second) -> 
second).orElse(repaymentPeriod.getInterestPeriods().getFirst());
     }
 
     /**


Reply via email to