update state transition and transaction api for loans.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
package org.mifosng.platform;
|
||||
|
||||
import org.mifosng.data.command.ImportLoanCommand;
|
||||
import org.mifosng.data.command.ImportLoanRepaymentsCommand;
|
||||
import org.mifosng.platform.api.commands.ImportClientCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanRepaymentsCommand;
|
||||
|
||||
public interface ImportPlatformService {
|
||||
|
||||
|
||||
+11
-11
@@ -19,15 +19,15 @@ import org.joda.time.LocalDate;
|
||||
import org.joda.time.format.DateTimeFormatter;
|
||||
import org.joda.time.format.ISODateTimeFormat;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.ImportLoanCommand;
|
||||
import org.mifosng.data.command.ImportLoanRepaymentsCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.SubmitApproveDisburseLoanCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.ImportClientCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanRepaymentsCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitApproveDisburseLoanCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.client.domain.Client;
|
||||
import org.mifosng.platform.client.domain.ClientRepository;
|
||||
import org.mifosng.platform.currency.domain.Money;
|
||||
@@ -140,12 +140,12 @@ public class ImportPlatformServiceImpl implements ImportPlatformService {
|
||||
|
||||
LoanStateTransitionCommand approveLoanCommand = combinedCommand.getApproveLoanCommand();
|
||||
if (approveLoanCommand != null) {
|
||||
loan.approve(approveLoanCommand.getEventDate(), loanLifecycleStateMachine);
|
||||
loan.approve(approveLoanCommand.getEventLocalDate(), loanLifecycleStateMachine);
|
||||
}
|
||||
|
||||
LoanStateTransitionCommand disburseLoanCommand = combinedCommand.getDisburseLoanCommand();
|
||||
if (disburseLoanCommand != null) {
|
||||
loan.disburse(disburseLoanCommand.getEventDate(), loanLifecycleStateMachine);
|
||||
loan.disburse(disburseLoanCommand.getEventLocalDate(), loanLifecycleStateMachine);
|
||||
}
|
||||
|
||||
newLoanCollection.add(loan);
|
||||
@@ -173,9 +173,9 @@ public class ImportPlatformServiceImpl implements ImportPlatformService {
|
||||
for (LoanTransactionCommand repaymentDetail : command.getRepayments()) {
|
||||
Loan loan = findLoanByIdentifier(allLoans, repaymentDetail.getLoanId().toString());
|
||||
|
||||
Money repaymentAmount = Money.of(loan.getCurrency(), repaymentDetail.getTransactionAmount());
|
||||
Money repaymentAmount = Money.of(loan.getCurrency(), repaymentDetail.getTransactionAmountValue());
|
||||
|
||||
LoanTransaction loanRepayment = LoanTransaction.repayment(repaymentAmount, repaymentDetail.getTransactionDate());
|
||||
LoanTransaction loanRepayment = LoanTransaction.repayment(repaymentAmount, repaymentDetail.getTransactionLocalDate());
|
||||
loan.makeRepayment(loanRepayment, loanLifecycleStateMachine);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import org.mifosng.data.ClientLoanAccountSummaryCollectionData;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.NoteData;
|
||||
import org.mifosng.data.OfficeLookup;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.NoteCommand;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiJSONFormattingService;
|
||||
import org.mifosng.platform.client.service.ClientReadPlatformService;
|
||||
|
||||
@@ -24,12 +24,12 @@ import org.mifosng.data.LoanAccountData;
|
||||
import org.mifosng.data.LoanRepaymentData;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.NewLoanWorkflowStepOneData;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.data.command.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.api.infrastructure.ApiDataConversionService;
|
||||
import org.mifosng.platform.api.infrastructure.ApiJSONFormattingService;
|
||||
import org.mifosng.platform.exceptions.UnrecognizedQueryParamException;
|
||||
@@ -187,12 +187,12 @@ public class LoansApiResource {
|
||||
public Response stateTransitions(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam,
|
||||
final LoanStateTransitionCommand command) {
|
||||
|
||||
LocalDate eventDate = this.apiDataConversionService.convertFrom(
|
||||
command.getEventDateFormatted(), "eventDateFormatted",
|
||||
LocalDate eventLocalDate = this.apiDataConversionService.convertFrom(
|
||||
command.getEventDate(), "eventDate",
|
||||
command.getDateFormat());
|
||||
|
||||
command.setLoanId(loanId);
|
||||
command.setEventDate(eventDate);
|
||||
command.setEventLocalDate(eventLocalDate);
|
||||
|
||||
Response response = null;
|
||||
|
||||
@@ -210,7 +210,7 @@ public class LoansApiResource {
|
||||
response = Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
UndoStateTransitionCommand undoCommand = new UndoStateTransitionCommand(loanId, command.getComment());
|
||||
UndoStateTransitionCommand undoCommand = new UndoStateTransitionCommand(loanId, command.getNote());
|
||||
if (is(commandParam, "undoapproval")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.undoLoanApproval(undoCommand);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
@@ -236,31 +236,37 @@ public class LoansApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public Response executeLoanTransaction(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@QueryParam("transactionType") final String transactionType,
|
||||
@QueryParam("command") final String commandParam,
|
||||
final LoanTransactionCommand command) {
|
||||
|
||||
Response response = null;
|
||||
command.setLoanId(loanId);
|
||||
|
||||
Locale clientLocale = this.apiDataConversionService.localeFromString(command.getLocale());
|
||||
|
||||
LocalDate transactionDate = apiDataConversionService.convertFrom(
|
||||
command.getTransactionDateFormatted(),
|
||||
"transactionDateFormatted", command.getDateFormat());
|
||||
command.setTransactionDate(transactionDate);
|
||||
LocalDate transactionLocalDate = apiDataConversionService.convertFrom(
|
||||
command.getTransactionDate(),
|
||||
"transactionDate", command.getDateFormat());
|
||||
command.setTransactionLocalDate(transactionLocalDate);
|
||||
|
||||
BigDecimal transactionAmount = apiDataConversionService.convertFrom(
|
||||
command.getTransactionAmountFormatted(),
|
||||
"transactionAmountFormatted", Locale.UK);
|
||||
command.setTransactionAmount(transactionAmount);
|
||||
BigDecimal transactionAmountValue = apiDataConversionService.convertFrom(
|
||||
command.getTransactionAmount(),
|
||||
"transactionAmount", clientLocale);
|
||||
command.setTransactionAmountValue(transactionAmountValue);
|
||||
|
||||
if (StringUtils.isNotBlank(transactionType)
|
||||
&& transactionType.trim().equalsIgnoreCase("waiver")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.waiveLoanAmount(command);
|
||||
return Response.ok().entity(identifier).build();
|
||||
if (is(commandParam, "repayment")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.makeLoanRepayment(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
} else if (is(commandParam, "waiver")) {
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.waiveLoanAmount(command);
|
||||
response = Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
if (response == null) {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam);
|
||||
}
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.makeLoanRepayment(command);
|
||||
return Response.ok().entity(identifier).build();
|
||||
return response;
|
||||
}
|
||||
|
||||
@GET
|
||||
@@ -269,37 +275,43 @@ public class LoansApiResource {
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public String retrieveNewRepaymentDetails(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@QueryParam("type") final String transactionType,
|
||||
@QueryParam("command") final String commandParam,
|
||||
@Context UriInfo uriInfo) {
|
||||
|
||||
String json = "";
|
||||
String selectedFields = loanRepaymentDefaultFieldList;
|
||||
if (StringUtils.isNotBlank(transactionType)
|
||||
&& transactionType.trim().equalsIgnoreCase("waiver")) {
|
||||
if (is(commandParam, "repayment")) {
|
||||
LoanRepaymentData loanRepaymentData = this.loanReadPlatformService
|
||||
.retrieveNewLoanRepaymentDetails(loanId);
|
||||
json = this.jsonFormattingService.convertRequest(loanRepaymentData,
|
||||
loanRepaymentFilterName, loanRepaymentAllowedFieldList, selectedFields,
|
||||
uriInfo.getQueryParameters());
|
||||
} else if (is(commandParam, "waiver")) {
|
||||
LoanRepaymentData loanWaiverData = this.loanReadPlatformService
|
||||
.retrieveNewLoanWaiverDetails(loanId);
|
||||
return this.jsonFormattingService.convertRequest(loanWaiverData,
|
||||
json = this.jsonFormattingService.convertRequest(loanWaiverData,
|
||||
loanRepaymentFilterName, loanRepaymentAllowedFieldList, selectedFields,
|
||||
uriInfo.getQueryParameters());
|
||||
}
|
||||
|
||||
LoanRepaymentData loanRepaymentData = this.loanReadPlatformService
|
||||
.retrieveNewLoanRepaymentDetails(loanId);
|
||||
return this.jsonFormattingService.convertRequest(loanRepaymentData,
|
||||
loanRepaymentFilterName, loanRepaymentAllowedFieldList, selectedFields,
|
||||
uriInfo.getQueryParameters());
|
||||
if (StringUtils.isBlank(json)) {
|
||||
throw new UnrecognizedQueryParamException("command", commandParam);
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{loanId}/transactions/{repaymentId}")
|
||||
@Path("{loanId}/transactions/{transactionId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public String retrieveRepaymentDetails(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@PathParam("repaymentId") final Long repaymentId,
|
||||
@PathParam("transactionId") final Long transactionId,
|
||||
@Context UriInfo uriInfo) {
|
||||
|
||||
LoanRepaymentData loanRepaymentData = this.loanReadPlatformService
|
||||
.retrieveLoanRepaymentDetails(loanId, repaymentId);
|
||||
.retrieveLoanRepaymentDetails(loanId, transactionId);
|
||||
|
||||
String selectedFields = "";
|
||||
return this.jsonFormattingService.convertRequest(loanRepaymentData,
|
||||
@@ -308,29 +320,30 @@ public class LoansApiResource {
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{loanId}/transactions/{repaymentId}")
|
||||
@Path("{loanId}/transactions/{transactionId}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public Response adjustLoanTransaction(
|
||||
@PathParam("loanId") final Long loanId,
|
||||
@PathParam("repaymentId") final Long repaymentId,
|
||||
@PathParam("transactionId") final Long transactionId,
|
||||
final AdjustLoanTransactionCommand command) {
|
||||
|
||||
command.setLoanId(loanId);
|
||||
command.setRepaymentId(repaymentId);
|
||||
command.setTransactionId(transactionId);
|
||||
|
||||
Locale clientLocale = this.apiDataConversionService.localeFromString(command.getLocale());
|
||||
|
||||
LocalDate transactionDate = apiDataConversionService.convertFrom(
|
||||
command.getTransactionDateFormatted(),
|
||||
"transactionDateFormatted", command.getDateFormat());
|
||||
command.setTransactionDate(transactionDate);
|
||||
LocalDate transactionLocalDate = apiDataConversionService.convertFrom(
|
||||
command.getTransactionDate(),
|
||||
"transactionDate", command.getDateFormat());
|
||||
command.setTransactionLocalDate(transactionLocalDate);
|
||||
|
||||
BigDecimal transactionAmount = apiDataConversionService.convertFrom(
|
||||
command.getTransactionAmountFormatted(),
|
||||
"transactionAmountFormatted", Locale.UK);
|
||||
command.setTransactionAmount(transactionAmount);
|
||||
BigDecimal transactionAmountValue = apiDataConversionService.convertFrom(
|
||||
command.getTransactionAmount(),
|
||||
"transactionAmount", clientLocale);
|
||||
command.setTransactionAmountValue(transactionAmountValue);
|
||||
|
||||
EntityIdentifier identifier = this.loanWritePlatformService
|
||||
.adjustLoanTransaction(command);
|
||||
EntityIdentifier identifier = this.loanWritePlatformService.adjustLoanTransaction(command);
|
||||
|
||||
return Response.ok().entity(identifier).build();
|
||||
}
|
||||
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
@XmlRootElement
|
||||
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() {
|
||||
//
|
||||
}
|
||||
|
||||
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.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;
|
||||
}
|
||||
|
||||
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() {
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
@XmlRootElement
|
||||
public class CalculateLoanScheduleCommand {
|
||||
|
||||
private String currencyCode;
|
||||
private Integer digitsAfterDecimalValue;
|
||||
private BigDecimal principalValue;
|
||||
private BigDecimal inArrearsToleranceValue;
|
||||
|
||||
private Integer repaymentEveryValue;
|
||||
private Integer repaymentFrequencyType;
|
||||
private Integer numberOfRepaymentsValue;
|
||||
|
||||
private BigDecimal interestRatePerPeriodValue;
|
||||
private Integer interestRateFrequencyType;
|
||||
private Integer amortizationType;
|
||||
private Integer interestType;
|
||||
private Integer interestCalculationPeriodType;
|
||||
|
||||
private LocalDate expectedDisbursementLocalDate;
|
||||
private LocalDate repaymentsStartingFromLocalDate;
|
||||
private LocalDate interestChargedFromLocalDate;
|
||||
|
||||
protected CalculateLoanScheduleCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public CalculateLoanScheduleCommand(final String currencyCode,
|
||||
final Integer digitsAfterDecimal, 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 LocalDate expectedDisbursementDate,
|
||||
final LocalDate repaymentsStartingFromDate, final LocalDate interestCalculatedFromDate) {
|
||||
|
||||
this.currencyCode = currencyCode;
|
||||
this.digitsAfterDecimalValue = digitsAfterDecimal;
|
||||
if (principal != null) {
|
||||
this.principalValue = BigDecimal.valueOf(principal.doubleValue());
|
||||
}
|
||||
if (interestRatePerPeriod != null) {
|
||||
this.interestRatePerPeriodValue = BigDecimal.valueOf(interestRatePerPeriod.doubleValue());
|
||||
}
|
||||
this.interestRateFrequencyType = interestRateFrequencyMethod;
|
||||
this.interestType = interestMethod;
|
||||
this.interestCalculationPeriodType = interestCalculationPeriodMethod;
|
||||
this.repaymentEveryValue = repaymentEvery;
|
||||
this.repaymentFrequencyType = repaymentFrequency;
|
||||
this.numberOfRepaymentsValue = numberOfRepayments;
|
||||
this.amortizationType = amortizationMethod;
|
||||
|
||||
this.expectedDisbursementLocalDate = expectedDisbursementDate;
|
||||
this.repaymentsStartingFromLocalDate = repaymentsStartingFromDate;
|
||||
this.interestChargedFromLocalDate= interestCalculatedFromDate;
|
||||
}
|
||||
|
||||
public String getCurrencyCode() {
|
||||
return currencyCode;
|
||||
}
|
||||
|
||||
public void setCurrencyCode(String currencyCode) {
|
||||
this.currencyCode = currencyCode;
|
||||
}
|
||||
|
||||
public Integer getDigitsAfterDecimalValue() {
|
||||
return digitsAfterDecimalValue;
|
||||
}
|
||||
|
||||
public void setDigitsAfterDecimalValue(Integer digitsAfterDecimalValue) {
|
||||
this.digitsAfterDecimalValue = digitsAfterDecimalValue;
|
||||
}
|
||||
|
||||
public BigDecimal getPrincipalValue() {
|
||||
return principalValue;
|
||||
}
|
||||
|
||||
public void setPrincipalValue(BigDecimal principalValue) {
|
||||
this.principalValue = principalValue;
|
||||
}
|
||||
|
||||
public BigDecimal getInArrearsToleranceValue() {
|
||||
return inArrearsToleranceValue;
|
||||
}
|
||||
|
||||
public void setInArrearsToleranceValue(BigDecimal inArrearsToleranceValue) {
|
||||
this.inArrearsToleranceValue = inArrearsToleranceValue;
|
||||
}
|
||||
|
||||
public Integer getRepaymentEveryValue() {
|
||||
return repaymentEveryValue;
|
||||
}
|
||||
|
||||
public void setRepaymentEveryValue(Integer repaymentEveryValue) {
|
||||
this.repaymentEveryValue = repaymentEveryValue;
|
||||
}
|
||||
|
||||
public Integer getRepaymentFrequencyType() {
|
||||
return repaymentFrequencyType;
|
||||
}
|
||||
|
||||
public void setRepaymentFrequencyType(Integer repaymentFrequencyType) {
|
||||
this.repaymentFrequencyType = repaymentFrequencyType;
|
||||
}
|
||||
|
||||
public Integer getNumberOfRepaymentsValue() {
|
||||
return numberOfRepaymentsValue;
|
||||
}
|
||||
|
||||
public void setNumberOfRepaymentsValue(Integer numberOfRepaymentsValue) {
|
||||
this.numberOfRepaymentsValue = numberOfRepaymentsValue;
|
||||
}
|
||||
|
||||
public BigDecimal getInterestRatePerPeriodValue() {
|
||||
return interestRatePerPeriodValue;
|
||||
}
|
||||
|
||||
public void setInterestRatePerPeriodValue(BigDecimal interestRatePerPeriodValue) {
|
||||
this.interestRatePerPeriodValue = interestRatePerPeriodValue;
|
||||
}
|
||||
|
||||
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 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;
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
||||
@XmlRootElement
|
||||
public class ImportLoanCommand {
|
||||
|
||||
private List<SubmitApproveDisburseLoanCommand> loans = new ArrayList<SubmitApproveDisburseLoanCommand>();
|
||||
|
||||
public ImportLoanCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public List<SubmitApproveDisburseLoanCommand> getLoans() {
|
||||
return loans;
|
||||
}
|
||||
|
||||
public void setLoans(List<SubmitApproveDisburseLoanCommand> loans) {
|
||||
this.loans = loans;
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class ImportLoanRepaymentsCommand {
|
||||
|
||||
private List<LoanTransactionCommand> repayments = new ArrayList<LoanTransactionCommand>();
|
||||
|
||||
public ImportLoanRepaymentsCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public List<LoanTransactionCommand> getRepayments() {
|
||||
return repayments;
|
||||
}
|
||||
|
||||
public void setRepayments(List<LoanTransactionCommand> repayments) {
|
||||
this.repayments = repayments;
|
||||
}
|
||||
}
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
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
|
||||
*/
|
||||
@XmlRootElement
|
||||
public class LoanStateTransitionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private String dateFormat;
|
||||
private String eventDate;
|
||||
private LocalDate eventLocalDate;
|
||||
private String note;
|
||||
|
||||
protected LoanStateTransitionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public LoanStateTransitionCommand(final Long loanId, final LocalDate eventDate, final String comment) {
|
||||
this.loanId = loanId;
|
||||
this.eventLocalDate = eventDate;
|
||||
this.note = comment;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public String 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;
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
@XmlRootElement
|
||||
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;
|
||||
|
||||
protected LoanTransactionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public LoanTransactionCommand(final Long loanId,
|
||||
final LocalDate paymentDate, final String note,
|
||||
final BigDecimal paymentAmount) {
|
||||
this.loanId = loanId;
|
||||
this.transactionLocalDate = paymentDate;
|
||||
this.note = note;
|
||||
this.transactionAmountValue = paymentAmount;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public String 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 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
* Command used for add or edit notes.
|
||||
*/
|
||||
@XmlRootElement
|
||||
public class NoteCommand {
|
||||
|
||||
private Long id;
|
||||
private Long clientId;
|
||||
private Long loanId;
|
||||
private Long loanTransactionId;
|
||||
private String note;
|
||||
|
||||
public NoteCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public void setClientId(Long clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
return loanId;
|
||||
}
|
||||
|
||||
public void setLoanId(Long loanId) {
|
||||
this.loanId = loanId;
|
||||
}
|
||||
|
||||
public Long getLoanTransactionId() {
|
||||
return loanTransactionId;
|
||||
}
|
||||
|
||||
public void setLoanTransactionId(Long loanTransactionId) {
|
||||
this.loanTransactionId = loanTransactionId;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
|
||||
@XmlRootElement
|
||||
public class SubmitApproveDisburseLoanCommand {
|
||||
|
||||
private SubmitLoanApplicationCommand submitLoanApplicationCommand;
|
||||
private LoanStateTransitionCommand approveLoanCommand;
|
||||
private LoanStateTransitionCommand disburseLoanCommand;
|
||||
|
||||
public SubmitApproveDisburseLoanCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public SubmitLoanApplicationCommand getSubmitLoanApplicationCommand() {
|
||||
return submitLoanApplicationCommand;
|
||||
}
|
||||
|
||||
public void setSubmitLoanApplicationCommand(
|
||||
SubmitLoanApplicationCommand submitLoanApplicationCommand) {
|
||||
this.submitLoanApplicationCommand = submitLoanApplicationCommand;
|
||||
}
|
||||
|
||||
public LoanStateTransitionCommand getApproveLoanCommand() {
|
||||
return approveLoanCommand;
|
||||
}
|
||||
|
||||
public void setApproveLoanCommand(LoanStateTransitionCommand approveLoanCommand) {
|
||||
this.approveLoanCommand = approveLoanCommand;
|
||||
}
|
||||
|
||||
public LoanStateTransitionCommand getDisburseLoanCommand() {
|
||||
return disburseLoanCommand;
|
||||
}
|
||||
|
||||
public void setDisburseLoanCommand(LoanStateTransitionCommand disburseLoanCommand) {
|
||||
this.disburseLoanCommand = disburseLoanCommand;
|
||||
}
|
||||
}
|
||||
+365
@@ -0,0 +1,365 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
|
||||
@XmlRootElement
|
||||
public class SubmitLoanApplicationCommand {
|
||||
|
||||
private Long clientId;
|
||||
private Long productId;
|
||||
|
||||
// product
|
||||
private String locale;
|
||||
private String currencyCode;
|
||||
private String digitsAfterDecimal;
|
||||
private Integer digitsAfterDecimalValue;
|
||||
private BigDecimal principalValue;
|
||||
private String principal;
|
||||
private BigDecimal inArrearsToleranceValue;
|
||||
private String inArrearsTolerance;
|
||||
|
||||
private String numberOfRepayments;
|
||||
private Integer numberOfRepaymentsValue;
|
||||
private String repaymentEvery;
|
||||
private Integer repaymentEveryValue;
|
||||
|
||||
private String interestRatePerPeriod;
|
||||
private BigDecimal interestRatePerPeriodValue;
|
||||
|
||||
private Integer repaymentFrequencyType;
|
||||
private Integer interestRateFrequencyType;
|
||||
private Integer amortizationType;
|
||||
private Integer interestType;
|
||||
private Integer interestCalculationPeriodType;
|
||||
// end of product related fields
|
||||
|
||||
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 LoanSchedule loanSchedule;
|
||||
|
||||
protected SubmitLoanApplicationCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public SubmitLoanApplicationCommand(final Long clientId,
|
||||
final Long productId, final LocalDate submittedOnDate,
|
||||
final String submittedOnNote,
|
||||
final LocalDate expectedDisbursementDate,
|
||||
final LocalDate repaymentsStartingFromDate,
|
||||
final LocalDate interestChargedFromLocalDate,
|
||||
final LoanSchedule loanSchedule, final String currencyCode,
|
||||
final Integer digitsAfterDecimal, 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) {
|
||||
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.currencyCode = currencyCode;
|
||||
this.digitsAfterDecimalValue = digitsAfterDecimal;
|
||||
this.principalValue = BigDecimal.valueOf(principal.doubleValue());
|
||||
this.interestRatePerPeriodValue = BigDecimal.valueOf(interestRatePerPeriod.doubleValue());
|
||||
this.interestRateFrequencyType = interestRateFrequencyMethod;
|
||||
this.interestType = interestMethod;
|
||||
this.interestCalculationPeriodType = interestCalculationPeriodMethod;
|
||||
this.repaymentEveryValue = repaymentEvery;
|
||||
this.repaymentFrequencyType = repaymentFrequency;
|
||||
this.numberOfRepaymentsValue = numberOfRepayments;
|
||||
this.amortizationType = amortizationMethod;
|
||||
}
|
||||
|
||||
public CalculateLoanScheduleCommand toCalculateLoanScheduleCommand() {
|
||||
return new CalculateLoanScheduleCommand(currencyCode, digitsAfterDecimalValue, 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;
|
||||
}
|
||||
|
||||
public LoanSchedule getLoanSchedule() {
|
||||
return this.loanSchedule;
|
||||
}
|
||||
|
||||
public void setLoanSchedule(final LoanSchedule loanSchedule) {
|
||||
this.loanSchedule = loanSchedule;
|
||||
}
|
||||
|
||||
public String getExternalId() {
|
||||
return externalId;
|
||||
}
|
||||
|
||||
public void setExternalId(String externalId) {
|
||||
this.externalId = externalId;
|
||||
}
|
||||
|
||||
public String getCurrencyCode() {
|
||||
return currencyCode;
|
||||
}
|
||||
|
||||
public void setCurrencyCode(String currencyCode) {
|
||||
this.currencyCode = currencyCode;
|
||||
}
|
||||
|
||||
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 String getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public void setLocale(String locale) {
|
||||
this.locale = locale;
|
||||
}
|
||||
|
||||
public String getDigitsAfterDecimal() {
|
||||
return digitsAfterDecimal;
|
||||
}
|
||||
|
||||
public void setDigitsAfterDecimal(String digitsAfterDecimal) {
|
||||
this.digitsAfterDecimal = digitsAfterDecimal;
|
||||
}
|
||||
|
||||
public Integer getDigitsAfterDecimalValue() {
|
||||
return digitsAfterDecimalValue;
|
||||
}
|
||||
|
||||
public void setDigitsAfterDecimalValue(Integer digitsAfterDecimalValue) {
|
||||
this.digitsAfterDecimalValue = digitsAfterDecimalValue;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package org.mifosng.platform.api.commands;
|
||||
|
||||
public class UndoStateTransitionCommand {
|
||||
|
||||
private Long loanId;
|
||||
private String note;
|
||||
|
||||
protected UndoStateTransitionCommand() {
|
||||
//
|
||||
}
|
||||
|
||||
public UndoStateTransitionCommand(final Long loanId, final String note) {
|
||||
this.loanId = loanId;
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public Long getLoanId() {
|
||||
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
-1
@@ -1,8 +1,8 @@
|
||||
package org.mifosng.platform.client.service;
|
||||
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.NoteCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface ClientWritePlatformService {
|
||||
|
||||
+1
-1
@@ -6,8 +6,8 @@ import static org.mifosng.platform.Specifications.officesThatMatch;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.command.NoteCommand;
|
||||
import org.mifosng.platform.api.commands.ClientCommand;
|
||||
import org.mifosng.platform.api.commands.NoteCommand;
|
||||
import org.mifosng.platform.client.domain.Client;
|
||||
import org.mifosng.platform.client.domain.ClientRepository;
|
||||
import org.mifosng.platform.client.domain.Note;
|
||||
|
||||
+9
-9
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class AdjustLoanTransactionCommandValidator {
|
||||
@@ -19,8 +19,8 @@ public class AdjustLoanTransactionCommandValidator {
|
||||
public void validate() {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
if (command.getRepaymentId() == null || command.getRepaymentId().longValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.id.is.invalid", "The parameter repaymentId is invalid.", "repaymentId", command.getRepaymentId());
|
||||
if (command.getTransactionId() == null || command.getTransactionId().longValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.id.is.invalid", "The parameter repaymentId is invalid.", "transactionId", command.getTransactionId());
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
@@ -29,18 +29,18 @@ public class AdjustLoanTransactionCommandValidator {
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (command.getTransactionDate() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.date.cannot.be.blank", "The parameter transactionDateFormatted cannot be blank.", "transactionDateFormatted");
|
||||
if (command.getTransactionLocalDate() == 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.getTransactionAmount() == null || command.getTransactionAmount().doubleValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.must.be.greater.than.zero", "The parameter transactionAmountFormatted less than zero.", "transactionAmountFormatted", command.getTransactionAmountFormatted());
|
||||
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());
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment()) && command.getComment().length() > 1000) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.note.exceeds.max.length", "The parameter comment exceeds max allowed size of {0}", "comment", 1000);
|
||||
if (StringUtils.isNotBlank(command.getNote()) && command.getNote().length() > 1000) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.note.exceeds.max.length", "The parameter note exceeds max allowed size of {0}", "note", 1000);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.DataValidatorBuilder;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class CalculateLoanScheduleCommandValidator {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ package org.mifosng.platform.loan.service;
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.data.LoanPayoffReadModel;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
|
||||
public interface CalculationPlatformService {
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ import org.mifosng.data.CurrencyData;
|
||||
import org.mifosng.data.LoanPayoffReadModel;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.MoneyData;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.currency.domain.ApplicationCurrency;
|
||||
import org.mifosng.platform.currency.domain.ApplicationCurrencyRepository;
|
||||
import org.mifosng.platform.currency.domain.MonetaryCurrency;
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.List;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.MoneyData;
|
||||
import org.mifosng.data.ScheduledLoanInstallment;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.client.domain.Client;
|
||||
import org.mifosng.platform.client.domain.ClientRepository;
|
||||
import org.mifosng.platform.currency.domain.MonetaryCurrency;
|
||||
|
||||
+1
-1
@@ -14,5 +14,5 @@ public interface LoanReadPlatformService {
|
||||
|
||||
LoanRepaymentData retrieveNewLoanWaiverDetails(Long loanId);
|
||||
|
||||
LoanRepaymentData retrieveLoanRepaymentDetails(Long loanId, Long repaymentId);
|
||||
LoanRepaymentData retrieveLoanRepaymentDetails(Long loanId, Long transactionId);
|
||||
}
|
||||
+1
-5
@@ -36,7 +36,6 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
// private final SimpleJdbcTemplate jdbcTemplate;
|
||||
private final PlatformSecurityContext context;
|
||||
private final LoanRepository loanRepository;
|
||||
private final ApplicationCurrencyRepository applicationCurrencyRepository;
|
||||
@@ -46,7 +45,6 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
@Autowired
|
||||
public LoanReadPlatformServiceImpl(final PlatformSecurityContext context,
|
||||
// final DataSource dataSource,
|
||||
final LoanRepository loanRepository, final LoanTransactionRepository loanTransactionRepository, final ApplicationCurrencyRepository applicationCurrencyRepository,
|
||||
final LoanProductReadPlatformService loanProductReadPlatformService, final ClientReadPlatformService clientReadPlatformService) {
|
||||
this.context = context;
|
||||
@@ -55,7 +53,6 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
this.applicationCurrencyRepository = applicationCurrencyRepository;
|
||||
this.loanProductReadPlatformService = loanProductReadPlatformService;
|
||||
this.clientReadPlatformService = clientReadPlatformService;
|
||||
// this.jdbcTemplate = new SimpleJdbcTemplate(dataSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -264,8 +261,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
// TODO - OPTIMIZE - write simple sql query to fetch back date of
|
||||
// possible next transaction date.
|
||||
Loan loan = this.loanRepository.findOne(loansThatMatch(
|
||||
currentUser.getOrganisation(), loanId));
|
||||
Loan loan = this.loanRepository.findOne(loansThatMatch(currentUser.getOrganisation(), loanId));
|
||||
if (loan == null) {
|
||||
throw new LoanNotFoundException(loanId);
|
||||
}
|
||||
|
||||
+6
-15
@@ -3,9 +3,9 @@ package org.mifosng.platform.loan.service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.DataValidatorBuilder;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class LoanStateTransitionCommandValidator {
|
||||
@@ -19,20 +19,11 @@ public class LoanStateTransitionCommandValidator {
|
||||
public void validate() {
|
||||
List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||
|
||||
if (command.getLoanId() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.id.is.invalid", "The parameter loanId is invalid.", "loanId", command.getLoanId());
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan.transition");
|
||||
|
||||
if (command.getEventDate() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.state.transition.date.cannot.be.blank", "The parameter eventDate cannot be blank.", "eventDate");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment()) && command.getComment().length() > 1000) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.note.exceeds.max.length", "The parameter comment exceeds mas allowed length of {0}.", "comment");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
baseDataValidator.reset().parameter("loanId").value(command.getLoanId()).notNull();
|
||||
baseDataValidator.reset().parameter("eventDate").value(command.getEventLocalDate()).notNull();
|
||||
baseDataValidator.reset().parameter("note").value(command.getNote()).notExceedingLengthOf(1000);
|
||||
|
||||
if (!dataValidationErrors.isEmpty()) {
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
|
||||
+6
-7
@@ -5,7 +5,7 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class LoanTransactionCommandValidator {
|
||||
@@ -24,17 +24,17 @@ public class LoanTransactionCommandValidator {
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (command.getTransactionDate() == null) {
|
||||
if (command.getTransactionLocalDate() == null) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.date.cannot.be.blank", "The parameter transactionDateFormatted cannot be blank.", "transactionDateFormatted");
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (command.getTransactionAmount() == null || command.getTransactionAmount().doubleValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.must.be.greater.than.zero", "The parameter transactionAmountFormatted less than zero.", "transactionAmountFormatted", command.getTransactionAmountFormatted());
|
||||
if (command.getTransactionAmount() == null || command.getTransactionAmountValue().doubleValue() <= 0) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.repayment.must.be.greater.than.zero", "The parameter transactionAmountFormatted less than zero.", "transactionAmountFormatted", command.getTransactionAmountValue());
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment()) && command.getComment().length() > 1000) {
|
||||
if (StringUtils.isNotBlank(command.getNote()) && command.getNote().length() > 1000) {
|
||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.note.exceeds.max.length", "The parameter comment exceeds max allowed size of {0}", "comment", 1000);
|
||||
dataValidationErrors.add(error);
|
||||
}
|
||||
@@ -43,5 +43,4 @@ public class LoanTransactionCommandValidator {
|
||||
throw new PlatformApiDataValidationException("validation.msg.validation.errors.exist", "Validation errors exist.", dataValidationErrors);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -1,11 +1,11 @@
|
||||
package org.mifosng.platform.loan.service;
|
||||
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.data.command.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.UndoStateTransitionCommand;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
|
||||
public interface LoanWritePlatformService {
|
||||
|
||||
+63
-50
@@ -10,17 +10,18 @@ import org.joda.time.LocalDate;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.LoanSchedule;
|
||||
import org.mifosng.data.ScheduledLoanInstallment;
|
||||
import org.mifosng.data.command.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.LoanStateTransitionCommand;
|
||||
import org.mifosng.data.command.LoanTransactionCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.data.command.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.AdjustLoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.LoanStateTransitionCommand;
|
||||
import org.mifosng.platform.api.commands.LoanTransactionCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.UndoStateTransitionCommand;
|
||||
import org.mifosng.platform.client.domain.Note;
|
||||
import org.mifosng.platform.client.domain.NoteRepository;
|
||||
import org.mifosng.platform.currency.domain.MonetaryCurrency;
|
||||
import org.mifosng.platform.currency.domain.Money;
|
||||
import org.mifosng.platform.exceptions.LoanNotFoundException;
|
||||
import org.mifosng.platform.exceptions.LoanTransactionNotFoundException;
|
||||
import org.mifosng.platform.exceptions.NoAuthorizationException;
|
||||
import org.mifosng.platform.exceptions.PlatformDomainRuleException;
|
||||
import org.mifosng.platform.loan.domain.DefaultLoanLifecycleStateMachine;
|
||||
@@ -138,16 +139,18 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
if (loan == null) {
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotApproveLoanInPast()) {
|
||||
|
||||
LocalDate eventDate = command.getEventLocalDate();
|
||||
if (this.isBeforeToday(eventDate) && currentUser.canNotApproveLoanInPast()) {
|
||||
throw new NoAuthorizationException("User has no authority to approve loan with a date in the past.");
|
||||
}
|
||||
|
||||
loan.approve(command.getEventDate(), defaultLoanLifecycleStateMachine());
|
||||
loan.approve(eventDate, defaultLoanLifecycleStateMachine());
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -168,8 +171,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
loan.undoApproval(defaultLoanLifecycleStateMachine());
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -190,15 +194,17 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotRejectLoanInPast()) {
|
||||
LocalDate eventDate = command.getEventLocalDate();
|
||||
if (this.isBeforeToday(eventDate) && currentUser.canNotRejectLoanInPast()) {
|
||||
throw new NoAuthorizationException("User has no authority to reject loan with a date in the past.");
|
||||
}
|
||||
|
||||
loan.reject(command.getEventDate(), defaultLoanLifecycleStateMachine());
|
||||
loan.reject(eventDate, defaultLoanLifecycleStateMachine());
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -219,15 +225,17 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotWithdrawByClientLoanInPast()) {
|
||||
LocalDate eventDate = command.getEventLocalDate();
|
||||
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.");
|
||||
}
|
||||
|
||||
loan.withdraw(command.getEventDate(), defaultLoanLifecycleStateMachine());
|
||||
loan.withdraw(eventDate, defaultLoanLifecycleStateMachine());
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -248,15 +256,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
if (this.isBeforeToday(command.getEventDate()) && currentUser.canNotDisburseLoanInPast()) {
|
||||
String noteText = command.getNote();
|
||||
LocalDate actualDisbursementDate = command.getEventLocalDate();
|
||||
if (this.isBeforeToday(actualDisbursementDate) && currentUser.canNotDisburseLoanInPast()) {
|
||||
throw new NoAuthorizationException("User has no authority to disburse loan with a date in the past.");
|
||||
}
|
||||
|
||||
LocalDate disbursedOn = command.getEventDate();
|
||||
String comment = command.getComment();
|
||||
|
||||
LocalDate actualDisbursementDate = new LocalDate(disbursedOn);
|
||||
|
||||
if (loan.isRepaymentScheduleRegenerationRequiredForDisbursement(actualDisbursementDate)) {
|
||||
|
||||
LocalDate repaymentsStartingFromDate = loan.getExpectedFirstRepaymentOnDate();
|
||||
@@ -309,15 +314,15 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
interest.getAmount());
|
||||
modifiedLoanRepaymentSchedule.add(installment);
|
||||
}
|
||||
loan.disburseWithModifiedRepaymentSchedule(disbursedOn, comment, modifiedLoanRepaymentSchedule, defaultLoanLifecycleStateMachine());
|
||||
loan.disburseWithModifiedRepaymentSchedule(actualDisbursementDate, noteText, modifiedLoanRepaymentSchedule, defaultLoanLifecycleStateMachine());
|
||||
} else {
|
||||
loan.disburse(disbursedOn, defaultLoanLifecycleStateMachine());
|
||||
loan.disburse(actualDisbursementDate, defaultLoanLifecycleStateMachine());
|
||||
}
|
||||
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -343,8 +348,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanNote(currentUser.getOrganisation(), loan, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -365,21 +371,23 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
if (this.isBeforeToday(command.getTransactionDate()) && currentUser.canNotMakeRepaymentOnLoanInPast()) {
|
||||
LocalDate transactionDate = command.getTransactionLocalDate();
|
||||
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.getTransactionAmount());
|
||||
command.getTransactionAmountValue());
|
||||
|
||||
LoanTransaction loanRepayment = LoanTransaction.repayment(repayment, command.getTransactionDate());
|
||||
LoanTransaction loanRepayment = LoanTransaction.repayment(repayment, transactionDate);
|
||||
loan.makeRepayment(loanRepayment, defaultLoanLifecycleStateMachine());
|
||||
this.loanTransactionRepository.save(loanRepayment);
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanTransactionNote(currentUser.getOrganisation(), loan, loanRepayment, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanTransactionNote(currentUser.getOrganisation(), loan, loanRepayment, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -400,17 +408,20 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
throw new LoanNotFoundException(command.getLoanId());
|
||||
}
|
||||
|
||||
LoanTransaction transactionToAdjust = this.loanTransactionRepository
|
||||
.findOne(command.getRepaymentId());
|
||||
|
||||
LoanTransaction transactionToAdjust = this.loanTransactionRepository.findOne(command.getTransactionId());
|
||||
if (transactionToAdjust == null) {
|
||||
throw new LoanTransactionNotFoundException(command.getTransactionId());
|
||||
}
|
||||
|
||||
Money transactionAmount = Money.of(loan
|
||||
.getLoanRepaymentScheduleDetail().getPrincipal()
|
||||
.getCurrency(), command.getTransactionAmount());
|
||||
.getCurrency(), command.getTransactionAmountValue());
|
||||
|
||||
// adjustment is only supported for repayments and waivers at present
|
||||
LoanTransaction newTransactionDetail = LoanTransaction.repayment(transactionAmount, command.getTransactionDate());
|
||||
LocalDate transactionDate = command.getTransactionLocalDate();
|
||||
LoanTransaction newTransactionDetail = LoanTransaction.repayment(transactionAmount, transactionDate);
|
||||
if (transactionToAdjust.isWaiver()) {
|
||||
newTransactionDetail = LoanTransaction.waiver(transactionAmount, command.getTransactionDate());
|
||||
newTransactionDetail = LoanTransaction.waiver(transactionAmount, transactionDate);
|
||||
}
|
||||
|
||||
loan.adjustExistingTransaction(transactionToAdjust, newTransactionDetail, defaultLoanLifecycleStateMachine());
|
||||
@@ -419,9 +430,10 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanTransactionNote(currentUser.getOrganisation(),
|
||||
loan, newTransactionDetail, command.getComment());
|
||||
loan, newTransactionDetail, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
@@ -444,9 +456,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
Money waived = Money.of(loan.getLoanRepaymentScheduleDetail()
|
||||
.getPrincipal().getCurrency(),
|
||||
command.getTransactionAmount());
|
||||
command.getTransactionAmountValue());
|
||||
|
||||
LoanTransaction waiver = LoanTransaction.waiver(waived, command.getTransactionDate());
|
||||
LoanTransaction waiver = LoanTransaction.waiver(waived, command.getTransactionLocalDate());
|
||||
|
||||
loan.waive(waiver, defaultLoanLifecycleStateMachine());
|
||||
|
||||
@@ -454,8 +466,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
||||
|
||||
this.loanRepository.save(loan);
|
||||
|
||||
if (StringUtils.isNotBlank(command.getComment())) {
|
||||
Note note = Note.loanTransactionNote(currentUser.getOrganisation(), loan, waiver, command.getComment());
|
||||
String noteText = command.getNote();
|
||||
if (StringUtils.isNotBlank(noteText)) {
|
||||
Note note = Note.loanTransactionNote(currentUser.getOrganisation(), loan, waiver, noteText);
|
||||
this.noteRepository.save(note);
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.mifosng.data.ApiParameterError;
|
||||
import org.mifosng.data.command.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.data.command.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.api.commands.CalculateLoanScheduleCommand;
|
||||
import org.mifosng.platform.api.commands.SubmitLoanApplicationCommand;
|
||||
import org.mifosng.platform.exceptions.PlatformApiDataValidationException;
|
||||
|
||||
public class SubmitLoanApplicationCommandValidator {
|
||||
|
||||
@@ -7,10 +7,10 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.mifosng.data.command.ImportLoanCommand;
|
||||
import org.mifosng.data.command.ImportLoanRepaymentsCommand;
|
||||
import org.mifosng.platform.ImportPlatformService;
|
||||
import org.mifosng.platform.api.commands.ImportClientCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanRepaymentsCommand;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -7,10 +7,10 @@ import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.mifosng.data.command.ImportLoanCommand;
|
||||
import org.mifosng.data.command.ImportLoanRepaymentsCommand;
|
||||
import org.mifosng.platform.ImportPlatformService;
|
||||
import org.mifosng.platform.api.commands.ImportClientCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanCommand;
|
||||
import org.mifosng.platform.api.commands.ImportLoanRepaymentsCommand;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
Reference in New Issue
Block a user