You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by "alberto-art3ch (via GitHub)" <gi...@apache.org> on 2025/05/05 19:33:33 UTC

[PR] FINERACT-2181: Fix Consult Loan repayment schedule with disbursement … [fineract]

alberto-art3ch opened a new pull request, #4643:
URL: https://github.com/apache/fineract/pull/4643

   …charge using interest
   
   ## Description
   
   Fix Consult Loan repayment schedule with disbursement charge using interest
   
   [FINERACT-2181](https://github.com/apache/fineract/pull/FINERACT-2181)
   
   - Loan Application using a Loan disbursement Charge with % Interest
   <img width="1306" alt="Screenshot 2025-05-05 at 1 31 05 p m" src="https://github.com/user-attachments/assets/c134669e-72c3-4289-9664-8ffa8abbbb83" />
   
   - Loan Repayment Schedule: `4% of $36.99 = 1.4796`
   <img width="1305" alt="Screenshot 2025-05-05 at 1 30 56 p m" src="https://github.com/user-attachments/assets/64951d83-70ee-478c-a9bc-f70d166bdd54" />
   
   ## Checklist
   
   Please make sure these boxes are checked before submitting your pull request - thanks!
   
   - [ ] Write the commit message as per https://github.com/apache/fineract/#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 for verifying the changes made.
   - [ ] Follow coding conventions at 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
   - [ ] Submission is not a "code dump".  (Large changes can be made "in repository" via a branch.  Ask on the developer mailing list for guidance, if required.)
   
   FYI our guidelines for code reviews are at 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-2181: Fix Consult Loan repayment schedule with disbursement … [fineract]

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


-- 
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-2181: Fix Consult Loan repayment schedule with disbursement … [fineract]

Posted by "alberto-art3ch (via GitHub)" <gi...@apache.org>.
alberto-art3ch commented on code in PR #4643:
URL: https://github.com/apache/fineract/pull/4643#discussion_r2075916513


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java:
##########
@@ -1542,4 +1552,34 @@ public Pair<Loan, Map<String, Object>> assembleLoanApproval(AppUser currentUser,
         return Pair.of(loan, actualChanges);
     }
 
+    private Set<LoanCharge> separateTotalCompoundingPercentageCharges(final Set<LoanCharge> loanCharges) {
+        Set<LoanCharge> interestCharges = new HashSet<>();
+        if (loanCharges != null) {
+            for (final LoanCharge loanCharge : loanCharges) {
+                if ((loanCharge.isSpecifiedDueDate() || loanCharge.isDisbursementCharge())
+                        && (loanCharge.getChargeCalculation().isPercentageOfInterest()
+                                || loanCharge.getChargeCalculation().isPercentageOfAmountAndInterest())) {
+                    interestCharges.add(loanCharge);
+                }
+            }
+            loanCharges.removeAll(interestCharges);
+        }
+        return interestCharges;
+    }
+
+    private void updateDisbursementWithCharges(final Collection<LoanScheduleModelPeriod> periods,
+            final Set<LoanCharge> nonCompoundingCharges) {
+        final BigDecimal totalInterest = periods.stream().filter(p -> p.isRepaymentPeriod()).map(LoanScheduleModelPeriod::interestDue)
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        for (LoanScheduleModelPeriod loanScheduleModelPeriod : periods) {
+            if (loanScheduleModelPeriod instanceof LoanScheduleModelDisbursementPeriod) {
+                log.info("Period {}", loanScheduleModelPeriod.periodNumber());

Review Comment:
   Done! Code updated



-- 
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-2181: Fix Consult Loan repayment schedule with disbursement … [fineract]

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java:
##########
@@ -1542,4 +1552,34 @@ public Pair<Loan, Map<String, Object>> assembleLoanApproval(AppUser currentUser,
         return Pair.of(loan, actualChanges);
     }
 
+    private Set<LoanCharge> separateTotalCompoundingPercentageCharges(final Set<LoanCharge> loanCharges) {
+        Set<LoanCharge> interestCharges = new HashSet<>();
+        if (loanCharges != null) {
+            for (final LoanCharge loanCharge : loanCharges) {
+                if ((loanCharge.isSpecifiedDueDate() || loanCharge.isDisbursementCharge())
+                        && (loanCharge.getChargeCalculation().isPercentageOfInterest()
+                                || loanCharge.getChargeCalculation().isPercentageOfAmountAndInterest())) {
+                    interestCharges.add(loanCharge);
+                }
+            }
+            loanCharges.removeAll(interestCharges);
+        }
+        return interestCharges;
+    }
+
+    private void updateDisbursementWithCharges(final Collection<LoanScheduleModelPeriod> periods,
+            final Set<LoanCharge> nonCompoundingCharges) {
+        final BigDecimal totalInterest = periods.stream().filter(p -> p.isRepaymentPeriod()).map(LoanScheduleModelPeriod::interestDue)
+                .reduce(BigDecimal.ZERO, BigDecimal::add);
+        for (LoanScheduleModelPeriod loanScheduleModelPeriod : periods) {
+            if (loanScheduleModelPeriod instanceof LoanScheduleModelDisbursementPeriod) {
+                log.info("Period {}", loanScheduleModelPeriod.periodNumber());

Review Comment:
   Way too verbose for sure.



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java:
##########
@@ -1542,4 +1552,34 @@ public Pair<Loan, Map<String, Object>> assembleLoanApproval(AppUser currentUser,
         return Pair.of(loan, actualChanges);
     }
 
+    private Set<LoanCharge> separateTotalCompoundingPercentageCharges(final Set<LoanCharge> loanCharges) {

Review Comment:
   I really don't like the fact that this method does not only return a new set of LoanCharges but it actually has a side-effect as it modifies the parameter loanCharges Set as well.
   
   Can we transform this into a method withOUT any side effects?
   
   Thanks.



-- 
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-2181: Fix Consult Loan repayment schedule with disbursement … [fineract]

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

   > No tests, pls add them.
   
   Done, ITC added


-- 
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-2181: Fix Consult Loan repayment schedule with disbursement … [fineract]

Posted by "alberto-art3ch (via GitHub)" <gi...@apache.org>.
alberto-art3ch commented on code in PR #4643:
URL: https://github.com/apache/fineract/pull/4643#discussion_r2080646759


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java:
##########
@@ -1542,4 +1552,34 @@ public Pair<Loan, Map<String, Object>> assembleLoanApproval(AppUser currentUser,
         return Pair.of(loan, actualChanges);
     }
 
+    private Set<LoanCharge> separateTotalCompoundingPercentageCharges(final Set<LoanCharge> loanCharges) {

Review Comment:
   Done! Code updated



-- 
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