Aman-Mittal commented on code in PR #5771:
URL: https://github.com/apache/fineract/pull/5771#discussion_r3153769678


##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/api/WorkingCapitalLoanApiResource.java:
##########
@@ -346,4 +349,110 @@ private CommandProcessingResult updateDiscount(final Long 
loanId, final String l
                 
.updateDiscountWorkingCapitalLoanApplication(resolvedLoanId).build();
         return 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
     }
+
+    @PUT
+    @Path("{loanId}/rate")

Review Comment:
   What is the difference between loadId and loanExternalId?
   
   I am assuming loanExternalId is for external Systems.
   
   (Please Resolve this comment after replying)
   



##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/api/WorkingCapitalLoanApiResource.java:
##########
@@ -346,4 +349,110 @@ private CommandProcessingResult updateDiscount(final Long 
loanId, final String l
                 
.updateDiscountWorkingCapitalLoanApplication(resolvedLoanId).build();
         return 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
     }
+
+    @PUT
+    @Path("{loanId}/rate")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(operationId = "updateWorkingCapitalLoanRateById", summary = 
"Update period payment rate for an active Working Capital Loan", description = 
"Modifies the period payment rate and triggers schedule recalculation for the 
remaining term.")
+    @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = 
WorkingCapitalLoanApiResourceSwagger.PutWorkingCapitalLoansLoanIdRateRequest.class)))
+    @ApiResponses({

Review Comment:
   ApiResponses doesnt provide any value in newer swagger dependecies and aften 
recommended to be removed by sonarqube



##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/api/WorkingCapitalLoanApiResource.java:
##########
@@ -346,4 +349,110 @@ private CommandProcessingResult updateDiscount(final Long 
loanId, final String l
                 
.updateDiscountWorkingCapitalLoanApplication(resolvedLoanId).build();
         return 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
     }
+
+    @PUT
+    @Path("{loanId}/rate")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(operationId = "updateWorkingCapitalLoanRateById", summary = 
"Update period payment rate for an active Working Capital Loan", description = 
"Modifies the period payment rate and triggers schedule recalculation for the 
remaining term.")
+    @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = 
WorkingCapitalLoanApiResourceSwagger.PutWorkingCapitalLoansLoanIdRateRequest.class)))
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = CommandProcessingResult.class))) })
+    public CommandProcessingResult updateRateById(
+            @PathParam("loanId") @Parameter(description = "loanId", required = 
true) final Long loanId,
+            @Parameter(hidden = true) final String apiRequestBodyAsJson) {
+        return updateRate(loanId, null, apiRequestBodyAsJson);
+    }
+
+    @PUT
+    @Path("external-id/{loanExternalId}/rate")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(operationId = "updateWorkingCapitalLoanRateByExternalId", 
summary = "Update period payment rate for an active Working Capital Loan by 
external id", description = "Modifies the period payment rate and triggers 
schedule recalculation for the remaining term.")
+    @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = 
WorkingCapitalLoanApiResourceSwagger.PutWorkingCapitalLoansLoanIdRateRequest.class)))
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = CommandProcessingResult.class))) })
+    public CommandProcessingResult updateRateByExternalId(
+            @PathParam("loanExternalId") @Parameter(description = 
"loanExternalId", required = true) final String loanExternalId,
+            @Parameter(hidden = true) final String apiRequestBodyAsJson) {
+        return updateRate(null, loanExternalId, apiRequestBodyAsJson);
+    }
+
+    private CommandProcessingResult updateRate(final Long loanId, final String 
loanExternalIdStr, final String apiRequestBodyAsJson) {
+        final Long resolvedLoanId = loanId != null ? loanId
+                : 
readPlatformService.getResolvedLoanId(ExternalIdFactory.produce(loanExternalIdStr));
+        if (resolvedLoanId == null) {
+            throw new 
WorkingCapitalLoanNotFoundException(ExternalIdFactory.produce(loanExternalIdStr));
+        }
+        final CommandWrapper commandRequest = new 
CommandWrapperBuilder().withJson(apiRequestBodyAsJson)
+                
.updateRateWorkingCapitalLoanApplication(resolvedLoanId).build();
+        return 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+    }
+
+    @POST
+    @Path("{loanId}/rate/undo")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(operationId = "undoWorkingCapitalLoanRateChangeById", summary = 
"Undo the last period payment rate change", description = "Reverses the most 
recent non-reversed rate change and restores the previous amortization model.")
+    @RequestBody(content = @Content(schema = @Schema(implementation = 
WorkingCapitalLoanApiResourceSwagger.PostWorkingCapitalLoansLoanIdRateUndoRequest.class)))
+    @ApiResponses({

Review Comment:
   same as above



##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/api/WorkingCapitalLoanApiResource.java:
##########
@@ -346,4 +349,110 @@ private CommandProcessingResult updateDiscount(final Long 
loanId, final String l
                 
.updateDiscountWorkingCapitalLoanApplication(resolvedLoanId).build();
         return 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
     }
+
+    @PUT
+    @Path("{loanId}/rate")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(operationId = "updateWorkingCapitalLoanRateById", summary = 
"Update period payment rate for an active Working Capital Loan", description = 
"Modifies the period payment rate and triggers schedule recalculation for the 
remaining term.")
+    @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = 
WorkingCapitalLoanApiResourceSwagger.PutWorkingCapitalLoansLoanIdRateRequest.class)))
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = CommandProcessingResult.class))) })
+    public CommandProcessingResult updateRateById(
+            @PathParam("loanId") @Parameter(description = "loanId", required = 
true) final Long loanId,
+            @Parameter(hidden = true) final String apiRequestBodyAsJson) {
+        return updateRate(loanId, null, apiRequestBodyAsJson);
+    }
+
+    @PUT
+    @Path("external-id/{loanExternalId}/rate")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(operationId = "updateWorkingCapitalLoanRateByExternalId", 
summary = "Update period payment rate for an active Working Capital Loan by 
external id", description = "Modifies the period payment rate and triggers 
schedule recalculation for the remaining term.")
+    @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = 
WorkingCapitalLoanApiResourceSwagger.PutWorkingCapitalLoansLoanIdRateRequest.class)))
+    @ApiResponses({

Review Comment:
   Same as above



##########
fineract-working-capital-loan/src/main/java/org/apache/fineract/portfolio/workingcapitalloan/api/WorkingCapitalLoanApiResource.java:
##########
@@ -346,4 +349,110 @@ private CommandProcessingResult updateDiscount(final Long 
loanId, final String l
                 
.updateDiscountWorkingCapitalLoanApplication(resolvedLoanId).build();
         return 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
     }
+
+    @PUT
+    @Path("{loanId}/rate")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(operationId = "updateWorkingCapitalLoanRateById", summary = 
"Update period payment rate for an active Working Capital Loan", description = 
"Modifies the period payment rate and triggers schedule recalculation for the 
remaining term.")
+    @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = 
WorkingCapitalLoanApiResourceSwagger.PutWorkingCapitalLoansLoanIdRateRequest.class)))
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = CommandProcessingResult.class))) })
+    public CommandProcessingResult updateRateById(
+            @PathParam("loanId") @Parameter(description = "loanId", required = 
true) final Long loanId,
+            @Parameter(hidden = true) final String apiRequestBodyAsJson) {
+        return updateRate(loanId, null, apiRequestBodyAsJson);
+    }
+
+    @PUT
+    @Path("external-id/{loanExternalId}/rate")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(operationId = "updateWorkingCapitalLoanRateByExternalId", 
summary = "Update period payment rate for an active Working Capital Loan by 
external id", description = "Modifies the period payment rate and triggers 
schedule recalculation for the remaining term.")
+    @RequestBody(required = true, content = @Content(schema = 
@Schema(implementation = 
WorkingCapitalLoanApiResourceSwagger.PutWorkingCapitalLoansLoanIdRateRequest.class)))
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = CommandProcessingResult.class))) })
+    public CommandProcessingResult updateRateByExternalId(
+            @PathParam("loanExternalId") @Parameter(description = 
"loanExternalId", required = true) final String loanExternalId,
+            @Parameter(hidden = true) final String apiRequestBodyAsJson) {
+        return updateRate(null, loanExternalId, apiRequestBodyAsJson);
+    }
+
+    private CommandProcessingResult updateRate(final Long loanId, final String 
loanExternalIdStr, final String apiRequestBodyAsJson) {
+        final Long resolvedLoanId = loanId != null ? loanId
+                : 
readPlatformService.getResolvedLoanId(ExternalIdFactory.produce(loanExternalIdStr));
+        if (resolvedLoanId == null) {
+            throw new 
WorkingCapitalLoanNotFoundException(ExternalIdFactory.produce(loanExternalIdStr));
+        }
+        final CommandWrapper commandRequest = new 
CommandWrapperBuilder().withJson(apiRequestBodyAsJson)
+                
.updateRateWorkingCapitalLoanApplication(resolvedLoanId).build();
+        return 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+    }
+
+    @POST
+    @Path("{loanId}/rate/undo")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(operationId = "undoWorkingCapitalLoanRateChangeById", summary = 
"Undo the last period payment rate change", description = "Reverses the most 
recent non-reversed rate change and restores the previous amortization model.")
+    @RequestBody(content = @Content(schema = @Schema(implementation = 
WorkingCapitalLoanApiResourceSwagger.PostWorkingCapitalLoansLoanIdRateUndoRequest.class)))
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = CommandProcessingResult.class))) })
+    public CommandProcessingResult undoRateChangeById(
+            @PathParam("loanId") @Parameter(description = "loanId", required = 
true) final Long loanId,
+            @Parameter(hidden = true) final String apiRequestBodyAsJson) {
+        return undoRateChange(loanId, null, apiRequestBodyAsJson);
+    }
+
+    @POST
+    @Path("external-id/{loanExternalId}/rate/undo")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(operationId = "undoWorkingCapitalLoanRateChangeByExternalId", 
summary = "Undo the last period payment rate change by external id", 
description = "Reverses the most recent non-reversed rate change and restores 
the previous amortization model.")
+    @RequestBody(content = @Content(schema = @Schema(implementation = 
WorkingCapitalLoanApiResourceSwagger.PostWorkingCapitalLoansLoanIdRateUndoRequest.class)))
+    @ApiResponses({
+            @ApiResponse(responseCode = "200", description = "OK", content = 
@Content(schema = @Schema(implementation = CommandProcessingResult.class))) })
+    public CommandProcessingResult undoRateChangeByExternalId(
+            @PathParam("loanExternalId") @Parameter(description = 
"loanExternalId", required = true) final String loanExternalId,
+            @Parameter(hidden = true) final String apiRequestBodyAsJson) {
+        return undoRateChange(null, loanExternalId, apiRequestBodyAsJson);
+    }
+
+    private CommandProcessingResult undoRateChange(final Long loanId, final 
String loanExternalIdStr, final String apiRequestBodyAsJson) {
+        final Long resolvedLoanId = loanId != null ? loanId
+                : 
readPlatformService.getResolvedLoanId(ExternalIdFactory.produce(loanExternalIdStr));
+        if (resolvedLoanId == null) {
+            throw new 
WorkingCapitalLoanNotFoundException(ExternalIdFactory.produce(loanExternalIdStr));
+        }
+        final CommandWrapper commandRequest = new 
CommandWrapperBuilder().withJson(apiRequestBodyAsJson)
+                
.undoRateChangeWorkingCapitalLoanApplication(resolvedLoanId).build();
+        return 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+    }
+
+    @GET
+    @Path("{loanId}/rate-changes")
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Operation(operationId = "getWorkingCapitalLoanRateChangeHistoryById", 
summary = "Retrieve rate change history for a Working Capital Loan", 
description = "Returns all rate change records for the loan, ordered by most 
recent first.")
+    @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