You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "budaidev (via GitHub)" <gi...@apache.org> on 2026/01/11 23:53:40 UTC

[PR] FINERACT-2354: fix error while do re-amortization on disbursement day [fineract]

budaidev opened a new pull request, #5314:
URL: https://github.com/apache/fineract/pull/5314

   ## Description
   
   Describe the changes made and why they were made. (Ignore if these details are present on the associated Apache Fineract JIRA ticket.)
   
   ## Checklist
   
   Please make sure these boxes are checked before submitting your pull request - thanks!
   
   - [ ] Write the commit message as per [our guidelines](https://github.com/apache/fineract/blob/develop/CONTRIBUTING.md#pull-requests)
   - [ ] Acknowledge that we will not review PRs that are not passing the build _("green")_ - it is your responsibility to get a proposed PR to pass the build, not primarily the project's maintainers.
   - [ ] Create/update [unit or integration tests](https://fineract.apache.org/docs/current/#_testing) for verifying the changes made.
   - [ ] Follow our [coding conventions](https://cwiki.apache.org/confluence/display/FINERACT/Coding+Conventions).
   - [ ] Add required Swagger annotation and update API documentation at fineract-provider/src/main/resources/static/legacy-docs/apiLive.htm with details of any API changes
   - [ ] [This PR must not be a "code dump"](https://cwiki.apache.org/confluence/display/FINERACT/Pull+Request+Size+Limit). Large changes can be made in a branch, with assistance. Ask for help on the [developer mailing list](https://fineract.apache.org/#contribute).
   
   Your assigned reviewer(s) will follow our [guidelines for code reviews](https://cwiki.apache.org/confluence/display/FINERACT/Code+Review+Guide).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2354: fix error while do re-amortization on disbursement day [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5314:
URL: https://github.com/apache/fineract/pull/5314#discussion_r2682941771


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -626,6 +626,19 @@ private void handleReamortizationWithEqualAmortizationInterestSplitHandlingType(
 
             Money totalOverDuePrincipal = Money.zero(currency);
             Money totalOverDueFee = Money.zero(currency);
+            Money totalOverDueInterest = Money.zero(currency);
+
+            if (previousInstallments.isEmpty()) {
+                loanTransaction.resetDerivedComponents();
+                loanTransaction.updateComponentsAndTotal(totalOverDuePrincipal, totalOverDueInterest, Money.zero(currency),
+                        Money.zero(currency));
+                if (loanTransaction.isNotReversed()) {
+                    loanTransaction.reverse();
+                    loanTransaction.manuallyAdjustedOrReversed();
+                }
+                return;
+            }
+

Review Comment:
   @budaidev I see. Thanks, then just extract the common logic and reuse it! ;)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2354: fix error while do re-amortization on disbursement day [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5314:
URL: https://github.com/apache/fineract/pull/5314#discussion_r2682951503


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -626,6 +626,19 @@ private void handleReamortizationWithEqualAmortizationInterestSplitHandlingType(
 
             Money totalOverDuePrincipal = Money.zero(currency);
             Money totalOverDueFee = Money.zero(currency);
+            Money totalOverDueInterest = Money.zero(currency);
+
+            if (previousInstallments.isEmpty()) {
+                loanTransaction.resetDerivedComponents();
+                loanTransaction.updateComponentsAndTotal(totalOverDuePrincipal, totalOverDueInterest, Money.zero(currency),
+                        Money.zero(currency));
+                if (loanTransaction.isNotReversed()) {
+                    loanTransaction.reverse();
+                    loanTransaction.manuallyAdjustedOrReversed();
+                }
+                return;
+            }
+

Review Comment:
   However, there is 1 thought... if there is no any reamortizable amount, maybe we should just throw a domain rule exception and explain, Reamortization cannot be executed, hence no overdue amount.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2354: fix error while do re-amortization on disbursement day [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #5314:
URL: https://github.com/apache/fineract/pull/5314#discussion_r2682274268


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -626,6 +626,19 @@ private void handleReamortizationWithEqualAmortizationInterestSplitHandlingType(
 
             Money totalOverDuePrincipal = Money.zero(currency);
             Money totalOverDueFee = Money.zero(currency);
+            Money totalOverDueInterest = Money.zero(currency);
+
+            if (previousInstallments.isEmpty()) {
+                loanTransaction.resetDerivedComponents();
+                loanTransaction.updateComponentsAndTotal(totalOverDuePrincipal, totalOverDueInterest, Money.zero(currency),
+                        Money.zero(currency));
+                if (loanTransaction.isNotReversed()) {
+                    loanTransaction.reverse();
+                    loanTransaction.manuallyAdjustedOrReversed();
+                }
+                return;
+            }
+

Review Comment:
   Can you please help me understand what this logic is for?
   
   Also seems reused multiple times, we might wanna extract this into a method.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2354: fix error while do re-amortization on disbursement day [fineract]

Posted by "budaidev (via GitHub)" <gi...@apache.org>.
budaidev commented on PR #5314:
URL: https://github.com/apache/fineract/pull/5314#issuecomment-3748944864

   @adamsaghy I have made some test changes according the validation we discussed here


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2354: fix error while do re-amortization on disbursement day [fineract]

Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy merged PR #5314:
URL: https://github.com/apache/fineract/pull/5314


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2354: fix error while do re-amortization on disbursement day [fineract]

Posted by "budaidev (via GitHub)" <gi...@apache.org>.
budaidev commented on code in PR #5314:
URL: https://github.com/apache/fineract/pull/5314#discussion_r2682888011


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -626,6 +626,19 @@ private void handleReamortizationWithEqualAmortizationInterestSplitHandlingType(
 
             Money totalOverDuePrincipal = Money.zero(currency);
             Money totalOverDueFee = Money.zero(currency);
+            Money totalOverDueInterest = Money.zero(currency);
+
+            if (previousInstallments.isEmpty()) {
+                loanTransaction.resetDerivedComponents();
+                loanTransaction.updateComponentsAndTotal(totalOverDuePrincipal, totalOverDueInterest, Money.zero(currency),
+                        Money.zero(currency));
+                if (loanTransaction.isNotReversed()) {
+                    loanTransaction.reverse();
+                    loanTransaction.manuallyAdjustedOrReversed();
+                }
+                return;
+            }
+

Review Comment:
   The logic handles an edge case where re-amortization is requested on disbursement day. At this point, previousInstallments (installments with due date ≤ transaction date) is empty because all installments are scheduled in the future.
   
     Without this guard, calling previousInstallments.getLast() throws NoSuchElementException causing a 500 error.
   
     The fix gracefully handles this by:
     1. Setting transaction amounts to zero
     2. Reversing the transaction (since there's nothing to re-amortize)
     3. Returning early
   
     This is consistent with the existing logic that reverses the transaction when both principal and interest are zero



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] FINERACT-2354: fix error while do re-amortization on disbursement day [fineract]

Posted by "budaidev (via GitHub)" <gi...@apache.org>.
budaidev commented on code in PR #5314:
URL: https://github.com/apache/fineract/pull/5314#discussion_r2685957749


##########
fineract-progressive-loan/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/transactionprocessor/impl/AdvancedPaymentScheduleTransactionProcessor.java:
##########
@@ -626,6 +626,19 @@ private void handleReamortizationWithEqualAmortizationInterestSplitHandlingType(
 
             Money totalOverDuePrincipal = Money.zero(currency);
             Money totalOverDueFee = Money.zero(currency);
+            Money totalOverDueInterest = Money.zero(currency);
+
+            if (previousInstallments.isEmpty()) {
+                loanTransaction.resetDerivedComponents();
+                loanTransaction.updateComponentsAndTotal(totalOverDuePrincipal, totalOverDueInterest, Money.zero(currency),
+                        Money.zero(currency));
+                if (loanTransaction.isNotReversed()) {
+                    loanTransaction.reverse();
+                    loanTransaction.manuallyAdjustedOrReversed();
+                }
+                return;
+            }
+

Review Comment:
   I modified it so we should throw an error in these cases



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org