You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2022/11/15 16:06:05 UTC

[GitHub] [fineract] ruchiD opened a new pull request, #2745: FINERACT-1734-Repayment-due-event

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

   ## Description
   Refactored for api change for retrieving repayment installments.
   
   Describe the changes made and why they were made.
   
   Ignore if these details are present on the associated [Apache Fineract JIRA ticket](https://github.com/apache/fineract/pull/1284).
   
   
   ## 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


[GitHub] [fineract] galovics commented on a diff in pull request #2745: FINERACT-1734-Repayment-due-event

Posted by GitBox <gi...@apache.org>.
galovics commented on code in PR #2745:
URL: https://github.com/apache/fineract/pull/2745#discussion_r1024893901


##########
fineract-provider/src/main/java/org/apache/fineract/cob/loan/CheckLoanRepaymentOverdueBusinessStep.java:
##########
@@ -19,33 +19,30 @@
 package org.apache.fineract.cob.loan;
 
 import java.time.LocalDate;
-import java.util.Collection;
+import java.util.List;
 import lombok.RequiredArgsConstructor;
 import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
 import org.apache.fineract.infrastructure.core.service.DateUtils;
 import org.apache.fineract.infrastructure.event.business.domain.loan.LoanRepaymentOverdueBusinessEvent;
 import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
 import org.apache.fineract.portfolio.loanaccount.domain.Loan;
-import org.apache.fineract.portfolio.loanaccount.loanschedule.data.OverdueLoanScheduleData;
-import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService;
+import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
 import org.springframework.stereotype.Component;
 
 @Component
 @RequiredArgsConstructor
 public class CheckLoanRepaymentOverdueBusinessStep implements LoanCOBBusinessStep {
 
-    private final LoanReadPlatformService loanReadPlatformService;
     private final ConfigurationDomainService configurationDomainService;
     private final BusinessEventNotifierService businessEventNotifierService;
 
     @Override
     public Loan execute(Loan loan) {
         Long numberOfDaysAfterDueDateToRaiseEvent = configurationDomainService.retrieveRepaymentOverdueDays();
         final LocalDate currentDate = DateUtils.getBusinessLocalDate();
-        final Collection<OverdueLoanScheduleData> overdueInstallmentsForLoan = loanReadPlatformService
-                .retrieveAllOverdueInstallmentsForLoan(loan);
-        for (OverdueLoanScheduleData overdueInstallment : overdueInstallmentsForLoan) {
-            LocalDate installmentDueDate = LocalDate.parse(overdueInstallment.getDueDate());
+        final List<LoanRepaymentScheduleInstallment> loanRepaymentScheduleInstallments = loan.getRepaymentScheduleInstallments();

Review Comment:
   If it was only about the grace period, wouldn't it make sense to create a separate method over there that skips the grace period handling yet follows the same logic of the existing method?
   So we'd have a `retrieveAllOverdueInstallmentsForLoan` and a `retrieveAllOverdueInstallmentsForLoanWithoutGracePeriod` method (obviously the naming can change).
   
   I'd say this is quite a generic functionality that we might reuse at other places and it would be a shame to reimplement this logic everywhere.



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


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2745: FINERACT-1734-Repayment-due-event

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2745:
URL: https://github.com/apache/fineract/pull/2745#discussion_r1023788446


##########
fineract-provider/src/main/java/org/apache/fineract/cob/loan/CheckLoanRepaymentOverdueBusinessStep.java:
##########
@@ -19,33 +19,30 @@
 package org.apache.fineract.cob.loan;
 
 import java.time.LocalDate;
-import java.util.Collection;
+import java.util.List;
 import lombok.RequiredArgsConstructor;
 import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
 import org.apache.fineract.infrastructure.core.service.DateUtils;
 import org.apache.fineract.infrastructure.event.business.domain.loan.LoanRepaymentOverdueBusinessEvent;
 import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
 import org.apache.fineract.portfolio.loanaccount.domain.Loan;
-import org.apache.fineract.portfolio.loanaccount.loanschedule.data.OverdueLoanScheduleData;
-import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService;
+import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
 import org.springframework.stereotype.Component;
 
 @Component
 @RequiredArgsConstructor
 public class CheckLoanRepaymentOverdueBusinessStep implements LoanCOBBusinessStep {
 
-    private final LoanReadPlatformService loanReadPlatformService;
     private final ConfigurationDomainService configurationDomainService;
     private final BusinessEventNotifierService businessEventNotifierService;
 
     @Override
     public Loan execute(Loan loan) {
         Long numberOfDaysAfterDueDateToRaiseEvent = configurationDomainService.retrieveRepaymentOverdueDays();
         final LocalDate currentDate = DateUtils.getBusinessLocalDate();
-        final Collection<OverdueLoanScheduleData> overdueInstallmentsForLoan = loanReadPlatformService
-                .retrieveAllOverdueInstallmentsForLoan(loan);
-        for (OverdueLoanScheduleData overdueInstallment : overdueInstallmentsForLoan) {
-            LocalDate installmentDueDate = LocalDate.parse(overdueInstallment.getDueDate());
+        final List<LoanRepaymentScheduleInstallment> loanRepaymentScheduleInstallments = loan.getRepaymentScheduleInstallments();
+        for (LoanRepaymentScheduleInstallment repaymentSchedule : loanRepaymentScheduleInstallments) {
+            LocalDate installmentDueDate = repaymentSchedule.getDueDate();

Review Comment:
   This logic is not sufficient. It will trigger the overdue business event for already closed (obligations met) installments as well.



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


[GitHub] [fineract] galovics merged pull request #2745: FINERACT-1734-Repayment-due-event

Posted by GitBox <gi...@apache.org>.
galovics merged PR #2745:
URL: https://github.com/apache/fineract/pull/2745


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


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2745: FINERACT-1734-Repayment-due-event

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2745:
URL: https://github.com/apache/fineract/pull/2745#discussion_r1023786435


##########
fineract-provider/src/main/java/org/apache/fineract/cob/loan/CheckLoanRepaymentOverdueBusinessStep.java:
##########
@@ -19,33 +19,30 @@
 package org.apache.fineract.cob.loan;
 
 import java.time.LocalDate;
-import java.util.Collection;
+import java.util.List;
 import lombok.RequiredArgsConstructor;
 import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
 import org.apache.fineract.infrastructure.core.service.DateUtils;
 import org.apache.fineract.infrastructure.event.business.domain.loan.LoanRepaymentOverdueBusinessEvent;
 import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
 import org.apache.fineract.portfolio.loanaccount.domain.Loan;
-import org.apache.fineract.portfolio.loanaccount.loanschedule.data.OverdueLoanScheduleData;
-import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService;
+import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
 import org.springframework.stereotype.Component;
 
 @Component
 @RequiredArgsConstructor
 public class CheckLoanRepaymentOverdueBusinessStep implements LoanCOBBusinessStep {
 
-    private final LoanReadPlatformService loanReadPlatformService;
     private final ConfigurationDomainService configurationDomainService;
     private final BusinessEventNotifierService businessEventNotifierService;
 
     @Override
     public Loan execute(Loan loan) {
         Long numberOfDaysAfterDueDateToRaiseEvent = configurationDomainService.retrieveRepaymentOverdueDays();
         final LocalDate currentDate = DateUtils.getBusinessLocalDate();
-        final Collection<OverdueLoanScheduleData> overdueInstallmentsForLoan = loanReadPlatformService
-                .retrieveAllOverdueInstallmentsForLoan(loan);
-        for (OverdueLoanScheduleData overdueInstallment : overdueInstallmentsForLoan) {
-            LocalDate installmentDueDate = LocalDate.parse(overdueInstallment.getDueDate());
+        final List<LoanRepaymentScheduleInstallment> loanRepaymentScheduleInstallments = loan.getRepaymentScheduleInstallments();

Review Comment:
   Can you help me to understand why the retrieveAllOverdueInstallmentsForLoan() was not sufficient? (i guess it was used to handle the grace period as well)



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


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2745: FINERACT-1734-Repayment-due-event

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2745:
URL: https://github.com/apache/fineract/pull/2745#discussion_r1023792846


##########
fineract-provider/src/test/java/org/apache/fineract/cob/loan/CheckLoanRepaymentOverdueBusinessStepTest.java:
##########
@@ -95,11 +94,12 @@ public void givenLoanWithNoInstallmentOverdueAfterConfiguredDaysWhenStepExecutio
         // given
         when(configurationDomainService.retrieveRepaymentOverdueDays()).thenReturn(1L);
         LocalDate loanInstallmentRepaymentDueDateBefore5Days = DateUtils.getBusinessLocalDate().minusDays(5);
-        Collection<OverdueLoanScheduleData> overdueInstallmentsForLoan = Arrays
-                .asList(new OverdueLoanScheduleData(1L, 1L, loanInstallmentRepaymentDueDateBefore5Days.toString(), BigDecimal.valueOf(0.0),
-                        "", "", BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0), 1));
-        when(loanReadPlatformService.retrieveAllOverdueInstallmentsForLoan(any())).thenReturn(overdueInstallmentsForLoan);
         Loan loanForProcessing = Mockito.mock(Loan.class);
+        List<LoanRepaymentScheduleInstallment> loanRepaymentScheduleInstallments = Arrays
+                .asList(new LoanRepaymentScheduleInstallment(loanForProcessing, 1, LocalDate.now(ZoneId.systemDefault()),
+                        loanInstallmentRepaymentDueDateBefore5Days, BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0),
+                        BigDecimal.valueOf(0.0), BigDecimal.valueOf(0.0), false, new HashSet<>(), BigDecimal.valueOf(0.0)));

Review Comment:
   Would you please extend your test suite with the following:
   numberOfDaysAfterDueDateToRaiseEvent = 1
   There are 2 installments
   - First is fully paid
   - Second is not fully paid
   
   Run the job on the first installment due date. Outcome should be nothing. (no event raised)
   Run the job on the first installment due date + 1. Outcome should be nothing. (no event raised) 
   Run the job on the first installment due date + 2. Outcome should be nothing (no event raised)
   
   Run the job on the second installment due date. Outcome should be nothing. (no event raised)
   Run the job on the second installment due date + 1. Outcome: event raised! 
   Run the job on the second installment due date + 2. Outcome should be nothing (no event raised)



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


[GitHub] [fineract] adamsaghy commented on a diff in pull request #2745: FINERACT-1734-Repayment-due-event

Posted by GitBox <gi...@apache.org>.
adamsaghy commented on code in PR #2745:
URL: https://github.com/apache/fineract/pull/2745#discussion_r1023786435


##########
fineract-provider/src/main/java/org/apache/fineract/cob/loan/CheckLoanRepaymentOverdueBusinessStep.java:
##########
@@ -19,33 +19,30 @@
 package org.apache.fineract.cob.loan;
 
 import java.time.LocalDate;
-import java.util.Collection;
+import java.util.List;
 import lombok.RequiredArgsConstructor;
 import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
 import org.apache.fineract.infrastructure.core.service.DateUtils;
 import org.apache.fineract.infrastructure.event.business.domain.loan.LoanRepaymentOverdueBusinessEvent;
 import org.apache.fineract.infrastructure.event.business.service.BusinessEventNotifierService;
 import org.apache.fineract.portfolio.loanaccount.domain.Loan;
-import org.apache.fineract.portfolio.loanaccount.loanschedule.data.OverdueLoanScheduleData;
-import org.apache.fineract.portfolio.loanaccount.service.LoanReadPlatformService;
+import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
 import org.springframework.stereotype.Component;
 
 @Component
 @RequiredArgsConstructor
 public class CheckLoanRepaymentOverdueBusinessStep implements LoanCOBBusinessStep {
 
-    private final LoanReadPlatformService loanReadPlatformService;
     private final ConfigurationDomainService configurationDomainService;
     private final BusinessEventNotifierService businessEventNotifierService;
 
     @Override
     public Loan execute(Loan loan) {
         Long numberOfDaysAfterDueDateToRaiseEvent = configurationDomainService.retrieveRepaymentOverdueDays();
         final LocalDate currentDate = DateUtils.getBusinessLocalDate();
-        final Collection<OverdueLoanScheduleData> overdueInstallmentsForLoan = loanReadPlatformService
-                .retrieveAllOverdueInstallmentsForLoan(loan);
-        for (OverdueLoanScheduleData overdueInstallment : overdueInstallmentsForLoan) {
-            LocalDate installmentDueDate = LocalDate.parse(overdueInstallment.getDueDate());
+        final List<LoanRepaymentScheduleInstallment> loanRepaymentScheduleInstallments = loan.getRepaymentScheduleInstallments();

Review Comment:
   Can you help me to understand why the retrieveAllOverdueInstallmentsForLoan() was not sufficient? (i guess it was using to handle the grace period as well)



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