nikpawar89 commented on a change in pull request #738: GSIM and GLIM with test 
cases (FINERACT-603)
URL: https://github.com/apache/fineract/pull/738#discussion_r410958376
 
 

 ##########
 File path: 
fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/api/LoansApiResource.java
 ##########
 @@ -848,59 +862,121 @@ public String 
deleteLoanApplication(@PathParam("loanId") @ApiParam(value = "loan
         return this.toApiJsonSerializer.serialize(result);
     }
 
+
+    @GET
+    @Path("glimAccount/{glimId}")
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @Produces({ MediaType.APPLICATION_JSON })
+    public String getGlimRepaymentTemplate(@PathParam("glimId") final Long 
glimId,@Context final UriInfo uriInfo)
+    {
+          
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
+          Collection<GlimRepaymentTemplate> 
glimRepaymentTemplate=this.glimAccountInfoReadPlatformService.findglimRepaymentTemplate(glimId);
+          final ApiRequestJsonSerializationSettings settings = 
this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
+         return this.glimTemplateToApiJsonSerializer.serialize(settings, 
glimRepaymentTemplate, this.GLIM_ACCOUNTS_DATA_PARAMETERS);
+
+    }
+
+
     @POST
-    @Path("{loanId}")
+    @Path("glimAccount/{glimId}")
     @Consumes({ MediaType.APPLICATION_JSON })
     @Produces({ MediaType.APPLICATION_JSON })
+
     @ApiOperation(value = "Approve Loan Application | Recover Loan Guarantee | 
Undo Loan Application Approval | Assign a Loan Officer | Unassign a Loan 
Officer | Reject Loan Application | Applicant Withdraws from Loan Application | 
Disburse Loan Disburse Loan To Savings Account | Undo Loan Disbursal", 
httpMethod = "POST", notes = "Approve Loan Application:\n" + "Mandatory Fields: 
approvedOnDate\n" + "Optional Fields: approvedLoanAmount and 
expectedDisbursementDate\n" + "Approves the loan application\n\n" + "Recover 
Loan Guarantee:\n" + "Recovers the loan guarantee\n\n" + "Undo Loan Application 
Approval:\n" + "Undoes the Loan Application Approval\n\n" + "Assign a Loan 
Officer:\n" + "Allows you to assign Loan Officer for existing Loan.\n\n" + 
"Unassign a Loan Officer:\n" + "Allows you to unassign the Loan Officer.\n\n" + 
"Reject Loan Application:\n" + "Mandatory Fields: rejectedOnDate\n" + "Allows 
you to reject the loan application\n\n" + "Applicant Withdraws from Loan 
Application:\n" + "Mandatory Fields: withdrawnOnDate\n" + "Allows the applicant 
to withdraw the loan application\n\n" + "Disburse Loan:\n" + "Mandatory Fields: 
actualDisbursementDate\n" + "Optional Fields: transactionAmount and 
fixedEmiAmount\n" + "Disburses the Loan\n\n" + "Disburse Loan To Savings 
Account:\n" + "Mandatory Fields: actualDisbursementDate\n" + "Optional Fields: 
transactionAmount and fixedEmiAmount\n" + "Disburses the loan to Saving 
Account\n\n" + "Undo Loan Disbursal:\n" + "Undoes the Loan Disbursal\n" + 
"Showing request and response for Assign a Loan Officer")
     @ApiImplicitParams({@ApiImplicitParam(value = "body", required = true, 
paramType = "body", dataType = "body", format = "body", dataTypeClass = 
LoansApiResourceSwagger.PostLoansLoanIdRequest.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "OK", response = 
LoansApiResourceSwagger.PostLoansLoanIdResponse.class)})
-    public String stateTransitions(@PathParam("loanId") @ApiParam(value = 
"loanId") final Long loanId, @QueryParam("command") @ApiParam(value = 
"command") final String commandParam,
-           @ApiParam(hidden = true) final String apiRequestBodyAsJson) {
+
+    public String glimStateTransitions(@PathParam("glimId") final Long glimId, 
@QueryParam("command") final String commandParam,
+          final String apiRequestBodyAsJson) {
+
 
         final CommandWrapperBuilder builder = new 
CommandWrapperBuilder().withJson(apiRequestBodyAsJson);
 
         CommandProcessingResult result = null;
 
         if (is(commandParam, "reject")) {
-            final CommandWrapper commandRequest = 
builder.rejectLoanApplication(loanId).build();
+            final CommandWrapper commandRequest = 
builder.rejectGLIMApplication(glimId).build();
             result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
-        } else if (is(commandParam, "withdrawnByApplicant")) {
-            final CommandWrapper commandRequest = 
builder.withdrawLoanApplication(loanId).build();
-            result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
-        } else if (is(commandParam, "approve")) {
-            final CommandWrapper commandRequest = 
builder.approveLoanApplication(loanId).build();
-            result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
-        } else if (is(commandParam, "disburse")) {
-            final CommandWrapper commandRequest = 
builder.disburseLoanApplication(loanId).build();
-            result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
-        } else if (is(commandParam, "disburseToSavings")) {
-            final CommandWrapper commandRequest = 
builder.disburseLoanToSavingsApplication(loanId).build();
+        }else if (is(commandParam, "approve")) {
+            final CommandWrapper commandRequest = 
builder.approveGLIMLoanApplication(glimId).build();
             result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
         }
-
-        if (is(commandParam, "undoapproval")) {
-            final CommandWrapper commandRequest = 
builder.undoLoanApplicationApproval(loanId).build();
-            result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
-        } else if (is(commandParam, "undodisbursal")) {
-            final CommandWrapper commandRequest = 
builder.undoLoanApplicationDisbursal(loanId).build();
+        else if (is(commandParam, "disburse")) {
+            final CommandWrapper commandRequest = 
builder.disburseGlimLoanApplication(glimId).build();
             result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
-        }else if (is(commandParam, "undolastdisbursal")) {
-            final CommandWrapper commandRequest = 
builder.undoLastDisbursalLoanApplication(loanId).build();
+        }  else if (is(commandParam, "glimrepayment")) {
+            final CommandWrapper commandRequest = 
builder.repaymentGlimLoanApplication(glimId).build();
             result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
         }
-
-        if (is(commandParam, "assignloanofficer")) {
-            final CommandWrapper commandRequest = 
builder.assignLoanOfficer(loanId).build();
+        else if (is(commandParam, "glimrepayment")) {
+            final CommandWrapper commandRequest = 
builder.repaymentGlimLoanApplication(glimId).build();
             result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
-        } else if (is(commandParam, "unassignloanofficer")) {
-            final CommandWrapper commandRequest = 
builder.unassignLoanOfficer(loanId).build();
+        }
+        else if (is(commandParam, "undodisbursal")) {
+            final CommandWrapper commandRequest = 
builder.undoGLIMLoanDisbursal(glimId).build();
             result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
-        } else if (is(commandParam, "recoverGuarantees")) {
-            final CommandWrapper commandRequest = new 
CommandWrapperBuilder().recoverFromGuarantor(loanId).build();
+        }
+        else if (is(commandParam, "undoapproval")) {
+            final CommandWrapper commandRequest = 
builder.undoGLIMLoanApproval(glimId).build();
             result = 
this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
         }
 
+
+        if (result == null) { throw new 
UnrecognizedQueryParamException("command", commandParam); }
 
 Review comment:
   I think instead of throwing exception over here, we should let Client know 
about about incorrect param. 
   By throwing exceptions, we sometimes reveal too much of inner mechanism to 
clients- just my thought.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to