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

[PR] FINERACT-2421: Rework code value handling in E2E [fineract]

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

   ## 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-2421: Rework code value handling in E2E [fineract]

Posted by "oleksii-novikov-onix (via GitHub)" <gi...@apache.org>.
oleksii-novikov-onix commented on code in PR #5334:
URL: https://github.com/apache/fineract/pull/5334#discussion_r2699013089


##########
fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java:
##########
@@ -3697,7 +3697,9 @@ public void initialize() throws Exception {
 
         List<PostClassificationToIncomeAccountMappings> buydownfeeClassificationToIncomeAccountMappings = new ArrayList<>();
         PostClassificationToIncomeAccountMappings classificationToIncomeAccountMappings = new PostClassificationToIncomeAccountMappings();
-        classificationToIncomeAccountMappings.setClassificationCodeValueId(25L);
+        long classificationId = codeValueResolver.resolve("buydown_fee_transaction_classification",
+                "buydown_fee_transaction_classification_value");

Review Comment:
   We can use constants here CodeNames.BUYDOWN_FEE_TRANSACTION_CLASSIFICATION.getValue() and CodeGlobalInitializerStep.BUYDOWN_FEE_TRANSACTION_CLASSIFICATION_VALUE



-- 
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-2421: Rework code value handling in E2E [fineract]

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


##########
fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java:
##########
@@ -3697,7 +3697,9 @@ public void initialize() throws Exception {
 
         List<PostClassificationToIncomeAccountMappings> buydownfeeClassificationToIncomeAccountMappings = new ArrayList<>();
         PostClassificationToIncomeAccountMappings classificationToIncomeAccountMappings = new PostClassificationToIncomeAccountMappings();
-        classificationToIncomeAccountMappings.setClassificationCodeValueId(25L);
+        long classificationId = codeValueResolver.resolve("buydown_fee_transaction_classification",
+                "buydown_fee_transaction_classification_value");

Review Comment:
   First one yes, last no... they are not in the same module..



-- 
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-2421: Rework code value handling in E2E [fineract]

Posted by "oleksii-novikov-onix (via GitHub)" <gi...@apache.org>.
oleksii-novikov-onix commented on code in PR #5334:
URL: https://github.com/apache/fineract/pull/5334#discussion_r2699018378


##########
fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java:
##########
@@ -3736,7 +3738,9 @@ public void initialize() throws Exception {
 
         List<PostClassificationToIncomeAccountMappings> capitalizedIncomeClassificationToIncomeAccountMappings = new ArrayList<>();
         PostClassificationToIncomeAccountMappings classificationToIncomeAccountMappingsCapitalizedIncome = new PostClassificationToIncomeAccountMappings();
-        classificationToIncomeAccountMappingsCapitalizedIncome.setClassificationCodeValueId(24L);
+        long capitalizedIncomeClassificationId = codeValueResolver.resolve("capitalized_income_transaction_classification",
+                "capitalized_income_transaction_classification_value");

Review Comment:
   And here we can use defined constants too



-- 
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-2421: Rework code value handling in E2E [fineract]

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


##########
fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java:
##########
@@ -3697,7 +3697,9 @@ public void initialize() throws Exception {
 
         List<PostClassificationToIncomeAccountMappings> buydownfeeClassificationToIncomeAccountMappings = new ArrayList<>();
         PostClassificationToIncomeAccountMappings classificationToIncomeAccountMappings = new PostClassificationToIncomeAccountMappings();
-        classificationToIncomeAccountMappings.setClassificationCodeValueId(25L);
+        long classificationId = codeValueResolver.resolve("buydown_fee_transaction_classification",
+                "buydown_fee_transaction_classification_value");

Review Comment:
   First one yes, last no... they are not in the same package..



-- 
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-2421: Rework code value handling in E2E [fineract]

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


##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/codes/service/CodeValueReadPlatformServiceImpl.java:
##########
@@ -105,4 +104,14 @@ public CodeValueData retrieveCodeValue(final Long codeValueId) {
         }
 
     }
+
+    @Override
+    public List<CodeValueData> retrieveAllCodeValues(String codeName) {
+        return codeValueMapper.map(codeValueRepository.findByCodeName(codeName));

Review Comment:
   All the other methods have `this.context.authenticatedUser();` don't we want to use the same in these 2 new methods?
   Also, is it possible to receive null from `codeValueRepository.findByCodeName(codeName)`? That could lead NPE



##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/codes/api/CodeValuesApiResource.java:
##########
@@ -172,4 +177,89 @@ public String deleteCodeValue(@PathParam("codeId") @Parameter(description = "cod
 
         return this.toApiJsonSerializer.serialize(result);
     }
+
+    @GET
+    @Path("name/{codeName}/codevalues")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(summary = "List Code Values", description = "Returns the list of Code Values for a given Code\n" + "\n"
+            + "Example Requests:\n" + "\n" + "codes/1/codevalues", parameters = @Parameter(name = "codeId", description = "co"))
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "A List of code values for a given code", content = @Content(array = @ArraySchema(schema = @Schema(implementation = CodeValuesApiResourceSwagger.GetCodeValuesDataResponse.class)))) })
+    public List<CodeValueData> retrieveAllCodeValues(@Context final UriInfo uriInfo,
+            @PathParam("codeName") @Parameter(description = "codeName") final String codeName) {
+
+        this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
+
+        return this.readPlatformService.retrieveAllCodeValues(codeName);
+    }
+
+    @GET
+    @Path("name/{codeName}/codevalues/{codeValueId}")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(summary = "Retrieve a Code description", description = "Returns the details of a Code Value\n" + "\n" + "Example Requests:\n"
+            + "\n" + "codes/name/ADDRESS_TYPE/codevalues/1")
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CodeValuesApiResourceSwagger.GetCodeValuesDataResponse.class))) })
+    public CodeValueData retrieveCodeValue(@Context final UriInfo uriInfo,
+            @PathParam("codeName") @Parameter(description = "codeName") final String codeName,
+            @PathParam("codeValueId") @Parameter(description = "codeValueId") final Long codeValueId) {
+
+        this.context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
+
+        return this.readPlatformService.retrieveCodeValue(codeName, codeValueId);
+    }
+
+    @POST
+    @Path("name/{codeName}/codevalues")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(summary = "Create a Code description", description = "")
+    @RequestBody(required = true, content = @Content(schema = @Schema(implementation = CodeValuesApiResourceSwagger.PostCodeValuesDataRequest.class)))
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = CodeValuesApiResourceSwagger.PostCodeValueDataResponse.class))) })
+    public CommandProcessingResult createCodeValue(@PathParam("codeName") @Parameter(description = "codeName") final String codeName,
+            @Parameter(hidden = true) final String apiRequestBodyAsJson) {
+        CodeData code = codeReadPlatformService.retriveCode(codeName);

Review Comment:
   minor: I know it's given, but there is a typo here, it should be retrieveCode



##########
fineract-e2e-tests-runner/src/test/java/org/apache/fineract/test/initializer/global/LoanProductGlobalInitializerStep.java:
##########
@@ -3736,7 +3738,9 @@ public void initialize() throws Exception {
 
         List<PostClassificationToIncomeAccountMappings> capitalizedIncomeClassificationToIncomeAccountMappings = new ArrayList<>();
         PostClassificationToIncomeAccountMappings classificationToIncomeAccountMappingsCapitalizedIncome = new PostClassificationToIncomeAccountMappings();
-        classificationToIncomeAccountMappingsCapitalizedIncome.setClassificationCodeValueId(24L);
+        long CapitalizedIncomeClassificationId = codeValueResolver.resolve("capitalized_income_transaction_classification",

Review Comment:
   ```suggestion
           long capitalizedIncomeClassificationId = codeValueResolver.resolve("capitalized_income_transaction_classification",
   ```



##########
fineract-e2e-tests-core/src/test/java/org/apache/fineract/test/data/codevalue/CodeValueResolver.java:
##########
@@ -43,7 +43,19 @@ public long resolve(Long codeId, CodeValue codeValue) {
         log.debug("Resolving code value by code id and name [{}]", codeValue);
         List<GetCodeValuesDataResponse> codeValuesResponses = ok(() -> fineractClient.codeValues().retrieveAllCodeValues(codeId, Map.of()));
         GetCodeValuesDataResponse foundPtr = codeValuesResponses.stream().filter(ptr -> codeValueName.equals(ptr.getName())).findAny()
-                .orElseThrow(() -> new IllegalArgumentException("Payment type [%s] not found".formatted(codeValueName)));
+                .orElseThrow(
+                        () -> new IllegalArgumentException("Code Value [%s] not found for Code [%s]".formatted(codeValueName, codeId)));
+
+        return foundPtr.getId();
+    }
+
+    @Cacheable(key = "#codeValue", value = "codeValuesByName")
+    public long resolve(String codeName, String codeValue) {

Review Comment:
   Is the codeValue always unique? If we have same values for multiple names it could cause caching issues



-- 
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-2421: Rework code value handling in E2E [fineract]

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


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