update commands around client and loan functionality to use json conversion service
This commit is contained in:
@@ -17,7 +17,6 @@ import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.NoteCommand;
|
||||
import org.mifosng.platform.api.data.ClientData;
|
||||
@@ -64,9 +63,9 @@ public class ClientApiResource {
|
||||
private ApiJSONFormattingService jsonFormattingService;
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAllIndividualClients(@Context UriInfo uriInfo,
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveAllIndividualClients(@Context final UriInfo uriInfo,
|
||||
@QueryParam("sqlSearch") final String sqlSearch,
|
||||
@QueryParam("officeId") final Integer officeId,
|
||||
@QueryParam("externalId") final String externalId,
|
||||
@@ -126,11 +125,11 @@ public class ClientApiResource {
|
||||
|
||||
@GET
|
||||
@Path("{clientId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveClientData(
|
||||
@PathParam("clientId") final Long clientId,
|
||||
@QueryParam("template") String template, @Context UriInfo uriInfo) {
|
||||
@QueryParam("template") final String template, @Context final UriInfo uriInfo) {
|
||||
|
||||
ClientData clientData = this.clientReadPlatformService
|
||||
.retrieveIndividualClient(clientId);
|
||||
@@ -148,8 +147,8 @@ public class ClientApiResource {
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String newClientDetails(@Context UriInfo uriInfo) {
|
||||
|
||||
ClientData clientData = this.clientReadPlatformService
|
||||
@@ -162,15 +161,12 @@ public class ClientApiResource {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response enrollClient(final ClientCommand command) {
|
||||
|
||||
LocalDate joiningLocalDate = apiDataConversionService.convertFrom(
|
||||
command.getJoiningDate(), "joiningDate",
|
||||
command.getDateFormat());
|
||||
command.setJoiningLocalDate(joiningLocalDate);
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response enrollClient(final String jsonRequestBody) {
|
||||
|
||||
ClientCommand command = this.apiDataConversionService.convertJsonToClientCommand(null, jsonRequestBody);
|
||||
|
||||
Long clientId = this.clientWritePlatformService.enrollClient(command);
|
||||
|
||||
return Response.ok().entity(new EntityIdentifier(clientId)).build();
|
||||
@@ -178,29 +174,23 @@ public class ClientApiResource {
|
||||
|
||||
@PUT
|
||||
@Path("{clientId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response updateClient(@PathParam("clientId") final Long clientId,
|
||||
final ClientCommand command) {
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateClient(@PathParam("clientId") final Long clientId, final String jsonRequestBody) {
|
||||
|
||||
LocalDate joiningLocalDate = apiDataConversionService.convertFrom(
|
||||
command.getJoiningDate(), "joiningDate",
|
||||
command.getDateFormat());
|
||||
command.setJoiningLocalDate(joiningLocalDate);
|
||||
command.setId(clientId);
|
||||
ClientCommand command = this.apiDataConversionService.convertJsonToClientCommand(clientId, jsonRequestBody);
|
||||
|
||||
EntityIdentifier identifier = this.clientWritePlatformService
|
||||
.updateClientDetails(command);
|
||||
EntityIdentifier identifier = this.clientWritePlatformService.updateClientDetails(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/loans")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveClientAccount(
|
||||
@PathParam("clientId") final Long clientId, @Context UriInfo uriInfo) {
|
||||
@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo) {
|
||||
|
||||
ClientLoanAccountSummaryCollectionData clientAccount = this.clientReadPlatformService
|
||||
.retrieveClientAccountDetails(clientId);
|
||||
@@ -213,10 +203,9 @@ public class ClientApiResource {
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/notes")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveAllClientNotes(
|
||||
@PathParam("clientId") final Long clientId, @Context UriInfo uriInfo) {
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveAllClientNotes(@PathParam("clientId") final Long clientId, @Context final UriInfo uriInfo) {
|
||||
|
||||
Collection<NoteData> notes = this.clientReadPlatformService
|
||||
.retrieveAllClientNotes(clientId);
|
||||
@@ -228,11 +217,9 @@ public class ClientApiResource {
|
||||
|
||||
@POST
|
||||
@Path("{clientId}/notes")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response addNewClientNote(
|
||||
@PathParam("clientId") final Long clientId,
|
||||
final NoteCommand command) {
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response addNewClientNote(@PathParam("clientId") final Long clientId, final NoteCommand command) {
|
||||
|
||||
command.setClientId(clientId);
|
||||
|
||||
@@ -244,11 +231,11 @@ public class ClientApiResource {
|
||||
|
||||
@GET
|
||||
@Path("{clientId}/notes/{noteId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveClientNote(
|
||||
@PathParam("clientId") final Long clientId,
|
||||
@PathParam("noteId") final Long noteId, @Context UriInfo uriInfo) {
|
||||
@PathParam("noteId") final Long noteId, @Context final UriInfo uriInfo) {
|
||||
|
||||
NoteData note = this.clientReadPlatformService.retrieveClientNote(
|
||||
clientId, noteId);
|
||||
@@ -260,8 +247,8 @@ public class ClientApiResource {
|
||||
|
||||
@PUT
|
||||
@Path("{clientId}/notes/{noteId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateClientNote(
|
||||
@PathParam("clientId") final Long clientId,
|
||||
@PathParam("noteId") final Long noteId, final NoteCommand command) {
|
||||
|
||||
@@ -48,7 +48,7 @@ public class FundsApiResource {
|
||||
@GET
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveFunds(@Context UriInfo uriInfo) {
|
||||
public String retrieveFunds(@Context final UriInfo uriInfo) {
|
||||
|
||||
Collection<FundData> funds = this.readPlatformService.retrieveAllFunds();
|
||||
String selectedFields = "";
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
@@ -17,7 +14,6 @@ import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
@@ -69,15 +65,14 @@ public class LoansApiResource {
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveDetailsForNewLoanApplicationStepOne(
|
||||
@QueryParam("clientId") final Long clientId,
|
||||
@QueryParam("productId") final Long productId,
|
||||
@Context UriInfo uriInfo) {
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
NewLoanData workflowData = this.loanReadPlatformService
|
||||
.retrieveClientAndProductDetails(clientId, productId);
|
||||
NewLoanData workflowData = this.loanReadPlatformService.retrieveClientAndProductDetails(clientId, productId);
|
||||
|
||||
String selectedFields = "";
|
||||
return this.jsonFormattingService.convertRequest(workflowData,
|
||||
@@ -87,13 +82,12 @@ public class LoansApiResource {
|
||||
|
||||
@GET
|
||||
@Path("{loanId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveLoanAccountDetails(
|
||||
@PathParam("loanId") final Long loanId, @Context UriInfo uriInfo) {
|
||||
@PathParam("loanId") final Long loanId, @Context final UriInfo uriInfo) {
|
||||
|
||||
LoanAccountData loanAccount = this.loanReadPlatformService
|
||||
.retrieveLoanAccountDetails(loanId);
|
||||
LoanAccountData loanAccount = this.loanReadPlatformService.retrieveLoanAccountDetails(loanId);
|
||||
|
||||
String selectedFields = "";
|
||||
String associatedFields = "summary,repaymentSchedule,loanRepayments,permissions,convenienceData";
|
||||
@@ -103,102 +97,50 @@ public class LoansApiResource {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response calculateLoanScheduleOrSubmitLoanApplication(
|
||||
@QueryParam("command") final String commandParam,
|
||||
final SubmitLoanApplicationCommand command) {
|
||||
final String jsonRequestBody) {
|
||||
|
||||
LocalDate expectedDisbursementLocalDate = apiDataConversionService
|
||||
.convertFrom(command.getExpectedDisbursementDate(),
|
||||
"expectedDisbursementDate", command.getDateFormat());
|
||||
LocalDate repaymentsStartingFromLocalDate = apiDataConversionService
|
||||
.convertFrom(command.getRepaymentsStartingFromDate(),
|
||||
"repaymentsStartingFromDate", command.getDateFormat());
|
||||
LocalDate interestChargedFromLocalDate = apiDataConversionService
|
||||
.convertFrom(command.getInterestChargedFromDate(),
|
||||
"interestChargedFromDate", command.getDateFormat());
|
||||
LocalDate submittedOnLocalDate = apiDataConversionService.convertFrom(
|
||||
command.getSubmittedOnDate(), "submittedOnDate",
|
||||
command.getDateFormat());
|
||||
|
||||
command.setExpectedDisbursementLocalDate(expectedDisbursementLocalDate);
|
||||
command.setRepaymentsStartingFromLocalDate(repaymentsStartingFromLocalDate);
|
||||
command.setInterestChargedFromLocalDate(interestChargedFromLocalDate);
|
||||
command.setSubmittedOnLocalDate(submittedOnLocalDate);
|
||||
|
||||
Locale clientApplicationLocale = this.apiDataConversionService
|
||||
.localeFromString(command.getLocale());
|
||||
BigDecimal principalValue = this.apiDataConversionService.convertFrom(
|
||||
command.getPrincipal(), "principal", clientApplicationLocale);
|
||||
BigDecimal inArrearsToleranceValue = this.apiDataConversionService
|
||||
.convertFrom(command.getInArrearsTolerance(),
|
||||
"inArrearsTolerance", clientApplicationLocale);
|
||||
BigDecimal interestRatePerPeriodValue = this.apiDataConversionService
|
||||
.convertFrom(command.getInterestRatePerPeriod(),
|
||||
"interestRatePerPeriod", clientApplicationLocale);
|
||||
|
||||
Integer repaymentEveryValue = this.apiDataConversionService
|
||||
.convertToInteger(command.getRepaymentEvery(),
|
||||
"repaymentEvery", clientApplicationLocale);
|
||||
Integer numberOfRepaymentsValue = this.apiDataConversionService
|
||||
.convertToInteger(command.getNumberOfRepayments(),
|
||||
"numberOfRepayments", clientApplicationLocale);
|
||||
|
||||
command.setPrincipalValue(principalValue);
|
||||
command.setInArrearsToleranceValue(inArrearsToleranceValue);
|
||||
command.setInterestRatePerPeriodValue(interestRatePerPeriodValue);
|
||||
command.setRepaymentEveryValue(repaymentEveryValue);
|
||||
command.setNumberOfRepaymentsValue(numberOfRepaymentsValue);
|
||||
|
||||
CalculateLoanScheduleCommand calculateLoanScheduleCommand = command
|
||||
.toCalculateLoanScheduleCommand();
|
||||
LoanSchedule loanSchedule = this.calculationPlatformService
|
||||
.calculateLoanSchedule(calculateLoanScheduleCommand);
|
||||
SubmitLoanApplicationCommand command = this.apiDataConversionService.convertJsonToSubmitLoanApplicationCommand(jsonRequestBody);
|
||||
|
||||
CalculateLoanScheduleCommand calculateLoanScheduleCommand = command.toCalculateLoanScheduleCommand();
|
||||
LoanSchedule loanSchedule = this.calculationPlatformService.calculateLoanSchedule(calculateLoanScheduleCommand);
|
||||
|
||||
// for now just auto generating the loan schedule and setting support
|
||||
// for 'manual' loan schedule creation later.
|
||||
command.setLoanSchedule(loanSchedule);
|
||||
|
||||
if (StringUtils.isNotBlank(commandParam)
|
||||
&& commandParam.trim()
|
||||
.equalsIgnoreCase("calculateLoanSchedule")) {
|
||||
|
||||
if (is(commandParam, "calculateLoanSchedule")) {
|
||||
return Response.ok().entity(loanSchedule).build();
|
||||
}
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.submitLoanApplication(command);
|
||||
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 })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response deleteLoanApplication(@PathParam("loanId") final Long loanId) {
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.deleteLoan(loanId);
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.deleteLoan(loanId);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{loanId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response stateTransitions(@PathParam("loanId") final Long loanId,
|
||||
@QueryParam("command") final String commandParam,
|
||||
final LoanStateTransitionCommand command) {
|
||||
|
||||
LocalDate eventLocalDate = this.apiDataConversionService.convertFrom(
|
||||
command.getEventDate(), "eventDate", command.getDateFormat());
|
||||
|
||||
command.setLoanId(loanId);
|
||||
command.setEventLocalDate(eventLocalDate);
|
||||
@QueryParam("command") final String commandParam, final String jsonRequestBody) {
|
||||
|
||||
LoanStateTransitionCommand command = this.apiDataConversionService.convertJsonToLoanStateTransitionCommand(loanId, jsonRequestBody);
|
||||
|
||||
Response response = null;
|
||||
|
||||
if (is(commandParam, "reject")) {
|
||||
@@ -219,8 +161,8 @@ public class LoansApiResource {
|
||||
response = Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
UndoStateTransitionCommand undoCommand = new UndoStateTransitionCommand(
|
||||
loanId, command.getNote());
|
||||
UndoStateTransitionCommand undoCommand = new UndoStateTransitionCommand(loanId, command.getNote());
|
||||
|
||||
if (is(commandParam, "undoapproval")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.undoLoanApproval(undoCommand);
|
||||
@@ -245,36 +187,21 @@ public class LoansApiResource {
|
||||
|
||||
@POST
|
||||
@Path("{loanId}/transactions")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response executeLoanTransaction(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@QueryParam("command") final String commandParam,
|
||||
final LoanTransactionCommand command) {
|
||||
@QueryParam("command") final String commandParam, final String jsonRequestBody) {
|
||||
|
||||
final LoanTransactionCommand command = this.apiDataConversionService.convertJsonToLoanTransactionCommand(loanId, jsonRequestBody);
|
||||
|
||||
Response response = null;
|
||||
command.setLoanId(loanId);
|
||||
|
||||
Locale clientLocale = this.apiDataConversionService
|
||||
.localeFromString(command.getLocale());
|
||||
|
||||
LocalDate transactionLocalDate = apiDataConversionService.convertFrom(
|
||||
command.getTransactionDate(), "transactionDate",
|
||||
command.getDateFormat());
|
||||
command.setTransactionLocalDate(transactionLocalDate);
|
||||
|
||||
BigDecimal transactionAmountValue = apiDataConversionService
|
||||
.convertFrom(command.getTransactionAmount(),
|
||||
"transactionAmount", clientLocale);
|
||||
command.setTransactionAmountValue(transactionAmountValue);
|
||||
|
||||
if (is(commandParam, "repayment")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.makeLoanRepayment(command);
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.makeLoanRepayment(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
} else if (is(commandParam, "waiver")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.waiveLoanAmount(command);
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.waiveLoanAmount(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
@@ -287,12 +214,12 @@ public class LoansApiResource {
|
||||
|
||||
@GET
|
||||
@Path("{loanId}/transactions/template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveNewRepaymentDetails(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@QueryParam("command") final String commandParam,
|
||||
@Context UriInfo uriInfo) {
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
String json = "";
|
||||
String selectedFields = loanRepaymentDefaultFieldList;
|
||||
@@ -319,11 +246,11 @@ public class LoansApiResource {
|
||||
|
||||
@GET
|
||||
@Path("{loanId}/transactions/{transactionId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveTransaction(@PathParam("loanId") final Long loanId,
|
||||
@PathParam("transactionId") final Long transactionId,
|
||||
@Context UriInfo uriInfo) {
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
LoanTransactionData loanRepaymentData = this.loanReadPlatformService
|
||||
.retrieveLoanTransactionDetails(loanId, transactionId);
|
||||
@@ -336,31 +263,15 @@ public class LoansApiResource {
|
||||
|
||||
@POST
|
||||
@Path("{loanId}/transactions/{transactionId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response adjustLoanTransaction(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@PathParam("transactionId") final Long transactionId,
|
||||
final AdjustLoanTransactionCommand command) {
|
||||
@PathParam("transactionId") final Long transactionId, final String jsonRequestBody) {
|
||||
|
||||
command.setLoanId(loanId);
|
||||
command.setTransactionId(transactionId);
|
||||
|
||||
Locale clientLocale = this.apiDataConversionService
|
||||
.localeFromString(command.getLocale());
|
||||
|
||||
LocalDate transactionLocalDate = apiDataConversionService.convertFrom(
|
||||
command.getTransactionDate(), "transactionDate",
|
||||
command.getDateFormat());
|
||||
command.setTransactionLocalDate(transactionLocalDate);
|
||||
|
||||
BigDecimal transactionAmountValue = apiDataConversionService
|
||||
.convertFrom(command.getTransactionAmount(),
|
||||
"transactionAmount", clientLocale);
|
||||
command.setTransactionAmountValue(transactionAmountValue);
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.adjustLoanTransaction(command);
|
||||
final AdjustLoanTransactionCommand command = this.apiDataConversionService.convertJsonToAdjustLoanTransactionCommand(loanId, transactionId, jsonRequestBody);
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.adjustLoanTransaction(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
+5
-15
@@ -1,8 +1,5 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
@@ -13,7 +10,6 @@ import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.commands.BranchMoneyTransferCommand;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.data.OfficeTransactionData;
|
||||
@@ -44,9 +40,9 @@ public class OfficeTransactionsApiResource {
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String newOfficeTransactionDetails(@Context UriInfo uriInfo) {
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String newOfficeTransactionDetails(@Context final UriInfo uriInfo) {
|
||||
|
||||
OfficeTransactionData officeTransactionData = this.readPlatformService
|
||||
.retrieveNewOfficeTransactionDetails();
|
||||
@@ -63,15 +59,9 @@ public class OfficeTransactionsApiResource {
|
||||
@POST
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response transferMoneyFrom(final BranchMoneyTransferCommand command) {
|
||||
public Response transferMoneyFrom(final String jsonRequestBody) {
|
||||
|
||||
LocalDate transactionLocalDate = apiDataConversionService.convertFrom(command.getTransactionDate(), "transactionDate", command.getDateFormat());
|
||||
command.setTransactionLocalDate(transactionLocalDate);
|
||||
|
||||
Locale clientLocale = this.apiDataConversionService.localeFromString(command.getLocale());
|
||||
|
||||
BigDecimal transactionAmountValue = apiDataConversionService.convertFrom(command.getTransactionAmount(), "transactionAmount", clientLocale);
|
||||
command.setTransactionAmountValue(transactionAmountValue);
|
||||
BranchMoneyTransferCommand command = this.apiDataConversionService.convertJsonToBranchMoneyTransferCommand(jsonRequestBody);
|
||||
|
||||
Long id = this.writePlatformService.externalBranchMoneyTransfer(command);
|
||||
return Response.ok().entity(new EntityIdentifier(id)).build();
|
||||
|
||||
+7
-7
@@ -26,7 +26,7 @@ import org.springframework.stereotype.Component;
|
||||
@Path("/reports")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class ReportingApiResource {
|
||||
public class ReportsApiResource {
|
||||
|
||||
private String allowedFieldList = "";
|
||||
private String filterName = "myFilter";
|
||||
@@ -38,9 +38,9 @@ public class ReportingApiResource {
|
||||
private ApiJSONFormattingService jsonFormattingService;
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON, "application/x-msdownload" })
|
||||
public Response retrieveReportList(@Context UriInfo uriInfo) {
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON, "application/x-msdownload" })
|
||||
public Response retrieveReportList(@Context final UriInfo uriInfo) {
|
||||
|
||||
MultivaluedMap<String, String> queryParams = uriInfo
|
||||
.getQueryParameters();
|
||||
@@ -70,12 +70,12 @@ public class ReportingApiResource {
|
||||
|
||||
@GET
|
||||
@Path("{reportName}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON, "application/x-msdownload",
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON, "application/x-msdownload",
|
||||
"application/vnd.ms-excel", "application/pdf", "text/html" })
|
||||
public Response retrieveReport(
|
||||
@PathParam("reportName") final String reportName,
|
||||
@Context UriInfo uriInfo) {
|
||||
@Context final UriInfo uriInfo) {
|
||||
|
||||
MultivaluedMap<String, String> queryParams = uriInfo
|
||||
.getQueryParameters();
|
||||
+26
-23
@@ -18,6 +18,7 @@ import javax.ws.rs.core.UriInfo;
|
||||
import org.mifosng.platform.api.commands.UserCommand;
|
||||
import org.mifosng.platform.api.data.AppUserData;
|
||||
import org.mifosng.platform.api.data.EntityIdentifier;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiJSONFormattingService;
|
||||
import org.mifosng.platform.user.service.AppUserReadPlatformService;
|
||||
import org.mifosng.platform.user.service.AppUserWritePlatformService;
|
||||
@@ -28,7 +29,7 @@ import org.springframework.stereotype.Component;
|
||||
@Path("/users")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class UserApiResource {
|
||||
public class UsersApiResource {
|
||||
|
||||
private String allowedFieldList = "allowedOffices,availableRoles";
|
||||
private String filterName = "userFilter";
|
||||
@@ -39,16 +40,18 @@ public class UserApiResource {
|
||||
@Autowired
|
||||
private AppUserWritePlatformService appUserWritePlatformService;
|
||||
|
||||
@Autowired
|
||||
private ApiDataConversionService apiDataConversionService;
|
||||
|
||||
@Autowired
|
||||
private ApiJSONFormattingService jsonFormattingService;
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveUsers(@Context UriInfo uriInfo) {
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveUsers(@Context final UriInfo uriInfo) {
|
||||
|
||||
Collection<AppUserData> users = this.appUserReadPlatformService
|
||||
.retrieveAllUsers();
|
||||
Collection<AppUserData> users = this.appUserReadPlatformService.retrieveAllUsers();
|
||||
|
||||
String selectedFields = "id,officeId,officeName,username,firstname,lastname,email";
|
||||
return this.jsonFormattingService.convertRequest(users, filterName,
|
||||
@@ -57,10 +60,9 @@ public class UserApiResource {
|
||||
|
||||
@GET
|
||||
@Path("{userId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String retrieveUser(@PathParam("userId") final Long userId,
|
||||
@Context UriInfo uriInfo) {
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String retrieveUser(@PathParam("userId") final Long userId, @Context final UriInfo uriInfo) {
|
||||
|
||||
AppUserData user = this.appUserReadPlatformService.retrieveUser(userId);
|
||||
|
||||
@@ -71,9 +73,9 @@ public class UserApiResource {
|
||||
|
||||
@GET
|
||||
@Path("template")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public String newUserDetails(@Context UriInfo uriInfo) {
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public String newUserDetails(@Context final UriInfo uriInfo) {
|
||||
|
||||
AppUserData newUser = this.appUserReadPlatformService
|
||||
.retrieveNewUserDetails();
|
||||
@@ -84,18 +86,20 @@ public class UserApiResource {
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response createUser(UserCommand command) {
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response createUser(final String jsonRequestBody) {
|
||||
|
||||
UserCommand command = this.apiDataConversionService.convertJsonToUserCommand(null, jsonRequestBody);
|
||||
|
||||
Long userId = this.appUserWritePlatformService.createUser(command);
|
||||
return Response.ok().entity(new EntityIdentifier(userId)).build();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("{userId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response deleteUser(@PathParam("userId") final Long userId) {
|
||||
|
||||
this.appUserWritePlatformService.deleteUser(userId);
|
||||
@@ -105,12 +109,11 @@ public class UserApiResource {
|
||||
|
||||
@PUT
|
||||
@Path("{userId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON })
|
||||
public Response updateUser(@PathParam("userId") final Long userId,
|
||||
UserCommand command) {
|
||||
@Consumes({MediaType.APPLICATION_JSON})
|
||||
@Produces({MediaType.APPLICATION_JSON})
|
||||
public Response updateUser(@PathParam("userId") final Long userId, final String jsonRequestBody) {
|
||||
|
||||
command.setId(userId);
|
||||
UserCommand command = this.apiDataConversionService.convertJsonToUserCommand(userId, jsonRequestBody);
|
||||
|
||||
this.appUserWritePlatformService.updateUser(command);
|
||||
|
||||
+15
-75
@@ -2,106 +2,46 @@ package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
@XmlRootElement
|
||||
/**
|
||||
* Immutable command for adjusting loan transactions.
|
||||
*/
|
||||
public class AdjustLoanTransactionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private Long transactionId;
|
||||
private String locale;
|
||||
private String dateFormat;
|
||||
private String transactionDate;
|
||||
private LocalDate transactionLocalDate;
|
||||
private String note;
|
||||
private String transactionAmount;
|
||||
private BigDecimal transactionAmountValue;
|
||||
|
||||
protected AdjustLoanTransactionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
private final Long loanId;
|
||||
private final Long transactionId;
|
||||
private final LocalDate transactionDate;
|
||||
private final BigDecimal transactionAmount;
|
||||
private final String note;
|
||||
|
||||
public AdjustLoanTransactionCommand(final Long loanId, final Long transactionId,
|
||||
final LocalDate transactionLocalDate, final String note,
|
||||
final BigDecimal transactionAmountValue) {
|
||||
this.loanId = loanId;
|
||||
this.transactionId = transactionId;
|
||||
this.transactionLocalDate = transactionLocalDate;
|
||||
this.transactionDate = transactionLocalDate;
|
||||
this.transactionAmount = transactionAmountValue;
|
||||
this.note = note;
|
||||
this.transactionAmountValue = transactionAmountValue;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return this.loanId;
|
||||
}
|
||||
|
||||
public void setLoanId(final Long loanId) {
|
||||
this.loanId = loanId;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
return loanId;
|
||||
}
|
||||
|
||||
public Long getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public void setTransactionId(Long transactionId) {
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public String getTransactionDate() {
|
||||
public LocalDate getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public void setTransactionDate(String transactionDate) {
|
||||
this.transactionDate = transactionDate;
|
||||
}
|
||||
|
||||
public LocalDate getTransactionLocalDate() {
|
||||
return transactionLocalDate;
|
||||
}
|
||||
|
||||
public void setTransactionLocalDate(LocalDate transactionLocalDate) {
|
||||
this.transactionLocalDate = transactionLocalDate;
|
||||
public BigDecimal getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public String getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public void setTransactionAmount(String transactionAmount) {
|
||||
this.transactionAmount = transactionAmount;
|
||||
}
|
||||
|
||||
public BigDecimal getTransactionAmountValue() {
|
||||
return transactionAmountValue;
|
||||
}
|
||||
|
||||
public void setTransactionAmountValue(BigDecimal transactionAmountValue) {
|
||||
this.transactionAmountValue = transactionAmountValue;
|
||||
}
|
||||
}
|
||||
+24
-85
@@ -1,121 +1,60 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Set;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Command used for transfering money between two branches.
|
||||
* Immutable command for transfering money between two branches.
|
||||
*/
|
||||
@XmlRootElement
|
||||
public class BranchMoneyTransferCommand {
|
||||
|
||||
private Long id;
|
||||
private Long fromOfficeId;
|
||||
private Long toOfficeId;
|
||||
private final Long fromOfficeId;
|
||||
private final Long toOfficeId;
|
||||
private final LocalDate transactionDate;
|
||||
private final String currencyCode;
|
||||
private final BigDecimal transactionAmount;
|
||||
private final String description;
|
||||
|
||||
private String dateFormat;
|
||||
private String transactionDate;
|
||||
private LocalDate transactionLocalDate;
|
||||
private final Set<String> modifiedParameters;
|
||||
|
||||
private String locale;
|
||||
private String currencyCode;
|
||||
private String transactionAmount;
|
||||
private BigDecimal transactionAmountValue;
|
||||
|
||||
private String description;
|
||||
|
||||
protected BranchMoneyTransferCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public BranchMoneyTransferCommand(final Set<String> modifiedParameters, final Long fromOfficeId, final Long toOfficeId,
|
||||
final LocalDate transactionDate, final String currencyCode, final BigDecimal transactionAmount, final String description) {
|
||||
this.modifiedParameters = modifiedParameters;
|
||||
this.fromOfficeId = fromOfficeId;
|
||||
this.toOfficeId = toOfficeId;
|
||||
this.transactionDate = transactionDate;
|
||||
this.currencyCode = currencyCode;
|
||||
this.transactionAmount = transactionAmount;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Long getFromOfficeId() {
|
||||
return fromOfficeId;
|
||||
}
|
||||
|
||||
public void setFromOfficeId(Long fromOfficeId) {
|
||||
this.fromOfficeId = fromOfficeId;
|
||||
}
|
||||
|
||||
public Long getToOfficeId() {
|
||||
return toOfficeId;
|
||||
}
|
||||
|
||||
public void setToOfficeId(Long toOfficeId) {
|
||||
this.toOfficeId = toOfficeId;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public String getTransactionDate() {
|
||||
public LocalDate getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public void setTransactionDate(String transactionDate) {
|
||||
this.transactionDate = transactionDate;
|
||||
}
|
||||
|
||||
public LocalDate getTransactionLocalDate() {
|
||||
return transactionLocalDate;
|
||||
}
|
||||
|
||||
public void setTransactionLocalDate(LocalDate transactionLocalDate) {
|
||||
this.transactionLocalDate = transactionLocalDate;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public String getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public void setTransactionAmount(String transactionAmount) {
|
||||
this.transactionAmount = transactionAmount;
|
||||
}
|
||||
|
||||
public BigDecimal getTransactionAmountValue() {
|
||||
return transactionAmountValue;
|
||||
}
|
||||
|
||||
public void setTransactionAmountValue(BigDecimal transactionAmountValue) {
|
||||
this.transactionAmountValue = transactionAmountValue;
|
||||
}
|
||||
|
||||
public String getCurrencyCode() {
|
||||
return currencyCode;
|
||||
}
|
||||
|
||||
public void setCurrencyCode(String currencyCode) {
|
||||
this.currencyCode = currencyCode;
|
||||
public BigDecimal getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
|
||||
public boolean isFromOfficeIdChanged() {
|
||||
return this.modifiedParameters.contains("fromOfficeId");
|
||||
}
|
||||
}
|
||||
+24
-72
@@ -7,98 +7,50 @@ import org.joda.time.LocalDate;
|
||||
@XmlRootElement
|
||||
public class ClientCommand {
|
||||
|
||||
private Long id;
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String clientOrBusinessName;
|
||||
private Long officeId;
|
||||
private String externalId;
|
||||
|
||||
private String dateFormat;
|
||||
private String joiningDate;
|
||||
private LocalDate joiningLocalDate;
|
||||
private final Long id;
|
||||
private final String externalId;
|
||||
private final String firstname;
|
||||
private final String lastname;
|
||||
private final String clientOrBusinessName;
|
||||
private final Long officeId;
|
||||
private final LocalDate joiningDate;
|
||||
|
||||
protected ClientCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public ClientCommand(final String firstname, final String lastname, final String clientOrBusinessName, final Long officeId, final LocalDate joiningDate) {
|
||||
public ClientCommand(final Long id, final String externalId, final String firstname, final String lastname, final String clientOrBusinessName,
|
||||
final Long officeId, final LocalDate joiningDate) {
|
||||
this.id = id;
|
||||
this.externalId = externalId;
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
this.clientOrBusinessName = clientOrBusinessName;
|
||||
this.officeId = officeId;
|
||||
this.joiningLocalDate = joiningDate;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(final String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return this.lastname;
|
||||
}
|
||||
|
||||
public void setLastname(final String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public Long getOfficeId() {
|
||||
return this.officeId;
|
||||
}
|
||||
|
||||
public void setOfficeId(final Long officeId) {
|
||||
this.officeId = officeId;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public void setExternalId(String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
this.joiningDate = joiningDate;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public String getJoiningDate() {
|
||||
return joiningDate;
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setJoiningDate(String joiningDate) {
|
||||
this.joiningDate = joiningDate;
|
||||
}
|
||||
|
||||
public LocalDate getJoiningLocalDate() {
|
||||
return joiningLocalDate;
|
||||
}
|
||||
|
||||
public void setJoiningLocalDate(LocalDate joiningLocalDate) {
|
||||
this.joiningLocalDate = joiningLocalDate;
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public String getClientOrBusinessName() {
|
||||
return clientOrBusinessName;
|
||||
}
|
||||
|
||||
public void setClientOrBusinessName(String clientOrBusinessName) {
|
||||
this.clientOrBusinessName = clientOrBusinessName;
|
||||
public Long getOfficeId() {
|
||||
return officeId;
|
||||
}
|
||||
|
||||
public LocalDate getJoiningDate() {
|
||||
return joiningDate;
|
||||
}
|
||||
}
|
||||
+9
-46
@@ -1,68 +1,31 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
/**
|
||||
* Use for any of the loan state transitions eg. reject, withdrawn by client, approve, disburse
|
||||
* Immutable command for any of the loan state transitions eg. reject, withdrawn by client, approve, disburse
|
||||
*/
|
||||
@XmlRootElement
|
||||
public class LoanStateTransitionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private String dateFormat;
|
||||
private String eventDate;
|
||||
private LocalDate eventLocalDate;
|
||||
private String note;
|
||||
private final Long loanId;
|
||||
private final LocalDate eventDate;
|
||||
private final String note;
|
||||
|
||||
protected LoanStateTransitionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public LoanStateTransitionCommand(final Long loanId, final LocalDate eventDate, final String comment) {
|
||||
public LoanStateTransitionCommand(final Long loanId, final LocalDate eventDate, final String note) {
|
||||
this.loanId = loanId;
|
||||
this.eventLocalDate = eventDate;
|
||||
this.note = comment;
|
||||
this.eventDate = eventDate;
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return this.loanId;
|
||||
return loanId;
|
||||
}
|
||||
|
||||
public void setLoanId(final Long loanId) {
|
||||
this.loanId = loanId;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public String getEventDate() {
|
||||
public LocalDate getEventDate() {
|
||||
return eventDate;
|
||||
}
|
||||
|
||||
public void setEventDate(String eventDate) {
|
||||
this.eventDate = eventDate;
|
||||
}
|
||||
|
||||
public LocalDate getEventLocalDate() {
|
||||
return eventLocalDate;
|
||||
}
|
||||
|
||||
public void setEventLocalDate(LocalDate eventLocalDate) {
|
||||
this.eventLocalDate = eventLocalDate;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
}
|
||||
+14
-72
@@ -2,96 +2,38 @@ package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
@XmlRootElement
|
||||
/**
|
||||
* Immutable command for loan transactions.
|
||||
*/
|
||||
public class LoanTransactionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private String locale;
|
||||
private String dateFormat;
|
||||
private String transactionDate;
|
||||
private LocalDate transactionLocalDate;
|
||||
private String note;
|
||||
private String transactionAmount;
|
||||
private BigDecimal transactionAmountValue;
|
||||
private final Long loanId;
|
||||
private final LocalDate transactionDate;
|
||||
private final BigDecimal transactionAmount;
|
||||
private final String note;
|
||||
|
||||
protected LoanTransactionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public LoanTransactionCommand(final Long loanId,
|
||||
final LocalDate paymentDate, final String note,
|
||||
final BigDecimal paymentAmount) {
|
||||
public LoanTransactionCommand(final Long loanId, final LocalDate paymentDate, final BigDecimal paymentAmount,final String note) {
|
||||
this.loanId = loanId;
|
||||
this.transactionLocalDate = paymentDate;
|
||||
this.transactionDate = paymentDate;
|
||||
this.transactionAmount = paymentAmount;
|
||||
this.note = note;
|
||||
this.transactionAmountValue = paymentAmount;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return this.loanId;
|
||||
return loanId;
|
||||
}
|
||||
|
||||
public void setLoanId(final Long loanId) {
|
||||
this.loanId = loanId;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public String getTransactionDate() {
|
||||
public LocalDate getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public void setTransactionDate(String transactionDate) {
|
||||
this.transactionDate = transactionDate;
|
||||
}
|
||||
|
||||
public LocalDate getTransactionLocalDate() {
|
||||
return transactionLocalDate;
|
||||
}
|
||||
|
||||
public void setTransactionLocalDate(LocalDate transactionLocalDate) {
|
||||
this.transactionLocalDate = transactionLocalDate;
|
||||
public BigDecimal getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public String getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
public void setTransactionAmount(String transactionAmount) {
|
||||
this.transactionAmount = transactionAmount;
|
||||
}
|
||||
|
||||
public BigDecimal getTransactionAmountValue() {
|
||||
return transactionAmountValue;
|
||||
}
|
||||
|
||||
public void setTransactionAmountValue(BigDecimal transactionAmountValue) {
|
||||
this.transactionAmountValue = transactionAmountValue;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,15 @@ public class RoleCommand {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public Set<String> getModifiedParameters() {
|
||||
return modifiedParameters;
|
||||
public boolean isNameChanged() {
|
||||
return this.modifiedParameters.contains("name");
|
||||
}
|
||||
|
||||
public boolean isDescriptionChanged() {
|
||||
return this.modifiedParameters.contains("description");
|
||||
}
|
||||
|
||||
public boolean isPermissionsChanged() {
|
||||
return this.modifiedParameters.contains("permissions");
|
||||
}
|
||||
}
|
||||
+112
-292
@@ -2,346 +2,166 @@ package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.data.LoanSchedule;
|
||||
|
||||
@XmlRootElement
|
||||
/**
|
||||
* Immutable command for submitting new loan application.
|
||||
*/
|
||||
public class SubmitLoanApplicationCommand {
|
||||
|
||||
private Long clientId;
|
||||
private Long productId;
|
||||
private final Long clientId;
|
||||
private final Long productId;
|
||||
private final String externalId;
|
||||
|
||||
// product
|
||||
private Long fundId;
|
||||
private final Long fundId;
|
||||
|
||||
private String locale;
|
||||
private BigDecimal principalValue;
|
||||
private String principal;
|
||||
private BigDecimal inArrearsToleranceValue;
|
||||
private String inArrearsTolerance;
|
||||
private final BigDecimal principal;
|
||||
private final BigDecimal inArrearsTolerance;
|
||||
|
||||
private String numberOfRepayments;
|
||||
private Integer numberOfRepaymentsValue;
|
||||
private String repaymentEvery;
|
||||
private Integer repaymentEveryValue;
|
||||
private final Integer numberOfRepayments;
|
||||
private final Integer repaymentEvery;
|
||||
|
||||
private String interestRatePerPeriod;
|
||||
private BigDecimal interestRatePerPeriodValue;
|
||||
private final BigDecimal interestRatePerPeriod;
|
||||
|
||||
private Integer repaymentFrequencyType;
|
||||
private Integer interestRateFrequencyType;
|
||||
private Integer amortizationType;
|
||||
private Integer interestType;
|
||||
private Integer interestCalculationPeriodType;
|
||||
// end of product related fields
|
||||
private final Integer repaymentFrequencyType;
|
||||
private final Integer interestRateFrequencyType;
|
||||
private final Integer amortizationType;
|
||||
private final Integer interestType;
|
||||
private final Integer interestCalculationPeriodType;
|
||||
|
||||
private String expectedDisbursementDate;
|
||||
private String repaymentsStartingFromDate;
|
||||
private String interestChargedFromDate;
|
||||
private LocalDate expectedDisbursementLocalDate;
|
||||
private LocalDate repaymentsStartingFromLocalDate;
|
||||
private LocalDate interestChargedFromLocalDate;
|
||||
|
||||
private String dateFormat;
|
||||
private String submittedOnDate;
|
||||
private LocalDate submittedOnLocalDate;
|
||||
private String submittedOnNote;
|
||||
private String externalId;
|
||||
private final LocalDate expectedDisbursementDate;
|
||||
private final LocalDate repaymentsStartingFromDate;
|
||||
private final LocalDate interestChargedFromDate;
|
||||
private final LocalDate submittedOnDate;
|
||||
private final String submittedOnNote;
|
||||
|
||||
private LoanSchedule loanSchedule;
|
||||
|
||||
protected SubmitLoanApplicationCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public SubmitLoanApplicationCommand(final Long clientId,
|
||||
final Long productId, final LocalDate submittedOnDate,
|
||||
final String submittedOnNote,
|
||||
public SubmitLoanApplicationCommand(
|
||||
final Long clientId, final Long productId, final String externalId, final Long fundId,
|
||||
final LocalDate submittedOnDate, final String submittedOnNote,
|
||||
final LocalDate expectedDisbursementDate,
|
||||
final LocalDate repaymentsStartingFromDate,
|
||||
final LocalDate interestChargedFromLocalDate,
|
||||
final LoanSchedule loanSchedule,
|
||||
final Number principal,
|
||||
final Number interestRatePerPeriod, Integer interestRateFrequencyMethod, final Integer interestMethod, final Integer interestCalculationPeriodMethod,
|
||||
final Integer repaymentEvery, final Integer repaymentFrequency, final Integer numberOfRepayments, Integer amortizationMethod, final Number toleranceAmount) {
|
||||
final BigDecimal principal,
|
||||
final BigDecimal interestRatePerPeriod,
|
||||
final Integer interestRateFrequencyMethod,
|
||||
final Integer interestMethod,
|
||||
final Integer interestCalculationPeriodMethod,
|
||||
final Integer repaymentEvery, final Integer repaymentFrequency, final Integer numberOfRepayments, Integer amortizationMethod,
|
||||
final BigDecimal toleranceAmount) {
|
||||
this.clientId = clientId;
|
||||
this.productId = productId;
|
||||
this.submittedOnLocalDate = submittedOnDate;
|
||||
this.submittedOnNote = submittedOnNote;
|
||||
this.expectedDisbursementLocalDate = expectedDisbursementDate;
|
||||
this.repaymentsStartingFromLocalDate = repaymentsStartingFromDate;
|
||||
this.interestChargedFromLocalDate = interestChargedFromLocalDate;
|
||||
this.loanSchedule = loanSchedule;
|
||||
this.inArrearsToleranceValue = BigDecimal.valueOf(toleranceAmount.doubleValue());
|
||||
this.externalId = externalId;
|
||||
this.fundId = fundId;
|
||||
|
||||
this.principalValue = BigDecimal.valueOf(principal.doubleValue());
|
||||
this.interestRatePerPeriodValue = BigDecimal.valueOf(interestRatePerPeriod.doubleValue());
|
||||
this.submittedOnDate = submittedOnDate;
|
||||
this.submittedOnNote = submittedOnNote;
|
||||
this.expectedDisbursementDate = expectedDisbursementDate;
|
||||
this.repaymentsStartingFromDate = repaymentsStartingFromDate;
|
||||
this.interestChargedFromDate = interestChargedFromLocalDate;
|
||||
|
||||
this.principal = principal;
|
||||
this.inArrearsTolerance = toleranceAmount;
|
||||
|
||||
this.interestRatePerPeriod = interestRatePerPeriod;
|
||||
this.interestRateFrequencyType = interestRateFrequencyMethod;
|
||||
this.interestType = interestMethod;
|
||||
this.interestCalculationPeriodType = interestCalculationPeriodMethod;
|
||||
this.repaymentEveryValue = repaymentEvery;
|
||||
this.repaymentEvery = repaymentEvery;
|
||||
this.repaymentFrequencyType = repaymentFrequency;
|
||||
this.numberOfRepaymentsValue = numberOfRepayments;
|
||||
this.numberOfRepayments = numberOfRepayments;
|
||||
this.amortizationType = amortizationMethod;
|
||||
}
|
||||
|
||||
public CalculateLoanScheduleCommand toCalculateLoanScheduleCommand() {
|
||||
return new CalculateLoanScheduleCommand(productId,
|
||||
principalValue, interestRatePerPeriodValue, interestRateFrequencyType, interestType, interestCalculationPeriodType, repaymentEveryValue, repaymentFrequencyType, numberOfRepaymentsValue, amortizationType,
|
||||
expectedDisbursementLocalDate, repaymentsStartingFromLocalDate, interestChargedFromLocalDate);
|
||||
}
|
||||
|
||||
public Long getProductId() {
|
||||
return this.productId;
|
||||
}
|
||||
|
||||
public void setProductId(final Long productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public String getSubmittedOnNote() {
|
||||
return this.submittedOnNote;
|
||||
}
|
||||
|
||||
public void setSubmittedOnNote(final String submittedOnNote) {
|
||||
this.submittedOnNote = submittedOnNote;
|
||||
principal, interestRatePerPeriod, interestRateFrequencyType, interestType, interestCalculationPeriodType, repaymentEvery, repaymentFrequencyType, numberOfRepayments, amortizationType,
|
||||
expectedDisbursementDate, repaymentsStartingFromDate, interestChargedFromDate);
|
||||
}
|
||||
|
||||
public LoanSchedule getLoanSchedule() {
|
||||
return this.loanSchedule;
|
||||
return loanSchedule;
|
||||
}
|
||||
|
||||
public void setLoanSchedule(final LoanSchedule loanSchedule) {
|
||||
public void setLoanSchedule(LoanSchedule loanSchedule) {
|
||||
this.loanSchedule = loanSchedule;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public void setExternalId(String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
public String getDateFormat() {
|
||||
return dateFormat;
|
||||
}
|
||||
|
||||
public void setDateFormat(String dateFormat) {
|
||||
this.dateFormat = dateFormat;
|
||||
}
|
||||
|
||||
public Long getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(Long clientId) {
|
||||
this.clientId = clientId;
|
||||
public Long getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public BigDecimal getPrincipalValue() {
|
||||
return principalValue;
|
||||
}
|
||||
|
||||
public void setPrincipalValue(BigDecimal principalValue) {
|
||||
this.principalValue = principalValue;
|
||||
}
|
||||
|
||||
public String getPrincipal() {
|
||||
return principal;
|
||||
}
|
||||
|
||||
public void setPrincipal(String principal) {
|
||||
this.principal = principal;
|
||||
}
|
||||
|
||||
public BigDecimal getInArrearsToleranceValue() {
|
||||
return inArrearsToleranceValue;
|
||||
}
|
||||
|
||||
public void setInArrearsToleranceValue(BigDecimal inArrearsToleranceValue) {
|
||||
this.inArrearsToleranceValue = inArrearsToleranceValue;
|
||||
}
|
||||
|
||||
public String getInArrearsTolerance() {
|
||||
return inArrearsTolerance;
|
||||
}
|
||||
|
||||
public void setInArrearsTolerance(String inArrearsTolerance) {
|
||||
this.inArrearsTolerance = inArrearsTolerance;
|
||||
}
|
||||
|
||||
public String getNumberOfRepayments() {
|
||||
return numberOfRepayments;
|
||||
}
|
||||
|
||||
public void setNumberOfRepayments(String numberOfRepayments) {
|
||||
this.numberOfRepayments = numberOfRepayments;
|
||||
}
|
||||
|
||||
public Integer getNumberOfRepaymentsValue() {
|
||||
return numberOfRepaymentsValue;
|
||||
}
|
||||
|
||||
public void setNumberOfRepaymentsValue(Integer numberOfRepaymentsValue) {
|
||||
this.numberOfRepaymentsValue = numberOfRepaymentsValue;
|
||||
}
|
||||
|
||||
public String getRepaymentEvery() {
|
||||
return repaymentEvery;
|
||||
}
|
||||
|
||||
public void setRepaymentEvery(String repaymentEvery) {
|
||||
this.repaymentEvery = repaymentEvery;
|
||||
}
|
||||
|
||||
public Integer getRepaymentEveryValue() {
|
||||
return repaymentEveryValue;
|
||||
}
|
||||
|
||||
public void setRepaymentEveryValue(Integer repaymentEveryValue) {
|
||||
this.repaymentEveryValue = repaymentEveryValue;
|
||||
}
|
||||
|
||||
public String getInterestRatePerPeriod() {
|
||||
return interestRatePerPeriod;
|
||||
}
|
||||
|
||||
public void setInterestRatePerPeriod(String interestRatePerPeriod) {
|
||||
this.interestRatePerPeriod = interestRatePerPeriod;
|
||||
}
|
||||
|
||||
public BigDecimal getInterestRatePerPeriodValue() {
|
||||
return interestRatePerPeriodValue;
|
||||
}
|
||||
|
||||
public void setInterestRatePerPeriodValue(BigDecimal interestRatePerPeriodValue) {
|
||||
this.interestRatePerPeriodValue = interestRatePerPeriodValue;
|
||||
}
|
||||
|
||||
public Integer getRepaymentFrequencyType() {
|
||||
return repaymentFrequencyType;
|
||||
}
|
||||
|
||||
public void setRepaymentFrequencyType(Integer repaymentFrequencyType) {
|
||||
this.repaymentFrequencyType = repaymentFrequencyType;
|
||||
}
|
||||
|
||||
public Integer getInterestRateFrequencyType() {
|
||||
return interestRateFrequencyType;
|
||||
}
|
||||
|
||||
public void setInterestRateFrequencyType(Integer interestRateFrequencyType) {
|
||||
this.interestRateFrequencyType = interestRateFrequencyType;
|
||||
}
|
||||
|
||||
public Integer getAmortizationType() {
|
||||
return amortizationType;
|
||||
}
|
||||
|
||||
public void setAmortizationType(Integer amortizationType) {
|
||||
this.amortizationType = amortizationType;
|
||||
}
|
||||
|
||||
public Integer getInterestType() {
|
||||
return interestType;
|
||||
}
|
||||
|
||||
public void setInterestType(Integer interestType) {
|
||||
this.interestType = interestType;
|
||||
}
|
||||
|
||||
public Integer getInterestCalculationPeriodType() {
|
||||
return interestCalculationPeriodType;
|
||||
}
|
||||
|
||||
public void setInterestCalculationPeriodType(
|
||||
Integer interestCalculationPeriodType) {
|
||||
this.interestCalculationPeriodType = interestCalculationPeriodType;
|
||||
}
|
||||
|
||||
public String getExpectedDisbursementDate() {
|
||||
return expectedDisbursementDate;
|
||||
}
|
||||
|
||||
public void setExpectedDisbursementDate(String expectedDisbursementDate) {
|
||||
this.expectedDisbursementDate = expectedDisbursementDate;
|
||||
}
|
||||
|
||||
public String getRepaymentsStartingFromDate() {
|
||||
return repaymentsStartingFromDate;
|
||||
}
|
||||
|
||||
public void setRepaymentsStartingFromDate(String repaymentsStartingFromDate) {
|
||||
this.repaymentsStartingFromDate = repaymentsStartingFromDate;
|
||||
}
|
||||
|
||||
public LocalDate getExpectedDisbursementLocalDate() {
|
||||
return expectedDisbursementLocalDate;
|
||||
}
|
||||
|
||||
public void setExpectedDisbursementLocalDate(
|
||||
LocalDate expectedDisbursementLocalDate) {
|
||||
this.expectedDisbursementLocalDate = expectedDisbursementLocalDate;
|
||||
}
|
||||
|
||||
public LocalDate getRepaymentsStartingFromLocalDate() {
|
||||
return repaymentsStartingFromLocalDate;
|
||||
}
|
||||
|
||||
public void setRepaymentsStartingFromLocalDate(
|
||||
LocalDate repaymentsStartingFromLocalDate) {
|
||||
this.repaymentsStartingFromLocalDate = repaymentsStartingFromLocalDate;
|
||||
}
|
||||
|
||||
public LocalDate getInterestChargedFromLocalDate() {
|
||||
return interestChargedFromLocalDate;
|
||||
}
|
||||
|
||||
public void setInterestChargedFromLocalDate(
|
||||
LocalDate interestChargedFromLocalDate) {
|
||||
this.interestChargedFromLocalDate = interestChargedFromLocalDate;
|
||||
}
|
||||
|
||||
public String getSubmittedOnDate() {
|
||||
return submittedOnDate;
|
||||
}
|
||||
|
||||
public void setSubmittedOnDate(String submittedOnDate) {
|
||||
this.submittedOnDate = submittedOnDate;
|
||||
}
|
||||
|
||||
public LocalDate getSubmittedOnLocalDate() {
|
||||
return submittedOnLocalDate;
|
||||
}
|
||||
|
||||
public void setSubmittedOnLocalDate(LocalDate submittedOnLocalDate) {
|
||||
this.submittedOnLocalDate = submittedOnLocalDate;
|
||||
}
|
||||
|
||||
public String getInterestChargedFromDate() {
|
||||
return interestChargedFromDate;
|
||||
}
|
||||
|
||||
public void setInterestChargedFromDate(String interestChargedFromDate) {
|
||||
this.interestChargedFromDate = interestChargedFromDate;
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public Long getFundId() {
|
||||
return fundId;
|
||||
}
|
||||
|
||||
public void setFundId(Long fundId) {
|
||||
this.fundId = fundId;
|
||||
public BigDecimal getPrincipal() {
|
||||
return principal;
|
||||
}
|
||||
|
||||
public BigDecimal getInArrearsTolerance() {
|
||||
return inArrearsTolerance;
|
||||
}
|
||||
|
||||
public Integer getNumberOfRepayments() {
|
||||
return numberOfRepayments;
|
||||
}
|
||||
|
||||
public Integer getRepaymentEvery() {
|
||||
return repaymentEvery;
|
||||
}
|
||||
|
||||
public BigDecimal getInterestRatePerPeriod() {
|
||||
return interestRatePerPeriod;
|
||||
}
|
||||
|
||||
public Integer getRepaymentFrequencyType() {
|
||||
return repaymentFrequencyType;
|
||||
}
|
||||
|
||||
public Integer getInterestRateFrequencyType() {
|
||||
return interestRateFrequencyType;
|
||||
}
|
||||
|
||||
public Integer getAmortizationType() {
|
||||
return amortizationType;
|
||||
}
|
||||
|
||||
public Integer getInterestType() {
|
||||
return interestType;
|
||||
}
|
||||
|
||||
public Integer getInterestCalculationPeriodType() {
|
||||
return interestCalculationPeriodType;
|
||||
}
|
||||
|
||||
public LocalDate getExpectedDisbursementDate() {
|
||||
return expectedDisbursementDate;
|
||||
}
|
||||
|
||||
public LocalDate getRepaymentsStartingFromDate() {
|
||||
return repaymentsStartingFromDate;
|
||||
}
|
||||
|
||||
public LocalDate getInterestChargedFromDate() {
|
||||
return interestChargedFromDate;
|
||||
}
|
||||
|
||||
public LocalDate getSubmittedOnDate() {
|
||||
return submittedOnDate;
|
||||
}
|
||||
|
||||
public String getSubmittedOnNote() {
|
||||
return submittedOnNote;
|
||||
}
|
||||
}
|
||||
+5
-14
@@ -1,13 +1,12 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
/**
|
||||
* Immutable command for undo'ing a state transition.
|
||||
*/
|
||||
public class UndoStateTransitionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private String note;
|
||||
|
||||
protected UndoStateTransitionCommand() {
|
||||
//
|
||||
}
|
||||
private final Long loanId;
|
||||
private final String note;
|
||||
|
||||
public UndoStateTransitionCommand(final Long loanId, final String note) {
|
||||
this.loanId = loanId;
|
||||
@@ -18,15 +17,7 @@ public class UndoStateTransitionCommand {
|
||||
return this.loanId;
|
||||
}
|
||||
|
||||
public void setLoanId(final Long loanId) {
|
||||
this.loanId = loanId;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
}
|
||||
@@ -1,112 +1,89 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* create or update user details command.
|
||||
* Immutable command for creating or updating details of a User.
|
||||
*/
|
||||
@XmlRootElement
|
||||
public class UserCommand implements Serializable {
|
||||
|
||||
private Long id;
|
||||
private String username;
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
private String password;
|
||||
private String repeatPassword;
|
||||
private String email;
|
||||
private Long officeId;
|
||||
private final Long id;
|
||||
private final String username;
|
||||
private final String firstname;
|
||||
private final String lastname;
|
||||
private final String password;
|
||||
private final String repeatPassword;
|
||||
private final String email;
|
||||
private final Long officeId;
|
||||
|
||||
private String[] notSelectedRoles;
|
||||
private String[] roles;
|
||||
private final String[] notSelectedRoles;
|
||||
private final String[] roles;
|
||||
|
||||
private final Set<String> modifiedParameters;
|
||||
|
||||
public UserCommand() {
|
||||
//
|
||||
public UserCommand(final Set<String> modifiedParameters, final Long id,
|
||||
final String username, final String firstname, final String lastname,
|
||||
final String password, final String repeatPassword, final String email,
|
||||
final Long officeId, final String[] notSelectedRoles, final String[] roles) {
|
||||
this.modifiedParameters = modifiedParameters;
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
this.password = password;
|
||||
this.repeatPassword = repeatPassword;
|
||||
this.email = email;
|
||||
this.officeId = officeId;
|
||||
this.notSelectedRoles = notSelectedRoles;
|
||||
this.roles = roles;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return new StringBuilder(this.lastname).append(", ").append(this.firstname).toString();
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(final String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(final String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return this.email;
|
||||
}
|
||||
|
||||
public void setEmail(final String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public Long getOfficeId() {
|
||||
return this.officeId;
|
||||
}
|
||||
|
||||
public void setOfficeId(final Long officeId) {
|
||||
this.officeId = officeId;
|
||||
return username;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String[] getNotSelectedRoles() {
|
||||
return notSelectedRoles;
|
||||
}
|
||||
|
||||
public void setNotSelectedRoles(String... notSelectedRoles) {
|
||||
this.notSelectedRoles = notSelectedRoles;
|
||||
}
|
||||
|
||||
public String[] getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public void setRoles(String... roles) {
|
||||
this.roles = roles;
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public String getRepeatPassword() {
|
||||
return repeatPassword;
|
||||
}
|
||||
|
||||
public void setRepeatPassword(String repeatPassword) {
|
||||
this.repeatPassword = repeatPassword;
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public Long getOfficeId() {
|
||||
return officeId;
|
||||
}
|
||||
|
||||
public String[] getNotSelectedRoles() {
|
||||
return notSelectedRoles;
|
||||
}
|
||||
|
||||
public String[] getRoles() {
|
||||
return roles;
|
||||
}
|
||||
|
||||
public boolean isUsernameChanged() {
|
||||
return this.modifiedParameters.contains("username");
|
||||
}
|
||||
}
|
||||
+22
-16
@@ -1,28 +1,19 @@
|
||||
package org.mifosng.platform.api.infrastructure;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.BranchMoneyTransferCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.FundCommand;
|
||||
import org.mifosng.platform.api.commands.LoanProductCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.OfficeCommand;
|
||||
import org.mifosng.platform.api.commands.RoleCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.UserCommand;
|
||||
|
||||
public interface ApiDataConversionService {
|
||||
|
||||
LocalDate convertFrom(String dateAsString, String parameterName,
|
||||
String dateFormat);
|
||||
|
||||
Integer convertToInteger(String digitsAfterDecimal, String string, Locale clientApplicationLocale);
|
||||
|
||||
BigDecimal convertFrom(String principalFormatted, String parameterName,
|
||||
Locale clientApplicationLocale);
|
||||
|
||||
Locale localeFromString(String locale);
|
||||
|
||||
Locale localeFrom(String languageCode, String courntryCode, String variantCode);
|
||||
|
||||
LoanProductCommand convertJsonToLoanProductCommand(Long resourceIdentifier, String json);
|
||||
|
||||
FundCommand convertJsonToFundCommand(Long resourceIdentifier, String json);
|
||||
@@ -30,4 +21,19 @@ public interface ApiDataConversionService {
|
||||
OfficeCommand convertJsonToOfficeCommand(Long resourceIdentifier, String json);
|
||||
|
||||
RoleCommand convertJsonToRoleCommand(Long resourceIdentifier, String json);
|
||||
|
||||
UserCommand convertJsonToUserCommand(Long resourceIdentifier, String json);
|
||||
|
||||
BranchMoneyTransferCommand convertJsonToBranchMoneyTransferCommand(String jsonRequestBody);
|
||||
|
||||
ClientCommand convertJsonToClientCommand(Long resourceIdentifier, String jsonRequestBody);
|
||||
|
||||
SubmitLoanApplicationCommand convertJsonToSubmitLoanApplicationCommand(String jsonRequestBody);
|
||||
|
||||
LoanStateTransitionCommand convertJsonToLoanStateTransitionCommand(Long resourceIdentifier, String jsonRequestBody);
|
||||
|
||||
LoanTransactionCommand convertJsonToLoanTransactionCommand(Long resourceIdentifier, String jsonRequestBody);
|
||||
|
||||
AdjustLoanTransactionCommand convertJsonToAdjustLoanTransactionCommand(
|
||||
Long loanId, Long transactionId, String jsonRequestBody);
|
||||
}
|
||||
+251
-12
@@ -17,10 +17,17 @@ import java.util.Set;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.format.DateTimeFormat;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.BranchMoneyTransferCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.FundCommand;
|
||||
import org.mifosng.platform.api.commands.LoanProductCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.OfficeCommand;
|
||||
import org.mifosng.platform.api.commands.RoleCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.UserCommand;
|
||||
import org.mifosng.platform.api.data.ApiParameterError;
|
||||
import org.mifosng.platform.api.errorhandling.InvalidJsonException;
|
||||
import org.mifosng.platform.api.errorhandling.UnsupportedParameterException;
|
||||
@@ -45,8 +52,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
gsonConverter = new Gson();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalDate convertFrom(final String dateAsString, final String parameterName, final String dateFormat) {
|
||||
private LocalDate convertFrom(final String dateAsString, final String parameterName, final String dateFormat) {
|
||||
|
||||
if (StringUtils.isBlank(dateFormat)) {
|
||||
|
||||
@@ -88,8 +94,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
return eventLocalDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer convertToInteger(String numericalValueFormatted, String parameterName, Locale clientApplicationLocale) {
|
||||
private Integer convertToInteger(String numericalValueFormatted, String parameterName, Locale clientApplicationLocale) {
|
||||
try {
|
||||
Integer number = null;
|
||||
|
||||
@@ -142,8 +147,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal convertFrom(final String numericalValueFormatted, final String parameterName, final Locale clientApplicationLocale) {
|
||||
private BigDecimal convertFrom(final String numericalValueFormatted, final String parameterName, final Locale clientApplicationLocale) {
|
||||
|
||||
if (clientApplicationLocale == null) {
|
||||
|
||||
@@ -196,8 +200,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale localeFromString(final String localeAsString) {
|
||||
private Locale localeFromString(final String localeAsString) {
|
||||
|
||||
if (StringUtils.isBlank(localeAsString)) {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
@@ -233,8 +236,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
return localeFrom(languageCode, courntryCode, variantCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Locale localeFrom(final String languageCode, final String courntryCode, final String variantCode) {
|
||||
private Locale localeFrom(final String languageCode, final String courntryCode, final String variantCode) {
|
||||
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
@@ -271,11 +273,10 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
Type typeOfMap = new TypeToken<Map<String, String>>(){}.getType();
|
||||
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
|
||||
Set<String> supportedParams = new HashSet<String>(
|
||||
Arrays.asList("name", "description", "fundId", "currencyCode", "digitsAfterDecimalValue",
|
||||
"principal", "inArrearsTolerance", "interestRatePerPeriod", "repaymentEvery", "numberOfRepayments",
|
||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType")
|
||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType", "locale")
|
||||
);
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
@@ -395,6 +396,244 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
||||
|
||||
return new RoleCommand(modifiedParameters, resourceIdentifier, name, description, permissionIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserCommand convertJsonToUserCommand(final Long resourceIdentifier, final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, Object>>(){}.getType();
|
||||
Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
Set<String> supportedParams = new HashSet<String>(
|
||||
Arrays.asList("username", "firstname", "lastname", "password", "repeatPassword", "email", "officeId", "notSelectedRoles", "roles")
|
||||
);
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
|
||||
String username = extractStringParameter("username", requestMap, modifiedParameters);
|
||||
String firstname = extractStringParameter("firstname", requestMap, modifiedParameters);
|
||||
String lastname = extractStringParameter("lastname", requestMap, modifiedParameters);
|
||||
String password = extractStringParameter("password", requestMap, modifiedParameters);
|
||||
String repeatPassword = extractStringParameter("repeatPassword", requestMap, modifiedParameters);
|
||||
String email = extractStringParameter("email", requestMap, modifiedParameters);
|
||||
Long officeId = extractLongParameter("officeId", requestMap, modifiedParameters);
|
||||
|
||||
// check array
|
||||
JsonParser parser = new JsonParser();
|
||||
|
||||
String[] notSelectedRoles = null;
|
||||
String[] roles = null;
|
||||
JsonElement element = parser.parse(json);
|
||||
if (element.isJsonObject()) {
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
if (object.has("notSelectedRoles")) {
|
||||
modifiedParameters.add("notSelectedRoles");
|
||||
JsonArray array = object.get("notSelectedRoles").getAsJsonArray();
|
||||
notSelectedRoles = new String[array.size()];
|
||||
for (int i=0; i<array.size(); i++) {
|
||||
notSelectedRoles[i] = array.get(i).getAsString();
|
||||
}
|
||||
}
|
||||
|
||||
if (object.has("roles")) {
|
||||
modifiedParameters.add("roles");
|
||||
JsonArray array = object.get("roles").getAsJsonArray();
|
||||
roles = new String[array.size()];
|
||||
for (int i=0; i<array.size(); i++) {
|
||||
roles[i] = array.get(i).getAsString();
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
|
||||
return new UserCommand(modifiedParameters, resourceIdentifier, username, firstname, lastname, password, repeatPassword, email, officeId, notSelectedRoles, roles);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BranchMoneyTransferCommand convertJsonToBranchMoneyTransferCommand(final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, Object>>(){}.getType();
|
||||
Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
Set<String> supportedParams = new HashSet<String>(
|
||||
Arrays.asList("fromOfficeId", "toOfficeId", "transactionDate", "currencyCode", "transactionAmount", "description", "locale", "dateFormat")
|
||||
);
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
|
||||
Long fromOfficeId = extractLongParameter("fromOfficeId", requestMap, modifiedParameters);
|
||||
Long toOfficeId = extractLongParameter("toOfficeId", requestMap, modifiedParameters);
|
||||
LocalDate transactionLocalDate = extractLocalDateParameter("transactionDate", requestMap, modifiedParameters);
|
||||
String currencyCode = extractStringParameter("currencyCode", requestMap, modifiedParameters);
|
||||
BigDecimal transactionAmountValue = extractBigDecimalParameter("transactionAmount", requestMap, modifiedParameters);
|
||||
String description = extractStringParameter("description", requestMap, modifiedParameters);
|
||||
|
||||
return new BranchMoneyTransferCommand(modifiedParameters, fromOfficeId, toOfficeId, transactionLocalDate, currencyCode, transactionAmountValue, description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientCommand convertJsonToClientCommand(final Long resourceIdentifier, final String json) {
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, Object>>(){}.getType();
|
||||
Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
Set<String> supportedParams = new HashSet<String>(
|
||||
Arrays.asList("externalId", "firstname", "lastname", "clientOrBusinessName", "officeId", "joiningDate", "dateFormat")
|
||||
);
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
|
||||
String externalId = extractStringParameter("externalId", requestMap, modifiedParameters);
|
||||
Long officeId = extractLongParameter("officeId", requestMap, modifiedParameters);
|
||||
LocalDate joiningDate = extractLocalDateParameter("joiningDate", requestMap, modifiedParameters);
|
||||
String firstname = extractStringParameter("firstname", requestMap, modifiedParameters);
|
||||
String lastname = extractStringParameter("lastname", requestMap, modifiedParameters);
|
||||
String clientOrBusinessName = extractStringParameter("clientOrBusinessName", requestMap, modifiedParameters);
|
||||
|
||||
return new ClientCommand(resourceIdentifier, externalId, firstname, lastname, clientOrBusinessName, officeId, joiningDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubmitLoanApplicationCommand convertJsonToSubmitLoanApplicationCommand(final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, Object>>(){}.getType();
|
||||
Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
Set<String> supportedParams = new HashSet<String>(
|
||||
Arrays.asList("clientId", "productId", "externalId", "fundId",
|
||||
"principal", "inArrearsTolerance", "interestRatePerPeriod", "repaymentEvery", "numberOfRepayments",
|
||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType",
|
||||
"expectedDisbursementDate", "repaymentsStartingFromDate", "interestChargedFromDate", "submittedOnDate", "submittedOnNote",
|
||||
"locale", "dateFormat")
|
||||
);
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
|
||||
Long clientId = extractLongParameter("clientId", requestMap, modifiedParameters);
|
||||
Long productId = extractLongParameter("productId", requestMap, modifiedParameters);
|
||||
Long fundId = extractLongParameter("fundId", requestMap, modifiedParameters);
|
||||
String externalId = extractStringParameter("externalId", requestMap, modifiedParameters);
|
||||
|
||||
BigDecimal principal = extractBigDecimalParameter("principal", requestMap, modifiedParameters);
|
||||
BigDecimal inArrearsToleranceValue = extractBigDecimalParameter("inArrearsTolerance", requestMap, modifiedParameters);
|
||||
BigDecimal interestRatePerPeriod = extractBigDecimalParameter("interestRatePerPeriod", requestMap, modifiedParameters);
|
||||
|
||||
Integer repaymentEvery = extractIntegerParameter("repaymentEvery", requestMap, modifiedParameters);
|
||||
Integer numberOfRepayments = extractIntegerParameter("numberOfRepayments", requestMap, modifiedParameters);
|
||||
Integer repaymentFrequencyType = extractIntegerParameter("repaymentFrequencyType", requestMap, modifiedParameters);
|
||||
|
||||
Integer interestRateFrequencyTypeValue = extractIntegerParameter("interestRateFrequencyType", requestMap, modifiedParameters);
|
||||
Integer amortizationTypeValue = extractIntegerParameter("amortizationType", requestMap, modifiedParameters);
|
||||
Integer interestTypeValue = extractIntegerParameter("interestType", requestMap, modifiedParameters);
|
||||
Integer interestCalculationPeriodTypeValue = extractIntegerParameter("interestCalculationPeriodType", requestMap, modifiedParameters);
|
||||
|
||||
LocalDate expectedDisbursementDate = extractLocalDateParameter("expectedDisbursementDate", requestMap, modifiedParameters);
|
||||
LocalDate repaymentsStartingFromDate = extractLocalDateParameter("repaymentsStartingFromDate", requestMap, modifiedParameters);
|
||||
LocalDate interestChargedFromDate = extractLocalDateParameter("interestChargedFromDate", requestMap, modifiedParameters);
|
||||
LocalDate submittedOnDate = extractLocalDateParameter("submittedOnDate", requestMap, modifiedParameters);
|
||||
|
||||
String submittedOnNote = extractStringParameter("submittedOnNote", requestMap, modifiedParameters);
|
||||
|
||||
return new SubmitLoanApplicationCommand(clientId, productId, externalId, fundId, submittedOnDate, submittedOnNote,
|
||||
expectedDisbursementDate, repaymentsStartingFromDate, interestChargedFromDate,
|
||||
principal, interestRatePerPeriod, interestRateFrequencyTypeValue, interestTypeValue, interestCalculationPeriodTypeValue,
|
||||
repaymentEvery, repaymentFrequencyType, numberOfRepayments, amortizationTypeValue, inArrearsToleranceValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanStateTransitionCommand convertJsonToLoanStateTransitionCommand(final Long resourceIdentifier, final String json) {
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, Object>>(){}.getType();
|
||||
Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
Set<String> supportedParams = new HashSet<String>(
|
||||
Arrays.asList("eventDate", "note", "dateFormat")
|
||||
);
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
|
||||
LocalDate eventDate = extractLocalDateParameter("eventDate", requestMap, modifiedParameters);
|
||||
String note = extractStringParameter("note", requestMap, modifiedParameters);
|
||||
|
||||
return new LoanStateTransitionCommand(resourceIdentifier, eventDate, note);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LoanTransactionCommand convertJsonToLoanTransactionCommand(final Long resourceIdentifier, final String json) {
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, Object>>(){}.getType();
|
||||
Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
Set<String> supportedParams = new HashSet<String>(
|
||||
Arrays.asList("transactionDate", "transactionAmount", "note", "dateFormat", "locale")
|
||||
);
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
|
||||
LocalDate paymentDate = extractLocalDateParameter("paymentDate", requestMap, modifiedParameters);
|
||||
BigDecimal paymentAmount = extractBigDecimalParameter("paymentAmount", requestMap, modifiedParameters);
|
||||
String note = extractStringParameter("note", requestMap, modifiedParameters);
|
||||
|
||||
return new LoanTransactionCommand(resourceIdentifier, paymentDate, paymentAmount, note);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AdjustLoanTransactionCommand convertJsonToAdjustLoanTransactionCommand(
|
||||
final Long loanId, final Long transactionId, final String json) {
|
||||
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new InvalidJsonException();
|
||||
}
|
||||
|
||||
Type typeOfMap = new TypeToken<Map<String, Object>>(){}.getType();
|
||||
Map<String, Object> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||
|
||||
Set<String> supportedParams = new HashSet<String>(
|
||||
Arrays.asList("transactionDate", "transactionAmount", "note", "dateFormat", "locale")
|
||||
);
|
||||
|
||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||
|
||||
Set<String> modifiedParameters = new HashSet<String>();
|
||||
|
||||
LocalDate transactionDate = extractLocalDateParameter("paymentDate", requestMap, modifiedParameters);
|
||||
BigDecimal transactionAmount = extractBigDecimalParameter("paymentAmount", requestMap, modifiedParameters);
|
||||
String note = extractStringParameter("note", requestMap, modifiedParameters);
|
||||
|
||||
return new AdjustLoanTransactionCommand(loanId, transactionId, transactionDate, note, transactionAmount);
|
||||
}
|
||||
|
||||
private void checkForUnsupportedParameters(Map<String, ?> requestMap, Set<String> supportedParams) {
|
||||
List<String> unsupportedParameterList = new ArrayList<String>();
|
||||
|
||||
@@ -79,7 +79,7 @@ public class Client extends AbstractAuditableCustom<AppUser, Long> {
|
||||
}
|
||||
|
||||
public void update(ClientCommand command) {
|
||||
this.joiningDate = command.getJoiningLocalDate().toDate();
|
||||
this.joiningDate = command.getJoiningDate().toDate();
|
||||
this.firstName = command.getFirstname();
|
||||
this.lastName = command.getLastname();
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class ClientCommandValidator {
|
||||
baseDataValidator.reset().parameter("officeId").value(command.getOfficeId()).ignoreIfNull().notNull().greaterThanZero();
|
||||
|
||||
baseDataValidator.reset().anyOfNotNull(command.getFirstname(), command.getLastname(), command.getClientOrBusinessName(),
|
||||
command.getJoiningLocalDate(), command.getExternalId(), command.getOfficeId());
|
||||
command.getJoiningDate(), command.getExternalId(), command.getOfficeId());
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
|
||||
+2
-3
@@ -56,7 +56,7 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
firstname = null;
|
||||
}
|
||||
|
||||
Client newClient = Client.newClient(clientOffice, firstname, lastname, command.getJoiningLocalDate(), command.getExternalId());
|
||||
Client newClient = Client.newClient(clientOffice, firstname, lastname, command.getJoiningDate(), command.getExternalId());
|
||||
|
||||
this.clientRepository.save(newClient);
|
||||
|
||||
@@ -88,12 +88,11 @@ public class ClientWritePlatformServiceJpaRepositoryImpl implements ClientWriteP
|
||||
firstname = null;
|
||||
}
|
||||
|
||||
// Client clientForUpdate = this.clientRepository.findOne(clientsThatMatch(currentUser.getOrganisation(), command.getId()));
|
||||
Client clientForUpdate = this.clientRepository.findOne(command.getId());
|
||||
if (clientForUpdate == null) {
|
||||
throw new ClientNotFoundException(command.getId());
|
||||
}
|
||||
clientForUpdate.update(clientOffice, firstname, lastname, command.getExternalId(), command.getJoiningLocalDate());
|
||||
clientForUpdate.update(clientOffice, firstname, lastname, command.getExternalId(), command.getJoiningDate());
|
||||
|
||||
this.clientRepository.save(clientForUpdate);
|
||||
|
||||
|
||||
+3
-3
@@ -29,13 +29,13 @@ public class AdjustLoanTransactionCommandValidator {
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (command.getTransactionLocalDate() == null) {
|
||||
if (command.getTransactionDate() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.date.cannot.be.blank", "The parameter transactionDate cannot be blank.", "transactionDate");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (command.getTransactionAmountValue() == null || command.getTransactionAmountValue().doubleValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.must.be.greater.than.zero", "The parameter transactionAmount less than zero.", "transactionAmount", command.getTransactionAmountValue());
|
||||
if (command.getTransactionAmount() == null || command.getTransactionAmount().doubleValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.must.be.greater.than.zero", "The parameter transactionAmount less than zero.", "transactionAmount", command.getTransactionAmount());
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,23 +64,23 @@ public class LoanAssembler {
|
||||
}
|
||||
|
||||
MonetaryCurrency currency = loanProduct.getCurrency();
|
||||
final BigDecimal defaultNominalInterestRatePerPeriod = command.getInterestRatePerPeriodValue();
|
||||
final BigDecimal defaultNominalInterestRatePerPeriod = command.getInterestRatePerPeriod();
|
||||
final PeriodFrequencyType interestPeriodFrequencyType = PeriodFrequencyType.fromInt(command.getInterestRateFrequencyType());
|
||||
|
||||
BigDecimal defaultAnnualNominalInterestRate = aprCalculator.calculateFrom(interestPeriodFrequencyType, command.getInterestRatePerPeriodValue());
|
||||
BigDecimal defaultAnnualNominalInterestRate = aprCalculator.calculateFrom(interestPeriodFrequencyType, command.getInterestRatePerPeriod());
|
||||
|
||||
final InterestMethod interestMethod = InterestMethod.fromInt(command.getInterestType());
|
||||
final InterestCalculationPeriodMethod interestCalculationPeriodMethod = InterestCalculationPeriodMethod.fromInt(command.getInterestCalculationPeriodType());
|
||||
|
||||
final Integer repayEvery = command.getRepaymentEveryValue();
|
||||
final Integer repayEvery = command.getRepaymentEvery();
|
||||
final PeriodFrequencyType repaymentFrequencyType = PeriodFrequencyType.fromInt(command.getRepaymentFrequencyType());
|
||||
final Integer defaultNumberOfInstallments = command.getNumberOfRepaymentsValue();
|
||||
final Integer defaultNumberOfInstallments = command.getNumberOfRepayments();
|
||||
final AmortizationMethod amortizationMethod = AmortizationMethod.fromInt(command.getAmortizationType());
|
||||
|
||||
LoanProductRelatedDetail loanRepaymentScheduleDetail = new LoanProductRelatedDetail(currency,
|
||||
command.getPrincipalValue(), defaultNominalInterestRatePerPeriod, interestPeriodFrequencyType, defaultAnnualNominalInterestRate,
|
||||
command.getPrincipal(), defaultNominalInterestRatePerPeriod, interestPeriodFrequencyType, defaultAnnualNominalInterestRate,
|
||||
interestMethod, interestCalculationPeriodMethod,
|
||||
repayEvery, repaymentFrequencyType, defaultNumberOfInstallments, amortizationMethod, command.getInArrearsToleranceValue());
|
||||
repayEvery, repaymentFrequencyType, defaultNumberOfInstallments, amortizationMethod, command.getInArrearsTolerance());
|
||||
|
||||
LoanSchedule loanSchedule = command.getLoanSchedule();
|
||||
List<ScheduledLoanInstallment> loanRepaymentSchedule = loanSchedule.getScheduledLoanInstallments();
|
||||
@@ -98,13 +98,14 @@ public class LoanAssembler {
|
||||
|
||||
LoanRepaymentScheduleInstallment installment = new LoanRepaymentScheduleInstallment(
|
||||
loan, scheduledLoanInstallment.getInstallmentNumber(),
|
||||
// scheduledLoanInstallment.getPeriodStart(),
|
||||
scheduledLoanInstallment.getPeriodEnd(), readPrincipalDue.getAmount(),
|
||||
readInterestDue.getAmount());
|
||||
loan.addRepaymentScheduleInstallment(installment);
|
||||
}
|
||||
|
||||
loan.submitApplication(command.getSubmittedOnLocalDate(), command.getExpectedDisbursementLocalDate(), command.getRepaymentsStartingFromLocalDate(), command.getInterestChargedFromLocalDate(), defaultLoanLifecycleStateMachine());
|
||||
loan.submitApplication(command.getSubmittedOnDate(), command.getExpectedDisbursementDate(),
|
||||
command.getRepaymentsStartingFromDate(), command.getInterestChargedFromDate(),
|
||||
defaultLoanLifecycleStateMachine());
|
||||
|
||||
return loan;
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class LoanStateTransitionCommandValidator {
|
||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan.transition");
|
||||
|
||||
baseDataValidator.reset().parameter("loanId").value(command.getLoanId()).notNull().greaterThanZero();
|
||||
baseDataValidator.reset().parameter("eventDate").value(command.getEventLocalDate()).notNull();
|
||||
baseDataValidator.reset().parameter("eventDate").value(command.getEventDate()).notNull();
|
||||
baseDataValidator.reset().parameter("note").value(command.getNote()).notExceedingLengthOf(1000);
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ public class LoanTransactionCommandValidator {
|
||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("role");
|
||||
|
||||
baseDataValidator.reset().parameter("loanid").value(command.getLoanId()).notNull().greaterThanZero();
|
||||
baseDataValidator.reset().parameter("transactionDate").value(command.getTransactionLocalDate()).notNull();
|
||||
baseDataValidator.reset().parameter("transactionAmount").value(command.getTransactionAmountValue()).notNull().positiveAmount();
|
||||
baseDataValidator.reset().parameter("transactionDate").value(command.getTransactionDate()).notNull();
|
||||
baseDataValidator.reset().parameter("transactionAmount").value(command.getTransactionAmount()).notNull().positiveAmount();
|
||||
baseDataValidator.reset().parameter("note").value(command.getNote()).notExceedingLengthOf(1000);
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
|
||||
+11
-14
@@ -82,7 +82,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
SubmitLoanApplicationCommandValidator validator = new SubmitLoanApplicationCommandValidator(command);
|
||||
validator.validate();
|
||||
|
||||
LocalDate submittedOn = command.getSubmittedOnLocalDate();
|
||||
LocalDate submittedOn = command.getSubmittedOnDate();
|
||||
if (this.isBeforeToday(submittedOn) && currentUser.hasNotPermissionForAnyOf("CAN_SUBMIT_HISTORIC_LOAN_APPLICATION_ROLE", "PORTFOLIO_MANAGEMENT_SUPER_USER_ROLE")) {
|
||||
throw new NoAuthorizationException("Cannot add backdated loan.");
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
LocalDate eventDate = command.getEventLocalDate();
|
||||
LocalDate eventDate = command.getEventDate();
|
||||
if (this.isBeforeToday(eventDate) && currentUser.canNotApproveLoanInPast()) {
|
||||
throw new NoAuthorizationException("User has no authority to approve loan with a date in the past.");
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
LocalDate eventDate = command.getEventLocalDate();
|
||||
LocalDate eventDate = command.getEventDate();
|
||||
if (this.isBeforeToday(eventDate) && currentUser.canNotRejectLoanInPast()) {
|
||||
throw new NoAuthorizationException("User has no authority to reject loan with a date in the past.");
|
||||
}
|
||||
@@ -221,7 +221,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
LocalDate eventDate = command.getEventLocalDate();
|
||||
LocalDate eventDate = command.getEventDate();
|
||||
if (this.isBeforeToday(eventDate) && currentUser.canNotWithdrawByClientLoanInPast()) {
|
||||
throw new NoAuthorizationException("User has no authority to mark loan as withdrawn by client with a date in the past.");
|
||||
}
|
||||
@@ -253,7 +253,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
}
|
||||
|
||||
String noteText = command.getNote();
|
||||
LocalDate actualDisbursementDate = command.getEventLocalDate();
|
||||
LocalDate actualDisbursementDate = command.getEventDate();
|
||||
if (this.isBeforeToday(actualDisbursementDate) && currentUser.canNotDisburseLoanInPast()) {
|
||||
throw new NoAuthorizationException("User has no authority to disburse loan with a date in the past.");
|
||||
}
|
||||
@@ -264,9 +264,6 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
LocalDate interestCalculatedFromDate = loan.getInterestChargedFromDate();
|
||||
|
||||
Number principalAsDecimal = loan.getLoanRepaymentScheduleDetail().getPrincipal().getAmount();
|
||||
// String currencyCode = loan.getLoanRepaymentScheduleDetail().getPrincipal().getCurrencyCode();
|
||||
// int currencyDigits = loan.getLoanRepaymentScheduleDetail().getPrincipal().getCurrencyDigitsAfterDecimal();
|
||||
|
||||
Number interestRatePerYear = loan.getLoanRepaymentScheduleDetail().getAnnualNominalInterestRate();
|
||||
Integer numberOfInstallments = loan.getLoanRepaymentScheduleDetail().getNumberOfRepayments();
|
||||
|
||||
@@ -369,14 +366,14 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
LocalDate transactionDate = command.getTransactionLocalDate();
|
||||
LocalDate transactionDate = command.getTransactionDate();
|
||||
if (this.isBeforeToday(transactionDate) && currentUser.canNotMakeRepaymentOnLoanInPast()) {
|
||||
throw new NoAuthorizationException("error.msg.no.permission.to.make.repayment.on.loan.in.past");
|
||||
}
|
||||
|
||||
Money repayment = Money.of(loan.getLoanRepaymentScheduleDetail()
|
||||
.getPrincipal().getCurrency(),
|
||||
command.getTransactionAmountValue());
|
||||
command.getTransactionAmount());
|
||||
|
||||
LoanTransaction loanRepayment = LoanTransaction.repayment(repayment, transactionDate);
|
||||
loan.makeRepayment(loanRepayment, defaultLoanLifecycleStateMachine());
|
||||
@@ -413,10 +410,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
Money transactionAmount = Money.of(loan
|
||||
.getLoanRepaymentScheduleDetail().getPrincipal()
|
||||
.getCurrency(), command.getTransactionAmountValue());
|
||||
.getCurrency(), command.getTransactionAmount());
|
||||
|
||||
// adjustment is only supported for repayments and waivers at present
|
||||
LocalDate transactionDate = command.getTransactionLocalDate();
|
||||
LocalDate transactionDate = command.getTransactionDate();
|
||||
LoanTransaction newTransactionDetail = LoanTransaction.repayment(transactionAmount, transactionDate);
|
||||
if (transactionToAdjust.isWaiver()) {
|
||||
newTransactionDetail = LoanTransaction.waiver(transactionAmount, transactionDate);
|
||||
@@ -453,9 +450,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
Money waived = Money.of(loan.getLoanRepaymentScheduleDetail()
|
||||
.getPrincipal().getCurrency(),
|
||||
command.getTransactionAmountValue());
|
||||
command.getTransactionAmount());
|
||||
|
||||
LoanTransaction waiver = LoanTransaction.waiver(waived, command.getTransactionLocalDate());
|
||||
LoanTransaction waiver = LoanTransaction.waiver(waived, command.getTransactionDate());
|
||||
|
||||
loan.waive(waiver, defaultLoanLifecycleStateMachine());
|
||||
|
||||
|
||||
+4
-17
@@ -25,12 +25,12 @@ public class SubmitLoanApplicationCommandValidator {
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (command.getSubmittedOnLocalDate() == null) {
|
||||
if (command.getSubmittedOnDate() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.submitted.on.date.cannot.be.blank",
|
||||
"The parameter submittedOnDate cannot be empty.", "submittedOnDate");
|
||||
dataValidationErrors.add(error);
|
||||
} else {
|
||||
if (command.getSubmittedOnLocalDate().isAfter(command.getExpectedDisbursementLocalDate())) {
|
||||
if (command.getSubmittedOnDate().isAfter(command.getExpectedDisbursementDate())) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.submitted.on.date.cannot.be.after.expectedDisbursementDate",
|
||||
"The date of parameter submittedOnDate cannot fall after the date given for expectedDisbursementDate.", "submittedOnDate",
|
||||
command.getSubmittedOnDate(), command.getExpectedDisbursementDate());
|
||||
@@ -40,21 +40,8 @@ public class SubmitLoanApplicationCommandValidator {
|
||||
|
||||
try {
|
||||
// reuse calculate loan schedule validator for now
|
||||
CalculateLoanScheduleCommand calculateLoanScheduleCommand = new CalculateLoanScheduleCommand(
|
||||
command.getProductId(),
|
||||
command.getPrincipalValue(), command.getInterestRatePerPeriodValue(),
|
||||
command.getInterestRateFrequencyType(),
|
||||
command.getInterestType(), command.getInterestCalculationPeriodType(),
|
||||
command.getRepaymentEveryValue(),
|
||||
command.getRepaymentFrequencyType(),
|
||||
command.getNumberOfRepaymentsValue(),
|
||||
command.getAmortizationType(),
|
||||
command.getExpectedDisbursementLocalDate(),
|
||||
command.getRepaymentsStartingFromLocalDate(),
|
||||
command.getInterestChargedFromLocalDate());
|
||||
|
||||
CalculateLoanScheduleCommandValidator validator = new CalculateLoanScheduleCommandValidator(
|
||||
calculateLoanScheduleCommand);
|
||||
CalculateLoanScheduleCommand calculateLoanScheduleCommand = this.command.toCalculateLoanScheduleCommand();
|
||||
CalculateLoanScheduleCommandValidator validator = new CalculateLoanScheduleCommandValidator(calculateLoanScheduleCommand);
|
||||
validator.validate();
|
||||
} catch (PlatformApiDataValidationException e) {
|
||||
dataValidationErrors.addAll(e.getErrors());
|
||||
|
||||
+2
-2
@@ -37,9 +37,9 @@ public class BranchMoneyTransferCommandValidator {
|
||||
baseDataValidator.reset().parameter("fromOfficeId").value(command.getFromOfficeId()).notSameAsParameter("toOfficeId", command.getToOfficeId());
|
||||
}
|
||||
|
||||
baseDataValidator.reset().parameter("transactionDate").value(command.getTransactionLocalDate()).notNull();
|
||||
baseDataValidator.reset().parameter("transactionDate").value(command.getTransactionDate()).notNull();
|
||||
baseDataValidator.reset().parameter("currencyCode").value(command.getCurrencyCode()).notBlank();
|
||||
baseDataValidator.reset().parameter("transactionAmount").value(command.getTransactionAmountValue()).notNull();
|
||||
baseDataValidator.reset().parameter("transactionAmount").value(command.getTransactionAmount()).notNull();
|
||||
baseDataValidator.reset().parameter("description").value(command.getDescription()).notExceedingLengthOf(100);
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
|
||||
+2
-2
@@ -129,9 +129,9 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP
|
||||
}
|
||||
|
||||
MonetaryCurrency currency = new MonetaryCurrency(appCurrency.getCode(), appCurrency.getDecimalPlaces());
|
||||
Money amount = Money.of(currency, command.getTransactionAmountValue());
|
||||
Money amount = Money.of(currency, command.getTransactionAmount());
|
||||
|
||||
OfficeTransaction entity = OfficeTransaction.create(fromOffice, toOffice, command.getTransactionLocalDate(), amount);
|
||||
OfficeTransaction entity = OfficeTransaction.create(fromOffice, toOffice, command.getTransactionDate(), amount);
|
||||
|
||||
this.officeMonetaryTransferRepository.save(entity);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import javax.persistence.JoinTable;
|
||||
import javax.persistence.ManyToMany;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.mifosng.platform.api.commands.RoleCommand;
|
||||
import org.mifosng.platform.api.data.PermissionData;
|
||||
import org.mifosng.platform.api.data.RoleData;
|
||||
import org.mifosng.platform.infrastructure.AbstractAuditableCustom;
|
||||
@@ -73,17 +74,16 @@ public class Role extends AbstractAuditableCustom<AppUser, Long> {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* When updating details, any parameters with null values are ignored.
|
||||
*/
|
||||
public void update(String name, String description, List<Permission> selectedPermissions) {
|
||||
if (name != null) {
|
||||
this.name = name;
|
||||
public void update(final RoleCommand command, List<Permission> selectedPermissions) {
|
||||
if (command.isNameChanged()) {
|
||||
this.name = command.getName();
|
||||
}
|
||||
if (description != null) {
|
||||
this.description = description;
|
||||
|
||||
if (command.isDescriptionChanged()) {
|
||||
this.description = command.getDescription();
|
||||
}
|
||||
if (!selectedPermissions.isEmpty()) {
|
||||
|
||||
if (command.isPermissionsChanged()) {
|
||||
this.permissions.clear();
|
||||
this.permissions = new HashSet<Permission>(selectedPermissions);
|
||||
}
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class RoleWritePlatformServiceJpaRepositoryImpl implements RoleWritePlatf
|
||||
if (role == null) {
|
||||
throw new RoleNotFoundException(command.getId());
|
||||
}
|
||||
role.update(command.getName(), command.getDescription(), selectedPermissions);
|
||||
role.update(command, selectedPermissions);
|
||||
|
||||
this.roleRepository.save(role);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user