move functionality around new loan application to loan resource.
This commit is contained in:
@@ -6,7 +6,6 @@ import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.LoanProductData;
|
||||
import org.mifosng.data.LoanRepaymentData;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.NewLoanWorkflowStepOneData;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
@@ -26,8 +25,6 @@ public interface CommonRestOperations {
|
||||
|
||||
LoanSchedule calculateLoanSchedule(CalculateLoanScheduleCommand command);
|
||||
|
||||
NewLoanWorkflowStepOneData retrieveNewLoanApplicationStepOneDetails(Long clientId);
|
||||
|
||||
Long submitLoanApplication(SubmitLoanApplicationCommand command);
|
||||
|
||||
EntityIdentifier deleteLoan(Long loanId);
|
||||
@@ -55,6 +52,4 @@ public interface CommonRestOperations {
|
||||
LoanRepaymentData retrieveNewLoanWaiverDetails(Long loanId);
|
||||
|
||||
EntityIdentifier waiveLoanAmount(LoanTransactionCommand command);
|
||||
|
||||
NewLoanWorkflowStepOneData retrieveNewLoanApplicationDetails(Long clientId, Long productId);
|
||||
}
|
||||
-44
@@ -14,7 +14,6 @@ import org.mifosng.data.LoanProductData;
|
||||
import org.mifosng.data.LoanProductList;
|
||||
import org.mifosng.data.LoanRepaymentData;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.NewLoanWorkflowStepOneData;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
@@ -138,49 +137,6 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewLoanWorkflowStepOneData retrieveNewLoanApplicationStepOneDetails(
|
||||
final Long clientId) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/loan/new/" + clientId.toString()
|
||||
+ "/workflow/one"));
|
||||
|
||||
ResponseEntity<NewLoanWorkflowStepOneData> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
NewLoanWorkflowStepOneData.class);
|
||||
|
||||
// for now ensure user must select product on step one (even if
|
||||
// there is only one product!)
|
||||
NewLoanWorkflowStepOneData data = s.getBody();
|
||||
data.setProductId(null);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public NewLoanWorkflowStepOneData retrieveNewLoanApplicationDetails(
|
||||
Long clientId, Long productId) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/loan/new/" + clientId.toString()
|
||||
+ "/product/" + productId.toString()));
|
||||
|
||||
ResponseEntity<NewLoanWorkflowStepOneData> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.GET, emptyRequest(),
|
||||
NewLoanWorkflowStepOneData.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long submitLoanApplication(final SubmitLoanApplicationCommand command) {
|
||||
try {
|
||||
|
||||
+18
@@ -1,8 +1,12 @@
|
||||
package org.mifosng.ui.admin;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
import org.mifosng.oauth.ConsumerUserDetails;
|
||||
import org.mifosng.ui.reporting.ReportingRestOperations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
@@ -71,4 +75,18 @@ public class ApplicationPagesRoutesController {
|
||||
public String userSettingsScreen() {
|
||||
return "admin/accountsettings";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/portfolio/client/{clientId}/loan/new", method = RequestMethod.GET)
|
||||
public String loadLoanCreationWorkflow(final Model model, @PathVariable("clientId") final Long clientId, final Principal principal) {
|
||||
|
||||
UsernamePasswordAuthenticationToken authenticationToken = (UsernamePasswordAuthenticationToken) principal;
|
||||
ConsumerUserDetails user = (ConsumerUserDetails) authenticationToken.getPrincipal();
|
||||
if (user.hasNoAuthorityToSumitLoanApplication()) {
|
||||
throw new AccessDeniedException("");
|
||||
}
|
||||
|
||||
model.addAttribute("clientId", clientId);
|
||||
|
||||
return "newloanapplication";
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.mifosng.ui.loan;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.security.Principal;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.ArrayList;
|
||||
@@ -17,20 +16,15 @@ import org.joda.time.format.DateTimeFormat;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.ErrorResponse;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.NewLoanWorkflowStepOneData;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.oauth.ConsumerUserDetails;
|
||||
import org.mifosng.ui.CommonRestOperations;
|
||||
import org.mifosng.ui.loanproduct.ClientValidationException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.i18n.LocaleContextHolder;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -97,20 +91,6 @@ public class LoanController {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/portfolio/client/{clientId}/loan/new", method = RequestMethod.GET)
|
||||
public String loadLoanCreationWorkflow(final Model model, @PathVariable("clientId") final Long clientId, final Principal principal) {
|
||||
|
||||
UsernamePasswordAuthenticationToken authenticationToken = (UsernamePasswordAuthenticationToken) principal;
|
||||
ConsumerUserDetails user = (ConsumerUserDetails) authenticationToken.getPrincipal();
|
||||
if (user.hasNoAuthorityToSumitLoanApplication()) {
|
||||
throw new AccessDeniedException("");
|
||||
}
|
||||
|
||||
model.addAttribute("clientId", clientId);
|
||||
|
||||
return "newloanapplication";
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/client/{clientId}/loan/new", method = RequestMethod.POST)
|
||||
public @ResponseBody EntityIdentifier submitNewLoanApplication(
|
||||
@RequestParam(value="clientId", required=false) Long applicantId,
|
||||
@@ -196,16 +176,4 @@ public class LoanController {
|
||||
|
||||
return this.commonRestOperations.calculateLoanSchedule(command);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/client/{clientId}/product/{productId}/new", method = RequestMethod.GET)
|
||||
public @ResponseBody NewLoanWorkflowStepOneData retrieveNewLoan(@PathVariable("clientId") Long clientId, @PathVariable("productId") Long productId) {
|
||||
|
||||
return this.commonRestOperations.retrieveNewLoanApplicationDetails(clientId, productId);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/json", produces="application/json", value = "/portfolio/client/{clientId}/loan/new/workflow/one", method = RequestMethod.GET)
|
||||
public @ResponseBody NewLoanWorkflowStepOneData retrieveNewLoan(@PathVariable("clientId") Long clientId) {
|
||||
|
||||
return this.commonRestOperations.retrieveNewLoanApplicationStepOneDetails(clientId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user