adamsaghy commented on code in PR #4828:
URL: https://github.com/apache/fineract/pull/4828#discussion_r2210145768


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java:
##########
@@ -1294,4 +1350,20 @@ private String createLoanDelinquencyAction(Long loanId, 
ExternalId loanExternalI
         return delinquencyActionSerializer.serialize(result);
     }
 
+    private String modifyLoanApprovedAmount(Long loanId, ExternalId 
loanExternalId, String apiRequestBodyAsJson) {
+        Long resolvedLoanId = getResolvedLoanId(loanId, loanExternalId);
+        final CommandWrapperBuilder builder = new 
CommandWrapperBuilder().withJson(apiRequestBodyAsJson);
+        CommandWrapper commandRequest = 
builder.updateLoanApprovedAmount(resolvedLoanId).build();
+
+        final CommandProcessingResult result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+        return this.toApiJsonSerializer.serialize(result);
+    }
+
+    private LoanApprovedAmountHistoryResponse 
getLoanApprovedAmountHistory(Long loanId, ExternalId loanExternalId) {
+        
context.authenticatedUser().validateHasReadPermission(RESOURCE_NAME_FOR_PERMISSIONS);
+        Long resolvedLoanId = getResolvedLoanId(loanId, loanExternalId);
+        List<LoanApprovedAmountHistoryData> loanApprovedAmountHistory = 
loanApprovedAmountHistoryRepository.findAllByLoanId(resolvedLoanId);
+        return new 
LoanApprovedAmountHistoryResponse(loanApprovedAmountHistory);

Review Comment:
   We can return directly the `List<LoanApprovedAmountHistoryData>`, no need 
extra serialization.



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java:
##########
@@ -872,6 +876,58 @@ public String createLoanDelinquencyAction(
         return createLoanDelinquencyAction(null, 
ExternalIdFactory.produce(loanExternalId), apiRequestBodyAsJson);
     }
 
+    @PUT
+    @Path("{loanId}/approved-amount")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    @Operation(summary = "Modifies the approved amount of the loan", 
description = "")
+    @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = 
LoansApiResourceSwagger.PutLoansApprovedAmountRequest.class)))
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = 
LoansApiResourceSwagger.PutLoansApprovedAmountResponse.class))) })
+    public String modifyLoanApprovedAmount(@PathParam("loanId") 
@Parameter(description = "loanId", required = true) final Long loanId,
+            @Context final UriInfo uriInfo, @Parameter(hidden = true) final 
String apiRequestBodyAsJson) {
+        return modifyLoanApprovedAmount(loanId, ExternalId.empty(), 
apiRequestBodyAsJson);
+    }
+
+    @PUT
+    @Path("external-id/{loanExternalId}/approved-amount")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    @Operation(summary = "Modifies the approved amount of the loan", 
description = "")
+    @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = 
LoansApiResourceSwagger.PutLoansApprovedAmountRequest.class)))
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = 
LoansApiResourceSwagger.PutLoansApprovedAmountResponse.class))) })
+    public String modifyLoanApprovedAmount(
+            @PathParam("loanExternalId") @Parameter(description = 
"loanExternalId", required = true) final String loanExternalId,
+            @Context final UriInfo uriInfo, @Parameter(hidden = true) final 
String apiRequestBodyAsJson) {
+        return modifyLoanApprovedAmount(null, 
ExternalIdFactory.produce(loanExternalId), apiRequestBodyAsJson);
+    }
+
+    @GET
+    @Path("{loanId}/approved-amount")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    @Operation(summary = "Collects and returns the approved amount 
modification history for a given loan", description = "")
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = 
LoansApiResourceSwagger.GetLoansApprovedAmountHistoryResponse.class))) })
+    public LoanApprovedAmountHistoryResponse getLoanApprovedAmountHistory(
+            @PathParam("loanId") @Parameter(description = "loanId", required = 
true) final Long loanId, @Context final UriInfo uriInfo) {
+        return getLoanApprovedAmountHistory(loanId, ExternalId.empty());
+    }
+
+    @GET
+    @Path("external-id/{loanExternalId}/approved-amount")
+    @Consumes(MediaType.APPLICATION_JSON)
+    @Produces(MediaType.APPLICATION_JSON)
+    @Operation(summary = "Collects and returns the approved amount 
modification history for a given loan", description = "")
+    @ApiResponses({

Review Comment:
   Same as above



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to