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/07/01 02:07:28 UTC

[GitHub] [fineract] josehernandezfintecheandomx opened a new pull request, #2394: Loan externalId unique validation

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

   ## Description
   
   Loan creation - Data integrity issue in case the ExternalID was already used, now It returns a domain rule validation error with the developer code: `error.msg.loan.with.externalId.already.used`
   
   - Error in the FrontEnd
   <img width="1114" alt="Screen Shot 2022-06-30 at 19 29 14" src="https://user-images.githubusercontent.com/44206706/176809039-6b0a78f5-8f6a-456b-8c90-21f3893d485b.png">
   
   - Error (detailed) in the Integration Test created
   <img width="1009" alt="Screen Shot 2022-06-30 at 20 57 33" src="https://user-images.githubusercontent.com/44206706/176809013-ea92d4f5-653d-4ca0-ab6e-bb6be070b875.png">
   
   ## 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] josehernandezfintecheandomx commented on a diff in pull request #2394: Loan externalId unique validation

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepository.java:
##########
@@ -161,4 +163,7 @@ List<Loan> findByGroupOfficeIdsAndLoanStatus(@Param("officeIds") Collection<Long
     @Query(FIND_BY_ACCOUNT_NUMBER)
     Loan findLoanAccountByAccountNumber(@Param("accountNumber") String accountNumber);
 
+    @Query(DOES_EXISTS_LOAN_WITH_EXTERNAL_ID)
+    boolean validateIfExistLoanWithExternalId(@Param("externalId") String externalId);

Review Comment:
   Done!



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepositoryWrapper.java:
##########
@@ -240,6 +240,10 @@ public Loan findNonClosedLoanByAccountNumber(@Param("accountNumber") String acco
         return this.repository.findNonClosedLoanByAccountNumber(accountNumber);
     }
 
+    public boolean validateIfExistLoanWithExternalId(@Param("externalId") String externalId) {

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 commented on a diff in pull request #2394: Loan externalId unique validation

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepository.java:
##########
@@ -161,4 +163,7 @@ List<Loan> findByGroupOfficeIdsAndLoanStatus(@Param("officeIds") Collection<Long
     @Query(FIND_BY_ACCOUNT_NUMBER)
     Loan findLoanAccountByAccountNumber(@Param("accountNumber") String accountNumber);
 
+    @Query(DOES_EXISTS_LOAN_WITH_EXTERNAL_ID)
+    boolean validateIfExistLoanWithExternalId(@Param("externalId") String externalId);

Review Comment:
   1. validate is not really a good choice of name because the method is not validating anything, rather it decides whether a loan exists with externalId.
   2. No need for a custom query. Spring Data JPA supports the `exists` keyword so you can simply name the method like `existsByExternalId` and magically it should work.



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/domain/LoanRepositoryWrapper.java:
##########
@@ -240,6 +240,10 @@ public Loan findNonClosedLoanByAccountNumber(@Param("accountNumber") String acco
         return this.repository.findNonClosedLoanByAccountNumber(accountNumber);
     }
 
+    public boolean validateIfExistLoanWithExternalId(@Param("externalId") String externalId) {

Review Comment:
   Same, method naming is a tiny bit confusing.
   Bonus: why do we have the `@Param` annotation here? It just doesn't make any sense to me. Could you explain?



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -303,6 +303,13 @@ public CommandProcessingResult submitApplication(final JsonCommand command) {
 
             this.fromApiJsonDeserializer.validateForCreate(command.json(), isMeetingMandatoryForJLGLoans, loanProduct);
 
+            // Validate If the externalId is already registered
+            final String externalId = this.fromJsonHelper.extractStringNamed("externalId", command.parsedJson());
+            if (StringUtils.isNotBlank(externalId) && this.loanRepositoryWrapper.validateIfExistLoanWithExternalId(externalId)) {

Review Comment:
   Let's not call a repository method within an if condition, it's just really hard to do debugging on 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


[GitHub] [fineract] galovics merged pull request #2394: Loan externalId unique validation

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


-- 
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 #2394: Loan externalId unique validation

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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java:
##########
@@ -303,6 +303,13 @@ public CommandProcessingResult submitApplication(final JsonCommand command) {
 
             this.fromApiJsonDeserializer.validateForCreate(command.json(), isMeetingMandatoryForJLGLoans, loanProduct);
 
+            // Validate If the externalId is already registered
+            final String externalId = this.fromJsonHelper.extractStringNamed("externalId", command.parsedJson());
+            if (StringUtils.isNotBlank(externalId) && this.loanRepositoryWrapper.validateIfExistLoanWithExternalId(externalId)) {

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