WIP filtering loans
This commit is contained in:
@@ -11,7 +11,7 @@ import org.joda.time.LocalDate;
|
|||||||
import org.joda.time.Months;
|
import org.joda.time.Months;
|
||||||
|
|
||||||
@XmlRootElement(name = "loan")
|
@XmlRootElement(name = "loan")
|
||||||
@JsonFilter("myFilter")
|
@JsonFilter("loanFilter")
|
||||||
public class LoanAccountData {
|
public class LoanAccountData {
|
||||||
|
|
||||||
private boolean open;
|
private boolean open;
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ package org.mifosng.data;
|
|||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
|
||||||
|
import org.codehaus.jackson.map.annotate.JsonFilter;
|
||||||
import org.joda.time.DateMidnight;
|
import org.joda.time.DateMidnight;
|
||||||
import org.joda.time.Days;
|
import org.joda.time.Days;
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
|
||||||
@XmlRootElement
|
@XmlRootElement
|
||||||
|
@JsonFilter("loanRepaymentFilter")
|
||||||
public class LoanRepaymentData {
|
public class LoanRepaymentData {
|
||||||
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|||||||
@@ -45,214 +45,307 @@ import org.springframework.stereotype.Component;
|
|||||||
@Scope("singleton")
|
@Scope("singleton")
|
||||||
public class LoansApiResource {
|
public class LoansApiResource {
|
||||||
|
|
||||||
private String allowedFieldList = "";
|
|
||||||
private String filterName = "myFilter";
|
private String filterName = "myFilter";
|
||||||
|
private String allowedFieldList = "";
|
||||||
@Autowired
|
|
||||||
private LoanReadPlatformService loanReadPlatformService;
|
@Autowired
|
||||||
|
private LoanReadPlatformService loanReadPlatformService;
|
||||||
@Autowired
|
|
||||||
private LoanWritePlatformService loanWritePlatformService;
|
@Autowired
|
||||||
|
private LoanWritePlatformService loanWritePlatformService;
|
||||||
@Autowired
|
|
||||||
|
@Autowired
|
||||||
private CalculationPlatformService calculationPlatformService;
|
private CalculationPlatformService calculationPlatformService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiDataConversionService apiDataConversionService;
|
private ApiDataConversionService apiDataConversionService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApiJSONFormattingService jsonFormattingService;
|
private ApiJSONFormattingService jsonFormattingService;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("template")
|
@Path("template")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@Produces({ MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveDetailsForNewLoanApplicationStepOne(@QueryParam("clientId") final Long clientId, @QueryParam("productId") final Long productId, @Context UriInfo uriInfo) {
|
public String retrieveDetailsForNewLoanApplicationStepOne(
|
||||||
|
@QueryParam("clientId") final Long clientId,
|
||||||
|
@QueryParam("productId") final Long productId,
|
||||||
|
@Context UriInfo uriInfo) {
|
||||||
|
|
||||||
NewLoanWorkflowStepOneData workflowData = this.loanReadPlatformService.retrieveClientAndProductDetails(clientId, productId);
|
NewLoanWorkflowStepOneData workflowData = this.loanReadPlatformService
|
||||||
|
.retrieveClientAndProductDetails(clientId, productId);
|
||||||
|
|
||||||
String selectedFields = "";
|
String selectedFields = "";
|
||||||
return this.jsonFormattingService.convertRequest(workflowData, filterName,
|
return this.jsonFormattingService.convertRequest(workflowData,
|
||||||
allowedFieldList, selectedFields, uriInfo.getQueryParameters());
|
filterName, allowedFieldList, selectedFields,
|
||||||
|
uriInfo.getQueryParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{loanId}")
|
@Path("{loanId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@Produces({ MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveLoanAccountDetails(@PathParam("loanId") final Long loanId, @Context UriInfo uriInfo) {
|
public String retrieveLoanAccountDetails(
|
||||||
|
@PathParam("loanId") final Long loanId, @Context UriInfo uriInfo) {
|
||||||
|
|
||||||
LoanAccountData loanAccount = this.loanReadPlatformService.retrieveLoanAccountDetails(loanId);
|
LoanAccountData loanAccount = this.loanReadPlatformService
|
||||||
|
.retrieveLoanAccountDetails(loanId);
|
||||||
|
|
||||||
|
String specificFilterName = "loanFilter";
|
||||||
String selectedFields = "";
|
String selectedFields = "";
|
||||||
return this.jsonFormattingService.convertRequest(loanAccount, filterName,
|
return this.jsonFormattingService.convertRequest(loanAccount,
|
||||||
allowedFieldList, selectedFields, uriInfo.getQueryParameters());
|
specificFilterName, allowedFieldList, selectedFields,
|
||||||
|
uriInfo.getQueryParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
|
||||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
|
||||||
public Response calculateLoanSchedule(@QueryParam("command") final String commandParam, final SubmitLoanApplicationCommand command) {
|
|
||||||
|
|
||||||
LocalDate expectedDisbursementDate = apiDataConversionService.convertFrom(command.getExpectedDisbursementDateFormatted(), "expectedDisbursementDateFormatted", command.getDateFormat());
|
@POST
|
||||||
LocalDate repaymentsStartingFromDate = apiDataConversionService.convertFrom(command.getRepaymentsStartingFromDateFormatted(), "repaymentsStartingFromDateFormatted", command.getDateFormat());
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
LocalDate interestCalculatedFromDate = apiDataConversionService.convertFrom(command.getInterestCalculatedFromDateFormatted(), "interestCalculatedFromDateFormatted", command.getDateFormat());
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
LocalDate submittedOnDate = apiDataConversionService.convertFrom(command.getSubmittedOnDateFormatted(), "submittedOnDateFormatted", command.getDateFormat());
|
public Response calculateLoanSchedule(
|
||||||
|
@QueryParam("command") final String commandParam,
|
||||||
|
final SubmitLoanApplicationCommand command) {
|
||||||
|
|
||||||
|
LocalDate expectedDisbursementDate = apiDataConversionService
|
||||||
|
.convertFrom(command.getExpectedDisbursementDateFormatted(),
|
||||||
|
"expectedDisbursementDateFormatted",
|
||||||
|
command.getDateFormat());
|
||||||
|
LocalDate repaymentsStartingFromDate = apiDataConversionService
|
||||||
|
.convertFrom(command.getRepaymentsStartingFromDateFormatted(),
|
||||||
|
"repaymentsStartingFromDateFormatted",
|
||||||
|
command.getDateFormat());
|
||||||
|
LocalDate interestCalculatedFromDate = apiDataConversionService
|
||||||
|
.convertFrom(command.getInterestCalculatedFromDateFormatted(),
|
||||||
|
"interestCalculatedFromDateFormatted",
|
||||||
|
command.getDateFormat());
|
||||||
|
LocalDate submittedOnDate = apiDataConversionService.convertFrom(
|
||||||
|
command.getSubmittedOnDateFormatted(),
|
||||||
|
"submittedOnDateFormatted", command.getDateFormat());
|
||||||
command.setExpectedDisbursementDate(expectedDisbursementDate);
|
command.setExpectedDisbursementDate(expectedDisbursementDate);
|
||||||
command.setRepaymentsStartingFromDate(repaymentsStartingFromDate);
|
command.setRepaymentsStartingFromDate(repaymentsStartingFromDate);
|
||||||
command.setInterestCalculatedFromDate(interestCalculatedFromDate);
|
command.setInterestCalculatedFromDate(interestCalculatedFromDate);
|
||||||
command.setSubmittedOnDate(submittedOnDate);
|
command.setSubmittedOnDate(submittedOnDate);
|
||||||
|
|
||||||
// FIXME - pass in locale through query string or in 'request body'
|
// FIXME - pass in locale through query string or in 'request body'
|
||||||
Locale clientApplicationLocale = Locale.UK;
|
Locale clientApplicationLocale = Locale.UK;
|
||||||
BigDecimal principal = this.apiDataConversionService.convertFrom(command.getPrincipalFormatted(), "principalFormatted", clientApplicationLocale);
|
BigDecimal principal = this.apiDataConversionService.convertFrom(
|
||||||
BigDecimal interestRatePerPeriod = this.apiDataConversionService.convertFrom(command.getInterestRatePerPeriodFormatted(), "interestRatePerPeriodFormatted", clientApplicationLocale);
|
command.getPrincipalFormatted(), "principalFormatted",
|
||||||
BigDecimal inArrearsToleranceAmount = this.apiDataConversionService.convertFrom(command.getInArrearsToleranceAmountFormatted(), "inArrearsToleranceAmountFormatted", clientApplicationLocale);
|
clientApplicationLocale);
|
||||||
|
BigDecimal interestRatePerPeriod = this.apiDataConversionService
|
||||||
|
.convertFrom(command.getInterestRatePerPeriodFormatted(),
|
||||||
|
"interestRatePerPeriodFormatted",
|
||||||
|
clientApplicationLocale);
|
||||||
|
BigDecimal inArrearsToleranceAmount = this.apiDataConversionService
|
||||||
|
.convertFrom(command.getInArrearsToleranceAmountFormatted(),
|
||||||
|
"inArrearsToleranceAmountFormatted",
|
||||||
|
clientApplicationLocale);
|
||||||
command.setPrincipal(principal);
|
command.setPrincipal(principal);
|
||||||
command.setInterestRatePerPeriod(interestRatePerPeriod);
|
command.setInterestRatePerPeriod(interestRatePerPeriod);
|
||||||
command.setInArrearsToleranceAmount(inArrearsToleranceAmount);
|
command.setInArrearsToleranceAmount(inArrearsToleranceAmount);
|
||||||
|
|
||||||
CalculateLoanScheduleCommand calculateLoanScheduleCommand = command.toCalculateLoanScheduleCommand();
|
CalculateLoanScheduleCommand calculateLoanScheduleCommand = command
|
||||||
LoanSchedule loanSchedule = this.calculationPlatformService.calculateLoanSchedule(calculateLoanScheduleCommand);
|
.toCalculateLoanScheduleCommand();
|
||||||
|
LoanSchedule loanSchedule = this.calculationPlatformService
|
||||||
// for now just auto generating the loan schedule and setting support for 'manual' loan schedule creation later.
|
.calculateLoanSchedule(calculateLoanScheduleCommand);
|
||||||
|
|
||||||
|
// for now just auto generating the loan schedule and setting support
|
||||||
|
// for 'manual' loan schedule creation later.
|
||||||
command.setLoanSchedule(loanSchedule);
|
command.setLoanSchedule(loanSchedule);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase("calculateLoanSchedule")) {
|
|
||||||
|
|
||||||
return Response.ok().entity(loanSchedule).build();
|
if (StringUtils.isNotBlank(commandParam)
|
||||||
|
&& commandParam.trim()
|
||||||
|
.equalsIgnoreCase("calculateLoanSchedule")) {
|
||||||
|
|
||||||
|
return Response.ok().entity(loanSchedule).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityIdentifier identifier = this.loanWritePlatformService.submitLoanApplication(command);
|
|
||||||
|
|
||||||
return Response.ok().entity(identifier).build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@DELETE
|
|
||||||
@Path("{loanId}")
|
|
||||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
|
||||||
@Produces({ MediaType.APPLICATION_JSON})
|
|
||||||
public Response deleteLoanApplication(@PathParam("loanId") final Long loanId) {
|
|
||||||
|
|
||||||
EntityIdentifier identifier = this.loanWritePlatformService.deleteLoan(loanId);
|
EntityIdentifier identifier = this.loanWritePlatformService
|
||||||
|
.submitLoanApplication(command);
|
||||||
|
|
||||||
return Response.ok().entity(identifier).build();
|
return Response.ok().entity(identifier).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DELETE
|
||||||
|
@Path("{loanId}")
|
||||||
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
|
public Response deleteLoanApplication(@PathParam("loanId") final Long loanId) {
|
||||||
|
|
||||||
|
EntityIdentifier identifier = this.loanWritePlatformService
|
||||||
|
.deleteLoan(loanId);
|
||||||
|
|
||||||
|
return Response.ok().entity(identifier).build();
|
||||||
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{loanId}")
|
@Path("{loanId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@Produces({ MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response stateTransitions(@PathParam("loanId") final Long loanId,
|
public Response stateTransitions(@PathParam("loanId") final Long loanId,
|
||||||
@QueryParam("command") final String commandParam,
|
@QueryParam("command") final String commandParam,
|
||||||
final LoanStateTransitionCommand command) {
|
final LoanStateTransitionCommand command) {
|
||||||
|
|
||||||
LocalDate eventDate = this.apiDataConversionService.convertFrom(command.getEventDateFormatted(), "eventDateFormatted", command.getDateFormat());
|
LocalDate eventDate = this.apiDataConversionService.convertFrom(
|
||||||
|
command.getEventDateFormatted(), "eventDateFormatted",
|
||||||
|
command.getDateFormat());
|
||||||
|
|
||||||
command.setLoanId(loanId);
|
command.setLoanId(loanId);
|
||||||
command.setEventDate(eventDate);
|
command.setEventDate(eventDate);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase("reject")) {
|
if (StringUtils.isNotBlank(commandParam)
|
||||||
EntityIdentifier identifier = this.loanWritePlatformService.rejectLoan(command);
|
&& commandParam.trim().equalsIgnoreCase("reject")) {
|
||||||
|
EntityIdentifier identifier = this.loanWritePlatformService
|
||||||
|
.rejectLoan(command);
|
||||||
return Response.ok().entity(identifier).build();
|
return Response.ok().entity(identifier).build();
|
||||||
} else if (StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase("withdrewbyclient")) {
|
} else if (StringUtils.isNotBlank(commandParam)
|
||||||
EntityIdentifier identifier = this.loanWritePlatformService.withdrawLoan(command);
|
&& commandParam.trim().equalsIgnoreCase("withdrewbyclient")) {
|
||||||
|
EntityIdentifier identifier = this.loanWritePlatformService
|
||||||
|
.withdrawLoan(command);
|
||||||
return Response.ok().entity(identifier).build();
|
return Response.ok().entity(identifier).build();
|
||||||
} else if (StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase("approve")) {
|
} else if (StringUtils.isNotBlank(commandParam)
|
||||||
EntityIdentifier identifier = this.loanWritePlatformService.approveLoanApplication(command);
|
&& commandParam.trim().equalsIgnoreCase("approve")) {
|
||||||
|
EntityIdentifier identifier = this.loanWritePlatformService
|
||||||
|
.approveLoanApplication(command);
|
||||||
return Response.ok().entity(identifier).build();
|
return Response.ok().entity(identifier).build();
|
||||||
} else if (StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase("disburse")) {
|
} else if (StringUtils.isNotBlank(commandParam)
|
||||||
EntityIdentifier identifier = this.loanWritePlatformService.disburseLoan(command);
|
&& commandParam.trim().equalsIgnoreCase("disburse")) {
|
||||||
|
EntityIdentifier identifier = this.loanWritePlatformService
|
||||||
|
.disburseLoan(command);
|
||||||
return Response.ok().entity(identifier).build();
|
return Response.ok().entity(identifier).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{loanId}/undo")
|
@Path("{loanId}/undo")
|
||||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response undoStateTransitions(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam) {
|
public Response undoStateTransitions(
|
||||||
|
@PathParam("loanId") final Long loanId,
|
||||||
if (StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase("undoapproval")) {
|
@QueryParam("command") final String commandParam) {
|
||||||
UndoLoanApprovalCommand undoCommand = new UndoLoanApprovalCommand(loanId);
|
|
||||||
EntityIdentifier identifier = this.loanWritePlatformService.undoLoanApproval(undoCommand);
|
if (StringUtils.isNotBlank(commandParam)
|
||||||
|
&& commandParam.trim().equalsIgnoreCase("undoapproval")) {
|
||||||
|
UndoLoanApprovalCommand undoCommand = new UndoLoanApprovalCommand(
|
||||||
|
loanId);
|
||||||
|
EntityIdentifier identifier = this.loanWritePlatformService
|
||||||
|
.undoLoanApproval(undoCommand);
|
||||||
return Response.ok().entity(identifier).build();
|
return Response.ok().entity(identifier).build();
|
||||||
} else if (StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase("undodisbursal")) {
|
} else if (StringUtils.isNotBlank(commandParam)
|
||||||
UndoLoanDisbursalCommand undoCommand = new UndoLoanDisbursalCommand(loanId);
|
&& commandParam.trim().equalsIgnoreCase("undodisbursal")) {
|
||||||
EntityIdentifier identifier = this.loanWritePlatformService.undloLoanDisbursal(undoCommand);
|
UndoLoanDisbursalCommand undoCommand = new UndoLoanDisbursalCommand(
|
||||||
|
loanId);
|
||||||
|
EntityIdentifier identifier = this.loanWritePlatformService
|
||||||
|
.undloLoanDisbursal(undoCommand);
|
||||||
return Response.ok().entity(identifier).build();
|
return Response.ok().entity(identifier).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Response.ok().build();
|
return Response.ok().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{loanId}/transactions")
|
@Path("{loanId}/transactions")
|
||||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response executeLoanTransaction(@PathParam("loanId") final Long loanId, @QueryParam("transactionType") final String transactionType, final LoanTransactionCommand command) {
|
public Response executeLoanTransaction(
|
||||||
|
@PathParam("loanId") final Long loanId,
|
||||||
|
@QueryParam("transactionType") final String transactionType,
|
||||||
|
final LoanTransactionCommand command) {
|
||||||
|
|
||||||
command.setLoanId(loanId);
|
command.setLoanId(loanId);
|
||||||
|
|
||||||
LocalDate transactionDate = apiDataConversionService.convertFrom(command.getTransactionDateFormatted(), "transactionDateFormatted", command.getDateFormat());
|
LocalDate transactionDate = apiDataConversionService.convertFrom(
|
||||||
|
command.getTransactionDateFormatted(),
|
||||||
|
"transactionDateFormatted", command.getDateFormat());
|
||||||
command.setTransactionDate(transactionDate);
|
command.setTransactionDate(transactionDate);
|
||||||
|
|
||||||
BigDecimal transactionAmount = apiDataConversionService.convertFrom(command.getTransactionAmountFormatted(), "transactionAmountFormatted", Locale.UK);
|
BigDecimal transactionAmount = apiDataConversionService.convertFrom(
|
||||||
|
command.getTransactionAmountFormatted(),
|
||||||
|
"transactionAmountFormatted", Locale.UK);
|
||||||
command.setTransactionAmount(transactionAmount);
|
command.setTransactionAmount(transactionAmount);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(transactionType) && transactionType.trim().equalsIgnoreCase("waiver")) {
|
if (StringUtils.isNotBlank(transactionType)
|
||||||
EntityIdentifier identifier = this.loanWritePlatformService.waiveLoanAmount(command);
|
&& transactionType.trim().equalsIgnoreCase("waiver")) {
|
||||||
|
EntityIdentifier identifier = this.loanWritePlatformService
|
||||||
|
.waiveLoanAmount(command);
|
||||||
return Response.ok().entity(identifier).build();
|
return Response.ok().entity(identifier).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityIdentifier identifier = this.loanWritePlatformService.makeLoanRepayment(command);
|
EntityIdentifier identifier = this.loanWritePlatformService
|
||||||
|
.makeLoanRepayment(command);
|
||||||
return Response.ok().entity(identifier).build();
|
return Response.ok().entity(identifier).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{loanId}/transactions/template")
|
@Path("{loanId}/transactions/template")
|
||||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response retrieveNewRepaymentDetails(@PathParam("loanId") final Long loanId, @QueryParam("type") final String transactionType, @Context UriInfo uriInfo) {
|
public String retrieveNewRepaymentDetails(
|
||||||
|
@PathParam("loanId") final Long loanId,
|
||||||
|
@QueryParam("type") final String transactionType,
|
||||||
|
@Context UriInfo uriInfo) {
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(transactionType) && transactionType.trim().equalsIgnoreCase("waiver")) {
|
String specificFilterName = "loanFilter";
|
||||||
LoanRepaymentData loanWaiverData = this.loanReadPlatformService.retrieveNewLoanWaiverDetails(loanId);
|
String selectedFields = "";
|
||||||
return Response.ok().entity(loanWaiverData).build();
|
if (StringUtils.isNotBlank(transactionType)
|
||||||
|
&& transactionType.trim().equalsIgnoreCase("waiver")) {
|
||||||
|
LoanRepaymentData loanWaiverData = this.loanReadPlatformService
|
||||||
|
.retrieveNewLoanWaiverDetails(loanId);
|
||||||
|
return this.jsonFormattingService.convertRequest(loanWaiverData,
|
||||||
|
specificFilterName, allowedFieldList, selectedFields,
|
||||||
|
uriInfo.getQueryParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
LoanRepaymentData loanRepaymentData = this.loanReadPlatformService.retrieveNewLoanRepaymentDetails(loanId);
|
LoanRepaymentData loanRepaymentData = this.loanReadPlatformService
|
||||||
return Response.ok().entity(loanRepaymentData).build();
|
.retrieveNewLoanRepaymentDetails(loanId);
|
||||||
|
return this.jsonFormattingService.convertRequest(loanRepaymentData,
|
||||||
|
specificFilterName, allowedFieldList, selectedFields,
|
||||||
|
uriInfo.getQueryParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{loanId}/transactions/{repaymentId}")
|
@Path("{loanId}/transactions/{repaymentId}")
|
||||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@Produces({MediaType.APPLICATION_JSON})
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public Response retrieveRepaymentDetails(@PathParam("loanId") final Long loanId, @PathParam("repaymentId") final Long repaymentId) {
|
public String retrieveRepaymentDetails(
|
||||||
|
@PathParam("loanId") final Long loanId,
|
||||||
|
@PathParam("repaymentId") final Long repaymentId,
|
||||||
|
@Context UriInfo uriInfo) {
|
||||||
|
|
||||||
LoanRepaymentData loanRepaymentData = this.loanReadPlatformService.retrieveLoanRepaymentDetails(loanId, repaymentId);
|
LoanRepaymentData loanRepaymentData = this.loanReadPlatformService
|
||||||
|
.retrieveLoanRepaymentDetails(loanId, repaymentId);
|
||||||
|
|
||||||
return Response.ok().entity(loanRepaymentData).build();
|
String specificFilterName = "loanFilter";
|
||||||
|
String selectedFields = "";
|
||||||
|
return this.jsonFormattingService.convertRequest(loanRepaymentData,
|
||||||
|
specificFilterName, allowedFieldList, selectedFields,
|
||||||
|
uriInfo.getQueryParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
@PUT
|
||||||
@Path("{loanId}/transactions/{repaymentId}")
|
@Path("{loanId}/transactions/{repaymentId}")
|
||||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||||
public Response adjustLoanTransaction(@PathParam("loanId") final Long loanId, @PathParam("repaymentId") final Long repaymentId, final AdjustLoanTransactionCommand command) {
|
public Response adjustLoanTransaction(
|
||||||
|
@PathParam("loanId") final Long loanId,
|
||||||
|
@PathParam("repaymentId") final Long repaymentId,
|
||||||
|
final AdjustLoanTransactionCommand command) {
|
||||||
|
|
||||||
command.setLoanId(loanId);
|
command.setLoanId(loanId);
|
||||||
command.setRepaymentId(repaymentId);
|
command.setRepaymentId(repaymentId);
|
||||||
|
|
||||||
LocalDate transactionDate = apiDataConversionService.convertFrom(command.getTransactionDateFormatted(), "transactionDateFormatted", command.getDateFormat());
|
LocalDate transactionDate = apiDataConversionService.convertFrom(
|
||||||
|
command.getTransactionDateFormatted(),
|
||||||
|
"transactionDateFormatted", command.getDateFormat());
|
||||||
command.setTransactionDate(transactionDate);
|
command.setTransactionDate(transactionDate);
|
||||||
|
|
||||||
BigDecimal transactionAmount = apiDataConversionService.convertFrom(command.getTransactionAmountFormatted(), "transactionAmountFormatted", Locale.UK);
|
BigDecimal transactionAmount = apiDataConversionService.convertFrom(
|
||||||
|
command.getTransactionAmountFormatted(),
|
||||||
|
"transactionAmountFormatted", Locale.UK);
|
||||||
command.setTransactionAmount(transactionAmount);
|
command.setTransactionAmount(transactionAmount);
|
||||||
|
|
||||||
EntityIdentifier identifier = this.loanWritePlatformService.adjustLoanTransaction(command);
|
EntityIdentifier identifier = this.loanWritePlatformService
|
||||||
|
.adjustLoanTransaction(command);
|
||||||
|
|
||||||
return Response.ok().entity(identifier).build();
|
return Response.ok().entity(identifier).build();
|
||||||
}
|
}
|
||||||
|
|||||||
+57
-37
@@ -121,6 +121,29 @@ public class ApiJSONFormattingServiceImpl implements ApiJSONFormattingService {
|
|||||||
filterFields.add(st.nextToken().trim());
|
filterFields.add(st.nextToken().trim());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (filterName.equals("loanFilter")) {
|
||||||
|
|
||||||
|
Set<String> loanRepaymentFields = new HashSet<String>();
|
||||||
|
|
||||||
|
if (filterType.equals("I")) {
|
||||||
|
return new SimpleFilterProvider().addFilter(
|
||||||
|
filterName,
|
||||||
|
SimpleBeanPropertyFilter
|
||||||
|
.filterOutAllExcept(filterFields)).addFilter(
|
||||||
|
"loanRepaymentFilter",
|
||||||
|
SimpleBeanPropertyFilter
|
||||||
|
.serializeAllExcept(loanRepaymentFields));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return new SimpleFilterProvider().addFilter(filterName,
|
||||||
|
SimpleBeanPropertyFilter.serializeAllExcept(filterFields))
|
||||||
|
.addFilter(
|
||||||
|
"loanRepaymentFilter",
|
||||||
|
SimpleBeanPropertyFilter
|
||||||
|
.serializeAllExcept(loanRepaymentFields));
|
||||||
|
}
|
||||||
|
|
||||||
if (filterName.equals("myFilter")) {
|
if (filterName.equals("myFilter")) {
|
||||||
|
|
||||||
if (filterType.equals("I")) {
|
if (filterType.equals("I")) {
|
||||||
@@ -129,10 +152,9 @@ public class ApiJSONFormattingServiceImpl implements ApiJSONFormattingService {
|
|||||||
.filterOutAllExcept(filterFields));
|
.filterOutAllExcept(filterFields));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SimpleFilterProvider().addFilter(filterName,
|
return new SimpleFilterProvider().addFilter(filterName,
|
||||||
SimpleBeanPropertyFilter
|
SimpleBeanPropertyFilter.serializeAllExcept(filterFields));
|
||||||
.serializeAllExcept(filterFields));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterName.equals("roleFilter")) {
|
if (filterName.equals("roleFilter")) {
|
||||||
@@ -154,17 +176,16 @@ public class ApiJSONFormattingServiceImpl implements ApiJSONFormattingService {
|
|||||||
SimpleBeanPropertyFilter
|
SimpleBeanPropertyFilter
|
||||||
.filterOutAllExcept(permissionFields));
|
.filterOutAllExcept(permissionFields));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SimpleFilterProvider().addFilter(
|
return new SimpleFilterProvider().addFilter(filterName,
|
||||||
filterName,
|
SimpleBeanPropertyFilter.serializeAllExcept(filterFields))
|
||||||
SimpleBeanPropertyFilter
|
.addFilter(
|
||||||
.serializeAllExcept(filterFields)).addFilter(
|
"permissionFilter",
|
||||||
"permissionFilter",
|
SimpleBeanPropertyFilter
|
||||||
SimpleBeanPropertyFilter
|
.filterOutAllExcept(permissionFields));
|
||||||
.filterOutAllExcept(permissionFields));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ADDED BY KEITH - list permissions didnt seem to be working right.
|
// ADDED BY KEITH - list permissions didnt seem to be working right.
|
||||||
// added this to avoid adding null filters to object mapper.
|
// added this to avoid adding null filters to object mapper.
|
||||||
if (filterName.equals("permissionFilter")) {
|
if (filterName.equals("permissionFilter")) {
|
||||||
@@ -174,14 +195,13 @@ public class ApiJSONFormattingServiceImpl implements ApiJSONFormattingService {
|
|||||||
permissionFields.add("description");
|
permissionFields.add("description");
|
||||||
permissionFields.add("code");
|
permissionFields.add("code");
|
||||||
permissionFields.add("groupType");
|
permissionFields.add("groupType");
|
||||||
|
|
||||||
return new SimpleFilterProvider().addFilter(
|
return new SimpleFilterProvider().addFilter(filterName,
|
||||||
filterName,
|
SimpleBeanPropertyFilter.filterOutAllExcept(filterFields))
|
||||||
SimpleBeanPropertyFilter
|
.addFilter(
|
||||||
.filterOutAllExcept(filterFields)).addFilter(
|
"permissionFilter",
|
||||||
"permissionFilter",
|
SimpleBeanPropertyFilter
|
||||||
SimpleBeanPropertyFilter
|
.filterOutAllExcept(permissionFields));
|
||||||
.filterOutAllExcept(permissionFields));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filterName.equals("userFilter")) {
|
if (filterName.equals("userFilter")) {
|
||||||
@@ -216,21 +236,21 @@ public class ApiJSONFormattingServiceImpl implements ApiJSONFormattingService {
|
|||||||
SimpleBeanPropertyFilter
|
SimpleBeanPropertyFilter
|
||||||
.filterOutAllExcept(permissionFields));
|
.filterOutAllExcept(permissionFields));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new SimpleFilterProvider()
|
return new SimpleFilterProvider()
|
||||||
.addFilter(
|
.addFilter(
|
||||||
filterName,
|
filterName,
|
||||||
SimpleBeanPropertyFilter
|
SimpleBeanPropertyFilter
|
||||||
.serializeAllExcept(filterFields))
|
.serializeAllExcept(filterFields))
|
||||||
.addFilter(
|
.addFilter(
|
||||||
"roleFilter",
|
"roleFilter",
|
||||||
SimpleBeanPropertyFilter
|
SimpleBeanPropertyFilter
|
||||||
.filterOutAllExcept(roleFields))
|
.filterOutAllExcept(roleFields))
|
||||||
.addFilter(
|
.addFilter(
|
||||||
"permissionFilter",
|
"permissionFilter",
|
||||||
SimpleBeanPropertyFilter
|
SimpleBeanPropertyFilter
|
||||||
.filterOutAllExcept(permissionFields));
|
.filterOutAllExcept(permissionFields));
|
||||||
|
|
||||||
}
|
}
|
||||||
return filters;
|
return filters;
|
||||||
|
|||||||
Reference in New Issue
Block a user