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/09/05 21:35:36 UTC

[GitHub] [fineract] josehernandezfintecheandomx opened a new pull request, #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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

   ## Description
   
   Instead of only supporting the Delinquency Classification as a separate job, we need to make sure that it can be configured as a Business Step as part of the COB. 
   
   There might be use-cases where in a Loan COB, another business step wants to build upon the delinquency information but serializing the Delinquency Classification job and the Loan COB steps is quite challenging so it’s best if the Delinquency Classification logic can be included as part of the Loan COB.
   
   [FINERACT-1721](https://issues.apache.org/jira/browse/FINERACT-1721).
   
   ## 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] adamsaghy commented on a diff in pull request #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


##########
fineract-provider/src/main/java/org/apache/fineract/cob/loan/LoanCOBWorkerConfiguration.java:
##########
@@ -57,19 +60,42 @@ public class LoanCOBWorkerConfiguration {
     private QueueChannel inboundRequests;
     @Autowired
     private COBBusinessStepService cobBusinessStepService;
+    @Autowired
+    private AppUserRepositoryWrapper userRepository;
 
-    @Bean(name = "Loan COB worker")
-    public Step loanCOBWorkerStep() {
+    @Bean
+    public Step loanBusinessStep() {
         return stepBuilderFactory.get("Loan COB worker").inputChannel(inboundRequests)
                 .<Loan, Loan>chunk(cobPropertyService.getChunkSize(JobName.LOAN_COB.name())).reader(itemReader(null))
                 .processor(itemProcessor()).writer(itemWriter()).build();
     }
 
+    @Bean(name = "Loan COB worker")
+    public Step loanCOBWorkerStep() {
+        return stepBuilderFactory.get("Loan COB worker - Step").inputChannel(inboundRequests).flow(flow()).build();
+    }
+
     @Bean
     public Job loanCOBWorkerJob() {
         return jobBuilderFactory.get("Loan COB worker").start(loanCOBWorkerStep()).incrementer(new RunIdIncrementer()).build();
     }
 
+    @Bean
+    public Flow flow() {
+        return new FlowBuilder<Flow>("cobFlow").start(initialisationStep()).next(loanBusinessStep()).next(loanBusinessStep()).build();

Review Comment:
   Duplicate ".next(loanBusinessStep())". Please remove one of them



-- 
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 #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


##########
fineract-provider/src/main/java/org/apache/fineract/cob/loan/SetLoanDelinquencyTagsBusinessStep.java:
##########
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.cob.loan;
+
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.fineract.infrastructure.core.service.DateUtils;
+import org.apache.fineract.portfolio.loanaccount.domain.Loan;
+import org.apache.fineract.portfolio.loanaccount.domain.LoanAccountDomainService;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component
+@RequiredArgsConstructor
+public class SetLoanDelinquencyTagsBusinessStep implements LoanCOBBusinessStep {
+
+    private final LoanAccountDomainService loanAccountDomainService;
+
+    @Override
+    public Loan execute(Loan loan) {
+        log.info("Set Loan Delinquency Tags Business Step {}", loan.getId());

Review Comment:
   Please do not log info level! Use debug!



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -148,7 +148,7 @@ public CommandProcessingResult deleteDelinquencyBucket(Long delinquencyBucketId,
     public CommandProcessingResult applyDelinquencyTagToLoan(Long loanId, JsonCommand command) {
         Map<String, Object> changes = new HashMap<>();
 
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);

Review Comment:
   @josehernandezfintecheandomx There is no change. You are still using referenceId



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -166,7 +166,7 @@ public CommandProcessingResult applyDelinquencyTagToLoan(Long loanId, JsonComman
 
     @Override
     public void applyDelinquencyTagToLoan(Long loanId, Long ageDays) {
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);

Review Comment:
   @josehernandezfintecheandomx no change... still using referenceId



-- 
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] josehernandezfintecheandomx commented on a diff in pull request #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -166,7 +166,7 @@ public CommandProcessingResult applyDelinquencyTagToLoan(Long loanId, JsonComman
 
     @Override
     public void applyDelinquencyTagToLoan(Long loanId, Long ageDays) {
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);

Review Comment:
   Done!



-- 
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 #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -148,7 +148,7 @@ public CommandProcessingResult deleteDelinquencyBucket(Long delinquencyBucketId,
     public CommandProcessingResult applyDelinquencyTagToLoan(Long loanId, JsonCommand command) {
         Map<String, Object> changes = new HashMap<>();
 
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);

Review Comment:
   As the loan is not used as a reference, rather doing actions on it, we should use the "this.loanRepository.findOneWithNotFoundDetection"
   
   Using the "getReferenceById" is only useful if we dont need to fetch the loan entirely (fields and associations), but only we need the reference of it. 
   Example:
   `new LoanTransaction(loan, transactionDate,....)`
   
   Here we dont need to fetch the loan, only the reference which can be used to associate the loan entity with the loan transaction entity.



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -329,7 +329,7 @@ private Map<String, Object> lookUpDelinquencyRange(final Loan loan, final Delinq
     }
 
     public Map<String, Object> setLoanDelinquencyTag(Long loanId, Long delinquencyRangeId) {
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);
+        final Loan loan = this.loanRepository.getReferenceById(loanId);

Review Comment:
   Nice catch! We dont need to fetch the full loan here. Reference is enough! :)



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -166,7 +166,7 @@ public CommandProcessingResult applyDelinquencyTagToLoan(Long loanId, JsonComman
 
     @Override
     public void applyDelinquencyTagToLoan(Long loanId, Long ageDays) {
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);

Review Comment:
   As the loan is not used as a reference, rather doing actions on it, we should use the "this.loanRepository.findOneWithNotFoundDetection"
   
   Using the "getReferenceById" is only useful if we dont need to fetch the loan entirely (fields and associations), but only we need the reference of it. 
   Example:
   `new LoanTransaction(loan, transactionDate,....)`
   
   Here we dont need to fetch the loan, only the reference which can be used to associate the loan entity with the loan transaction entity.



-- 
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] josehernandezfintecheandomx commented on a diff in pull request #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -148,7 +148,7 @@ public CommandProcessingResult deleteDelinquencyBucket(Long delinquencyBucketId,
     public CommandProcessingResult applyDelinquencyTagToLoan(Long loanId, JsonCommand command) {
         Map<String, Object> changes = new HashMap<>();
 
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);

Review Comment:
   Done!



-- 
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 #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


##########
fineract-provider/src/main/java/org/apache/fineract/cob/loan/LoanCOBWorkerConfiguration.java:
##########
@@ -57,19 +60,42 @@ public class LoanCOBWorkerConfiguration {
     private QueueChannel inboundRequests;
     @Autowired
     private COBBusinessStepService cobBusinessStepService;
+    @Autowired
+    private AppUserRepositoryWrapper userRepository;
 
-    @Bean(name = "Loan COB worker")
-    public Step loanCOBWorkerStep() {
+    @Bean
+    public Step loanBusinessStep() {
         return stepBuilderFactory.get("Loan COB worker").inputChannel(inboundRequests)
                 .<Loan, Loan>chunk(cobPropertyService.getChunkSize(JobName.LOAN_COB.name())).reader(itemReader(null))
                 .processor(itemProcessor()).writer(itemWriter()).build();
     }
 
+    @Bean(name = "Loan COB worker")
+    public Step loanCOBWorkerStep() {
+        return stepBuilderFactory.get("Loan COB worker - Step").inputChannel(inboundRequests).flow(flow()).build();
+    }
+
     @Bean
     public Job loanCOBWorkerJob() {
         return jobBuilderFactory.get("Loan COB worker").start(loanCOBWorkerStep()).incrementer(new RunIdIncrementer()).build();
     }
 
+    @Bean
+    public Flow flow() {
+        return new FlowBuilder<Flow>("cobFlow").start(initialisationStep()).next(loanBusinessStep()).next(loanBusinessStep()).build();

Review Comment:
   Duplicate ".next(loanBusinessStep())". Please remove one of them



-- 
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 #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -166,7 +166,7 @@ public CommandProcessingResult applyDelinquencyTagToLoan(Long loanId, JsonComman
 
     @Override
     public void applyDelinquencyTagToLoan(Long loanId, Long ageDays) {
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);

Review Comment:
   As the loan is not used as a reference, rather doing actions on it, we should use the "this.loanRepository.findOneWithNotFoundDetection"



-- 
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 #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -329,7 +329,7 @@ private Map<String, Object> lookUpDelinquencyRange(final Loan loan, final Delinq
     }
 
     public Map<String, Object> setLoanDelinquencyTag(Long loanId, Long delinquencyRangeId) {
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);
+        final Loan loan = this.loanRepository.getReferenceById(loanId);

Review Comment:
   Would you please check whether this and the only method (public CommandProcessingResult setLoanDelinquencyTag(Long loanId, Long delinquencyRangeId, JsonCommand command)) in the line 108 is used at all?
   
   We might not need this method at all...



-- 
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 #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -148,7 +148,7 @@ public CommandProcessingResult deleteDelinquencyBucket(Long delinquencyBucketId,
     public CommandProcessingResult applyDelinquencyTagToLoan(Long loanId, JsonCommand command) {
         Map<String, Object> changes = new HashMap<>();
 
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);

Review Comment:
   As the loan is not used as a reference, rather doing actions on it, we should use the "this.loanRepository.findOneWithNotFoundDetection"
   
   Using the "getReferenceById" is only useful if we dont need to fetch the loan entirely (fields and associations), but only we need the reference of it. 
   Example:
   `new LoanTransaction(loan, transactionDate,....)`
   
   In the example we dont need to fetch the loan, only the reference which can be used to associate the loan entity with the loan transaction entity.



-- 
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 #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -329,7 +329,7 @@ private Map<String, Object> lookUpDelinquencyRange(final Loan loan, final Delinq
     }
 
     public Map<String, Object> setLoanDelinquencyTag(Long loanId, Long delinquencyRangeId) {
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);
+        final Loan loan = this.loanRepository.getReferenceById(loanId);

Review Comment:
   Would you please check whether this and the only method (public CommandProcessingResult setLoanDelinquencyTag(Long loanId, Long delinquencyRangeId, JsonCommand command)) in the line 108 is used at all?



-- 
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] josehernandezfintecheandomx commented on a diff in pull request #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/delinquency/service/DelinquencyWritePlatformServiceImpl.java:
##########
@@ -329,7 +329,7 @@ private Map<String, Object> lookUpDelinquencyRange(final Loan loan, final Delinq
     }
 
     public Map<String, Object> setLoanDelinquencyTag(Long loanId, Long delinquencyRangeId) {
-        final Loan loan = this.loanRepository.findOneWithNotFoundDetection(loanId);
+        final Loan loan = this.loanRepository.getReferenceById(loanId);

Review Comment:
   Done!



-- 
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 #2569: FINERACT-1721: Delinquency classification as a Loan COB business step

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


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