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 2020/05/03 19:58:04 UTC

[GitHub] [fineract] nikpawar89 commented on a change in pull request #738: GSIM and GLIM with test cases (FINERACT-603)

nikpawar89 commented on a change in pull request #738:
URL: https://github.com/apache/fineract/pull/738#discussion_r419138684



##########
File path: fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/data/CommandProcessingResultBuilder.java
##########
@@ -106,6 +108,16 @@ public CommandProcessingResultBuilder withProductId(final Long productId) {
         return this;
     }
 
+    public CommandProcessingResultBuilder withGsimId(final Long gsimId) {

Review comment:
       For now you can keep this, we will revisit these two new params when we do more testing and see if refactoring is possible.

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/accountdetails/service/AccountDetailsReadPlatformServiceJpaRepositoryImpl.java
##########
@@ -131,6 +162,16 @@ public AccountSummaryCollectionData retrieveGroupAccountDetails(final Long group
         return retrieveLoanAccountDetails(loanWhereClause, new Object[] { clientId });
     }
 
+    @Override
+        public List<LoanAccountSummaryData> retrieveLoanAccountDetailsByGroupIdAndGlimAccountNumber(final Long groupId,final String glimAccount) {
+        final LoanAccountSummaryDataMapper rm = new LoanAccountSummaryDataMapper();
+        final String loanWhereClauseForGroupAndLoanType = " where l.group_id =? and glim.account_number="+glimAccount+" and l.loan_type_enum=4";

Review comment:
       please look into this.

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

Review comment:
       could you please check this.

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java
##########
@@ -91,7 +91,9 @@
             LoanApiConstants.linkAccountIdParameterName, LoanApiConstants.disbursementDataParameterName,
             LoanApiConstants.emiAmountParameterName, LoanApiConstants.maxOutstandingBalanceParameterName,
             LoanProductConstants.graceOnArrearsAgeingParameterName, LoanApiConstants.createStandingInstructionAtDisbursementParameterName,
-            LoanApiConstants.isTopup, LoanApiConstants.loanIdToClose, LoanApiConstants.datatables, LoanApiConstants.isEqualAmortizationParam, LoanProductConstants.ratesParamName));
+            LoanApiConstants.isTopup, LoanApiConstants.loanIdToClose, LoanApiConstants.datatables, LoanApiConstants.isEqualAmortizationParam,LoanProductConstants.ratesParamName,
+            LoanApiConstants.applicationId,                   // glim specific

Review comment:
       let us revisit this when we have UI. 

##########
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:
       you can ignore this.

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/SavingsAccountReadPlatformServiceImpl.java
##########
@@ -789,7 +789,7 @@ public SavingsAccountTransactionsMapper() {
             sqlBuilder.append("tr.created_date as submittedOnDate,");
             sqlBuilder.append(" au.username as submittedByUsername, ");
             sqlBuilder.append(" nt.note as transactionNote, ") ;
-            sqlBuilder.append("tr.running_balance_derived as runningBalance, tr.is_reversed as reversed,");
+            sqlBuilder.append("tr.running_balance_derived as runningBalance, tr.is_reversed as reversed,tr.is_loan_disbursement as isLoanDisbursement,");

Review comment:
       did you get a chance to look in to this?

##########
File path: fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java
##########
@@ -365,11 +387,106 @@ public CommandProcessingResult submitApplication(final JsonCommand command) {
                 createAndPersistCalendarInstanceForInterestRecalculation(newLoanApplication);
             }
 
+
+            // loan account number generation
+            String accountNumber="";
+            GroupLoanIndividualMonitoringAccount glimAccount;
+            BigDecimal applicationId=BigDecimal.ZERO;
+            Boolean isLastChildApplication=false;
+
+
             if (newLoanApplication.isAccountNumberRequiresAutoGeneration()) {
-                final AccountNumberFormat accountNumberFormat = this.accountNumberFormatRepository
-                        .findByAccountType(EntityAccountType.LOAN);
-                newLoanApplication.updateAccountNo(this.accountNumberGenerator.generate(newLoanApplication, accountNumberFormat));
-                this.loanRepositoryWrapper.save(newLoanApplication);
+
+                 final AccountNumberFormat accountNumberFormat = this.accountNumberFormatRepository.findByAccountType(EntityAccountType.LOAN);
+                // if application is of GLIM type
+                if(newLoanApplication.getLoanType()==4)
+                {
+                    Group group= this.groupRepository.findOneWithNotFoundDetection(groupId);
+
+                    //GLIM specific parameters
+                    if(command.bigDecimalValueOfParameterNamedDefaultToNullIfZero("applicationId")!=null)
+                    {
+                        applicationId=command.bigDecimalValueOfParameterNamedDefaultToNullIfZero("applicationId");
+                    }
+
+                    if(command.booleanObjectValueOfParameterNamed("lastApplication")!=null)
+                    {
+                        isLastChildApplication=command.booleanPrimitiveValueOfParameterNamed("lastApplication");
+                    }
+
+                    if(command.booleanObjectValueOfParameterNamed("isParentAccount")!=null)
+                    {
+
+                        //empty table check
+                            if(glimRepository.count()!=0)
+                            {
+                                //**************Parent-Not an empty table********************
+                                accountNumber=this.accountNumberGenerator.generate(newLoanApplication, accountNumberFormat);
+                                newLoanApplication.updateAccountNo(accountNumber+"-1");
+                                glimAccountInfoWritePlatformService.addGLIMAccountInfo(accountNumber,group, command.bigDecimalValueOfParameterNamedDefaultToNullIfZero("totalLoan"),Long.valueOf(1),true,
+                                        LoanStatus.SUBMITTED_AND_PENDING_APPROVAL.getValue(),applicationId);
+                                newLoanApplication.setGlim(glimRepository.findOneByAccountNumber(accountNumber));
+                                 this.loanRepositoryWrapper.save(newLoanApplication);
+
+                            }
+                            else
+                            {
+                                //************** Parent-empty table********************
+
+                                accountNumber=this.accountNumberGenerator.generate(newLoanApplication, accountNumberFormat);

Review comment:
       we will revisit this later.




----------------------------------------------------------------
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:
users@infra.apache.org