add state transitions around loan to api.
This commit is contained in:
@@ -5,7 +5,6 @@ import org.mifosng.data.LoanRepaymentData;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.UndoLoanApprovalCommand;
|
||||
import org.mifosng.data.command.UndoLoanDisbursalCommand;
|
||||
import org.springframework.security.oauth.consumer.ProtectedResourceDetails;
|
||||
|
||||
@@ -15,16 +14,6 @@ public interface CommonRestOperations {
|
||||
|
||||
void updateProtectedResource(ProtectedResourceDetails loadProtectedResourceDetailsById);
|
||||
|
||||
EntityIdentifier deleteLoan(Long loanId);
|
||||
|
||||
EntityIdentifier approveLoan(LoanStateTransitionCommand command);
|
||||
|
||||
EntityIdentifier undoLoanApproval(UndoLoanApprovalCommand command);
|
||||
|
||||
EntityIdentifier rejectLoan(LoanStateTransitionCommand command);
|
||||
|
||||
EntityIdentifier withdrawLoan(LoanStateTransitionCommand command);
|
||||
|
||||
EntityIdentifier disburseLoan(LoanStateTransitionCommand command);
|
||||
|
||||
EntityIdentifier undloLoanDisbursal(UndoLoanDisbursalCommand command);
|
||||
|
||||
+1
-91
@@ -99,97 +99,7 @@ public class CommonRestOperationsImpl implements CommonRestOperations {
|
||||
}
|
||||
return errorList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier deleteLoan(Long loanId) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/loan/").concat(loanId.toString()));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate
|
||||
.exchange(restUri, HttpMethod.DELETE, null,
|
||||
EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier approveLoan(final LoanStateTransitionCommand command) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/loan/approve"));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate
|
||||
.postForEntity(restUri,
|
||||
loanStateTransitionApplicationRequest(command),
|
||||
EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier undoLoanApproval(
|
||||
final UndoLoanApprovalCommand command) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/loan/undoapproval"));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate
|
||||
.postForEntity(restUri, undoLoanApprovalRequest(command),
|
||||
EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier rejectLoan(final LoanStateTransitionCommand command) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/loan/reject"));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate
|
||||
.postForEntity(restUri,
|
||||
loanStateTransitionApplicationRequest(command),
|
||||
EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityIdentifier withdrawLoan(
|
||||
final LoanStateTransitionCommand command) {
|
||||
try {
|
||||
URI restUri = URI.create(getBaseServerUrl().concat(
|
||||
"api/protected/loan/withdraw"));
|
||||
|
||||
ResponseEntity<EntityIdentifier> s = this.oauthRestServiceTemplate
|
||||
.postForEntity(restUri,
|
||||
loanStateTransitionApplicationRequest(command),
|
||||
EntityIdentifier.class);
|
||||
|
||||
return s.getBody();
|
||||
} catch (HttpStatusCodeException e) {
|
||||
ErrorResponseList errorList = parseErrors(e);
|
||||
throw new ClientValidationException(errorList.getErrors());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public EntityIdentifier disburseLoan(
|
||||
final LoanStateTransitionCommand command) {
|
||||
|
||||
-60
@@ -19,7 +19,6 @@ import org.mifosng.data.LoanRepaymentData;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.UndoLoanApprovalCommand;
|
||||
import org.mifosng.data.command.UndoLoanDisbursalCommand;
|
||||
import org.mifosng.ui.CommonRestOperations;
|
||||
import org.mifosng.ui.loanproduct.ClientValidationException;
|
||||
@@ -97,65 +96,6 @@ public class LoanTransactionController {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/portfolio/loan/{loanId}/delete", method = RequestMethod.POST)
|
||||
public @ResponseBody EntityIdentifier deleteLoan(@PathVariable("loanId") final Long loanId) {
|
||||
|
||||
return this.commonRestOperations.deleteLoan(loanId);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/loan/{loanId}/approve", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier approveLoan(
|
||||
@PathVariable("loanId") final Long loanId,
|
||||
@RequestParam(value="eventDate", required=false) String eventDate,
|
||||
@RequestParam(value="comment", required=false) String comment) {
|
||||
|
||||
LocalDate approvalDate = parseStringToLocalDate(eventDate, "eventDate");
|
||||
|
||||
LoanStateTransitionCommand command = new LoanStateTransitionCommand(loanId, approvalDate, comment);
|
||||
|
||||
return this.commonRestOperations.approveLoan(command);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/portfolio/loan/{loanId}/undoapproval", method = RequestMethod.POST)
|
||||
public String undoLoanApproval(@PathVariable("loanId") final Long loanId) {
|
||||
|
||||
UndoLoanApprovalCommand command = new UndoLoanApprovalCommand(loanId);
|
||||
|
||||
EntityIdentifier clientAccountId = this.commonRestOperations
|
||||
.undoLoanApproval(command);
|
||||
|
||||
return "redirect:/portfolio/client/" + clientAccountId.getEntityId();
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/loan/{loanId}/reject", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier rejectLoan(
|
||||
@PathVariable("loanId") final Long loanId,
|
||||
@RequestParam(value="eventDate", required=false) String eventDate,
|
||||
@RequestParam(value="comment", required=false) String comment) {
|
||||
|
||||
LocalDate rejectionDate = parseStringToLocalDate(eventDate, "eventDate");
|
||||
|
||||
LoanStateTransitionCommand command = new LoanStateTransitionCommand(loanId, rejectionDate, comment);
|
||||
|
||||
return this.commonRestOperations.rejectLoan(command);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/loan/{loanId}/withdraw", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier loanWithdrawnByClient(
|
||||
@PathVariable("loanId") final Long loanId,
|
||||
@RequestParam(value="eventDate", required=false) String eventDate,
|
||||
@RequestParam(value="comment", required=false) String comment) {
|
||||
|
||||
LocalDate withdrawnOnDate = parseStringToLocalDate(eventDate, "eventDate");
|
||||
|
||||
LoanStateTransitionCommand command = new LoanStateTransitionCommand(loanId, withdrawnOnDate, comment);
|
||||
|
||||
return this.commonRestOperations.withdrawLoan(command);
|
||||
}
|
||||
|
||||
@RequestMapping(consumes="application/x-www-form-urlencoded", produces="application/json", value = "/portfolio/loan/{loanId}/disburse", method = RequestMethod.POST)
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
public @ResponseBody EntityIdentifier disburseLoan(
|
||||
|
||||
Reference in New Issue
Block a user