some updates to fix issues from recent changes to updates.
This commit is contained in:
+71
-160
@@ -2,192 +2,103 @@ package org.mifosng.platform.api.commands;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
|
|
||||||
@XmlRootElement
|
/**
|
||||||
|
* Immutable command used when auto-calculating loan schedules based on loan terms.
|
||||||
|
*/
|
||||||
public class CalculateLoanScheduleCommand {
|
public class CalculateLoanScheduleCommand {
|
||||||
|
|
||||||
private Long productId;
|
private final Long productId;
|
||||||
private BigDecimal principalValue;
|
private final BigDecimal principal;
|
||||||
private BigDecimal inArrearsToleranceValue;
|
|
||||||
|
|
||||||
private Integer repaymentEveryValue;
|
private final Integer repaymentEvery;
|
||||||
private Integer repaymentFrequencyType;
|
private final Integer repaymentFrequencyType;
|
||||||
private Integer numberOfRepaymentsValue;
|
private final Integer numberOfRepayments;
|
||||||
|
|
||||||
private BigDecimal interestRatePerPeriodValue;
|
private final BigDecimal interestRatePerPeriod;
|
||||||
private Integer interestRateFrequencyType;
|
private final Integer interestRateFrequencyType;
|
||||||
private Integer amortizationType;
|
private final Integer amortizationType;
|
||||||
private Integer interestType;
|
private final Integer interestType;
|
||||||
private Integer interestCalculationPeriodType;
|
private final Integer interestCalculationPeriodType;
|
||||||
|
|
||||||
private LocalDate expectedDisbursementLocalDate;
|
private final LocalDate expectedDisbursementDate;
|
||||||
private LocalDate repaymentsStartingFromLocalDate;
|
private final LocalDate repaymentsStartingFromDate;
|
||||||
private LocalDate interestChargedFromLocalDate;
|
private final LocalDate interestChargedFromDate;
|
||||||
|
|
||||||
protected CalculateLoanScheduleCommand() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
public CalculateLoanScheduleCommand(
|
public CalculateLoanScheduleCommand(
|
||||||
final Long productId,
|
final Long productId,
|
||||||
final Number principal,
|
final BigDecimal principal,
|
||||||
final Number interestRatePerPeriod, Integer interestRateFrequencyMethod, final Integer interestMethod, final Integer interestCalculationPeriodMethod,
|
final BigDecimal interestRatePerPeriod, Integer interestRateFrequencyMethod, final Integer interestMethod, final Integer interestCalculationPeriodMethod,
|
||||||
final Integer repaymentEvery, final Integer repaymentFrequency, final Integer numberOfRepayments, Integer amortizationMethod,
|
final Integer repaymentEvery, final Integer repaymentFrequency, final Integer numberOfRepayments, Integer amortizationMethod,
|
||||||
final LocalDate expectedDisbursementDate,
|
final LocalDate expectedDisbursementDate,
|
||||||
final LocalDate repaymentsStartingFromDate, final LocalDate interestCalculatedFromDate) {
|
final LocalDate repaymentsStartingFromDate, final LocalDate interestCalculatedFromDate) {
|
||||||
|
|
||||||
this.productId = productId;
|
this.productId = productId;
|
||||||
if (principal != null) {
|
this.principal = principal;
|
||||||
this.principalValue = BigDecimal.valueOf(principal.doubleValue());
|
this.interestRatePerPeriod = interestRatePerPeriod;
|
||||||
}
|
|
||||||
if (interestRatePerPeriod != null) {
|
|
||||||
this.interestRatePerPeriodValue = BigDecimal.valueOf(interestRatePerPeriod.doubleValue());
|
|
||||||
}
|
|
||||||
this.interestRateFrequencyType = interestRateFrequencyMethod;
|
this.interestRateFrequencyType = interestRateFrequencyMethod;
|
||||||
this.interestType = interestMethod;
|
this.interestType = interestMethod;
|
||||||
this.interestCalculationPeriodType = interestCalculationPeriodMethod;
|
this.interestCalculationPeriodType = interestCalculationPeriodMethod;
|
||||||
this.repaymentEveryValue = repaymentEvery;
|
this.repaymentEvery = repaymentEvery;
|
||||||
this.repaymentFrequencyType = repaymentFrequency;
|
this.repaymentFrequencyType = repaymentFrequency;
|
||||||
this.numberOfRepaymentsValue = numberOfRepayments;
|
this.numberOfRepayments = numberOfRepayments;
|
||||||
this.amortizationType = amortizationMethod;
|
this.amortizationType = amortizationMethod;
|
||||||
|
|
||||||
this.expectedDisbursementLocalDate = expectedDisbursementDate;
|
this.expectedDisbursementDate = expectedDisbursementDate;
|
||||||
this.repaymentsStartingFromLocalDate = repaymentsStartingFromDate;
|
this.repaymentsStartingFromDate = repaymentsStartingFromDate;
|
||||||
this.interestChargedFromLocalDate= interestCalculatedFromDate;
|
this.interestChargedFromDate= 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getProductId() {
|
public Long getProductId() {
|
||||||
return productId;
|
return productId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProductId(Long productId) {
|
public BigDecimal getPrincipal() {
|
||||||
this.productId = productId;
|
return principal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRepaymentEvery() {
|
||||||
|
return repaymentEvery;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRepaymentFrequencyType() {
|
||||||
|
return repaymentFrequencyType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNumberOfRepayments() {
|
||||||
|
return numberOfRepayments;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getInterestRatePerPeriod() {
|
||||||
|
return interestRatePerPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-6
@@ -1,9 +1,5 @@
|
|||||||
package org.mifosng.platform.api.commands;
|
package org.mifosng.platform.api.commands;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
|
|
||||||
@XmlRootElement
|
|
||||||
public class SubmitApproveDisburseLoanCommand {
|
public class SubmitApproveDisburseLoanCommand {
|
||||||
|
|
||||||
private SubmitLoanApplicationCommand submitLoanApplicationCommand;
|
private SubmitLoanApplicationCommand submitLoanApplicationCommand;
|
||||||
@@ -27,7 +23,8 @@ public class SubmitApproveDisburseLoanCommand {
|
|||||||
return approveLoanCommand;
|
return approveLoanCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setApproveLoanCommand(LoanStateTransitionCommand approveLoanCommand) {
|
public void setApproveLoanCommand(
|
||||||
|
LoanStateTransitionCommand approveLoanCommand) {
|
||||||
this.approveLoanCommand = approveLoanCommand;
|
this.approveLoanCommand = approveLoanCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +32,8 @@ public class SubmitApproveDisburseLoanCommand {
|
|||||||
return disburseLoanCommand;
|
return disburseLoanCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisburseLoanCommand(LoanStateTransitionCommand disburseLoanCommand) {
|
public void setDisburseLoanCommand(
|
||||||
|
LoanStateTransitionCommand disburseLoanCommand) {
|
||||||
this.disburseLoanCommand = disburseLoanCommand;
|
this.disburseLoanCommand = disburseLoanCommand;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+7
-2
@@ -274,7 +274,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
|||||||
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||||
|
|
||||||
Set<String> supportedParams = new HashSet<String>(
|
Set<String> supportedParams = new HashSet<String>(
|
||||||
Arrays.asList("name", "description", "fundId", "currencyCode", "digitsAfterDecimalValue",
|
Arrays.asList("name", "description", "fundId", "currencyCode", "digitsAfterDecimal",
|
||||||
"principal", "inArrearsTolerance", "interestRatePerPeriod", "repaymentEvery", "numberOfRepayments",
|
"principal", "inArrearsTolerance", "interestRatePerPeriod", "repaymentEvery", "numberOfRepayments",
|
||||||
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType", "locale")
|
"repaymentFrequencyType", "interestRateFrequencyType", "amortizationType", "interestType", "interestCalculationPeriodType", "locale")
|
||||||
);
|
);
|
||||||
@@ -341,7 +341,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
|||||||
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
|
||||||
|
|
||||||
Set<String> supportedParams = new HashSet<String>(
|
Set<String> supportedParams = new HashSet<String>(
|
||||||
Arrays.asList("name", "externalId", "parentId", "openingDate")
|
Arrays.asList("name", "externalId", "parentId", "openingDate", "dateFormat")
|
||||||
);
|
);
|
||||||
|
|
||||||
checkForUnsupportedParameters(requestMap, supportedParams);
|
checkForUnsupportedParameters(requestMap, supportedParams);
|
||||||
@@ -654,6 +654,11 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
|
|||||||
paramValue = (String) requestMap.get(paramName);
|
paramValue = (String) requestMap.get(paramName);
|
||||||
modifiedParameters.add(paramName);
|
modifiedParameters.add(paramName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (paramValue != null) {
|
||||||
|
paramValue = paramValue.trim();
|
||||||
|
}
|
||||||
|
|
||||||
return paramValue;
|
return paramValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,15 +25,16 @@ public class Fund extends AbstractAuditableCustom<AppUser, Long> {
|
|||||||
@Column(name = "external_id", length=100)
|
@Column(name = "external_id", length=100)
|
||||||
private String externalId;
|
private String externalId;
|
||||||
|
|
||||||
public static Fund createNew(final String fundName) {
|
public static Fund createNew(final String fundName, final String externalId) {
|
||||||
return new Fund(fundName);
|
return new Fund(fundName, externalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Fund() {
|
protected Fund() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private Fund(final String fundName) {
|
private Fund(final String fundName, final String externalId) {
|
||||||
this.name = fundName;
|
this.name = StringUtils.defaultIfEmpty(fundName, null);
|
||||||
|
this.externalId = StringUtils.defaultIfEmpty(externalId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(final FundCommand command) {
|
public void update(final FundCommand command) {
|
||||||
|
|||||||
+2
-2
@@ -37,7 +37,7 @@ public class FundWritePlatformServiceJpaRepositoryImpl implements FundWritePlatf
|
|||||||
FundCommandValidator validator = new FundCommandValidator(command);
|
FundCommandValidator validator = new FundCommandValidator(command);
|
||||||
validator.validateForCreate();
|
validator.validateForCreate();
|
||||||
|
|
||||||
Fund fund = Fund.createNew(command.getName());
|
Fund fund = Fund.createNew(command.getName(), command.getExternalId());
|
||||||
|
|
||||||
this.fundRepository.saveAndFlush(fund);
|
this.fundRepository.saveAndFlush(fund);
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ public class FundWritePlatformServiceJpaRepositoryImpl implements FundWritePlatf
|
|||||||
}
|
}
|
||||||
fund.update(command);
|
fund.update(command);
|
||||||
|
|
||||||
this.fundRepository.save(fund);
|
this.fundRepository.saveAndFlush(fund);
|
||||||
|
|
||||||
return fund.getId();
|
return fund.getId();
|
||||||
} catch (DataIntegrityViolationException dve) {
|
} catch (DataIntegrityViolationException dve) {
|
||||||
|
|||||||
+14
-16
@@ -22,41 +22,39 @@ public class CalculateLoanScheduleCommandValidator {
|
|||||||
|
|
||||||
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan");
|
DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("loan");
|
||||||
|
|
||||||
// baseDataValidator.reset().parameter("currencyCode").value(command.getCurrencyCode()).notBlank();
|
baseDataValidator.reset().parameter("principal").value(command.getPrincipal()).notNull().positiveAmount();
|
||||||
// baseDataValidator.reset().parameter("digitsAfterDecimal").value(command.getDigitsAfterDecimalValue()).notNull().inMinMaxRange(0, 6);
|
|
||||||
baseDataValidator.reset().parameter("principal").value(command.getPrincipalValue()).notNull().positiveAmount();
|
|
||||||
baseDataValidator.reset().parameter("repaymentFrequencyType").value(command.getRepaymentFrequencyType()).notNull().inMinMaxRange(0, 3);
|
baseDataValidator.reset().parameter("repaymentFrequencyType").value(command.getRepaymentFrequencyType()).notNull().inMinMaxRange(0, 3);
|
||||||
baseDataValidator.reset().parameter("repaymentEvery").value(command.getRepaymentEveryValue()).notNull().greaterThanZero();
|
baseDataValidator.reset().parameter("repaymentEvery").value(command.getRepaymentEvery()).notNull().greaterThanZero();
|
||||||
baseDataValidator.reset().parameter("numberOfRepayments").value(command.getNumberOfRepaymentsValue()).notNull().greaterThanZero();
|
baseDataValidator.reset().parameter("numberOfRepayments").value(command.getNumberOfRepayments()).notNull().greaterThanZero();
|
||||||
baseDataValidator.reset().parameter("interestRatePerPeriod").value(command.getInterestRatePerPeriodValue()).notNull();
|
baseDataValidator.reset().parameter("interestRatePerPeriod").value(command.getInterestRatePerPeriod()).notNull();
|
||||||
baseDataValidator.reset().parameter("interestRateFrequencyType").value(command.getInterestRateFrequencyType()).notNull().inMinMaxRange(0, 3);
|
baseDataValidator.reset().parameter("interestRateFrequencyType").value(command.getInterestRateFrequencyType()).notNull().inMinMaxRange(0, 3);
|
||||||
baseDataValidator.reset().parameter("amortizationType").value(command.getAmortizationType()).notNull().inMinMaxRange(0, 1);
|
baseDataValidator.reset().parameter("amortizationType").value(command.getAmortizationType()).notNull().inMinMaxRange(0, 1);
|
||||||
baseDataValidator.reset().parameter("interestType").value(command.getInterestType()).notNull().inMinMaxRange(0, 1);
|
baseDataValidator.reset().parameter("interestType").value(command.getInterestType()).notNull().inMinMaxRange(0, 1);
|
||||||
baseDataValidator.reset().parameter("interestCalculationPeriodType").value(command.getInterestCalculationPeriodType()).notNull().inMinMaxRange(0, 1);
|
baseDataValidator.reset().parameter("interestCalculationPeriodType").value(command.getInterestCalculationPeriodType()).notNull().inMinMaxRange(0, 1);
|
||||||
|
|
||||||
baseDataValidator.reset().parameter("expectedDisbursementDate").value(command.getExpectedDisbursementLocalDate()).notNull();
|
baseDataValidator.reset().parameter("expectedDisbursementDate").value(command.getExpectedDisbursementDate()).notNull();
|
||||||
|
|
||||||
if (command.getExpectedDisbursementLocalDate() != null) {
|
if (command.getExpectedDisbursementDate() != null) {
|
||||||
if (command.getRepaymentsStartingFromLocalDate() != null
|
if (command.getRepaymentsStartingFromDate() != null
|
||||||
&& command.getExpectedDisbursementLocalDate().isAfter(command.getRepaymentsStartingFromLocalDate())) {
|
&& command.getExpectedDisbursementDate().isAfter(command.getRepaymentsStartingFromDate())) {
|
||||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.expectedDisbursementDate.cannot.be.after.first.repayment.date",
|
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.expectedDisbursementDate.cannot.be.after.first.repayment.date",
|
||||||
"The parameter expectedDisbursementDate has a date which falls after the given first repayment date.", "expectedDisbursementDate",
|
"The parameter expectedDisbursementDate has a date which falls after the given first repayment date.", "expectedDisbursementDate",
|
||||||
command.getExpectedDisbursementLocalDate(), command.getRepaymentsStartingFromLocalDate());
|
command.getExpectedDisbursementDate(), command.getRepaymentsStartingFromDate());
|
||||||
dataValidationErrors.add(error);
|
dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command.getRepaymentsStartingFromLocalDate() != null && command.getInterestChargedFromLocalDate() == null) {
|
if (command.getRepaymentsStartingFromDate() != null && command.getInterestChargedFromDate() == null) {
|
||||||
|
|
||||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.interestCalculatedFromDate.must.be.entered.when.using.repayments.startfrom.field",
|
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.interestCalculatedFromDate.must.be.entered.when.using.repayments.startfrom.field",
|
||||||
"The parameter interestCalculatedFromDate cannot be empty when first repayment date is provided.", "interestCalculatedFromDate", command.getRepaymentsStartingFromLocalDate());
|
"The parameter interestCalculatedFromDate cannot be empty when first repayment date is provided.", "interestCalculatedFromDate", command.getRepaymentsStartingFromDate());
|
||||||
dataValidationErrors.add(error);
|
dataValidationErrors.add(error);
|
||||||
} else if (command.getRepaymentsStartingFromLocalDate() == null && command.getInterestChargedFromLocalDate() != null) {
|
} else if (command.getRepaymentsStartingFromDate() == null && command.getInterestChargedFromDate() != null) {
|
||||||
|
|
||||||
// validate interestCalculatedFromDate is after or on repaymentsStartingFromDate
|
// validate interestCalculatedFromDate is after or on repaymentsStartingFromDate
|
||||||
if (command.getExpectedDisbursementLocalDate().isAfter(command.getInterestChargedFromLocalDate())) {
|
if (command.getExpectedDisbursementDate().isAfter(command.getInterestChargedFromDate())) {
|
||||||
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.interestChargedFromDate.cannot.be.before.disbursement.date",
|
ApiParameterError error = ApiParameterError.parameterError("validation.msg.loan.interestChargedFromDate.cannot.be.before.disbursement.date",
|
||||||
"The parameter interestCalculatedFromDate cannot be before the date given for expected disbursement.", "interestChargedFromDate", command.getInterestChargedFromLocalDate(), command.getExpectedDisbursementLocalDate());
|
"The parameter interestCalculatedFromDate cannot be before the date given for expected disbursement.", "interestChargedFromDate", command.getInterestChargedFromDate(), command.getExpectedDisbursementDate());
|
||||||
dataValidationErrors.add(error);
|
dataValidationErrors.add(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -62,14 +62,14 @@ public class CalculationPlatformServiceImpl implements
|
|||||||
CalculateLoanScheduleCommandValidator validator = new CalculateLoanScheduleCommandValidator(command);
|
CalculateLoanScheduleCommandValidator validator = new CalculateLoanScheduleCommandValidator(command);
|
||||||
validator.validate();
|
validator.validate();
|
||||||
|
|
||||||
final BigDecimal principalAmount = command.getPrincipalValue();
|
final BigDecimal principalAmount = command.getPrincipal();
|
||||||
final BigDecimal defaultNominalInterestRatePerPeriod = command.getInterestRatePerPeriodValue();
|
final BigDecimal defaultNominalInterestRatePerPeriod = command.getInterestRatePerPeriod();
|
||||||
final PeriodFrequencyType interestPeriodFrequencyType = PeriodFrequencyType.fromInt(command.getInterestRateFrequencyType());
|
final PeriodFrequencyType interestPeriodFrequencyType = PeriodFrequencyType.fromInt(command.getInterestRateFrequencyType());
|
||||||
final InterestMethod interestMethod = InterestMethod.fromInt(command.getInterestType());
|
final InterestMethod interestMethod = InterestMethod.fromInt(command.getInterestType());
|
||||||
final InterestCalculationPeriodMethod interestCalculationPeriodMethod = InterestCalculationPeriodMethod.fromInt(command.getInterestCalculationPeriodType());
|
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 PeriodFrequencyType repaymentFrequencyType = PeriodFrequencyType.fromInt(command.getRepaymentFrequencyType());
|
||||||
final Integer defaultNumberOfInstallments = command.getNumberOfRepaymentsValue();
|
final Integer defaultNumberOfInstallments = command.getNumberOfRepayments();
|
||||||
final AmortizationMethod amortizationMethod = AmortizationMethod.fromInt(command.getAmortizationType());
|
final AmortizationMethod amortizationMethod = AmortizationMethod.fromInt(command.getAmortizationType());
|
||||||
|
|
||||||
final BigDecimal defaultAnnualNominalInterestRate = this.aprCalculator.calculateFrom(interestPeriodFrequencyType, defaultNominalInterestRatePerPeriod);
|
final BigDecimal defaultAnnualNominalInterestRate = this.aprCalculator.calculateFrom(interestPeriodFrequencyType, defaultNominalInterestRatePerPeriod);
|
||||||
@@ -96,8 +96,8 @@ public class CalculationPlatformServiceImpl implements
|
|||||||
CurrencyData currencyData = new CurrencyData(applicationCurrency.getCode(), applicationCurrency.getName(), currency.getDigitsAfterDecimal(),
|
CurrencyData currencyData = new CurrencyData(applicationCurrency.getCode(), applicationCurrency.getName(), currency.getDigitsAfterDecimal(),
|
||||||
applicationCurrency.getDisplaySymbol(), applicationCurrency.getNameCode());
|
applicationCurrency.getDisplaySymbol(), applicationCurrency.getNameCode());
|
||||||
|
|
||||||
return loanScheduleGenerator.generate(loanScheduleInfo, command.getExpectedDisbursementLocalDate(), command.getRepaymentsStartingFromLocalDate(),
|
return loanScheduleGenerator.generate(loanScheduleInfo, command.getExpectedDisbursementDate(), command.getRepaymentsStartingFromDate(),
|
||||||
command.getInterestChargedFromLocalDate(), currencyData);
|
command.getInterestChargedFromDate(), currencyData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+4
-3
@@ -1,5 +1,6 @@
|
|||||||
package org.mifosng.platform.loan.service;
|
package org.mifosng.platform.loan.service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -263,8 +264,8 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
LocalDate repaymentsStartingFromDate = loan.getExpectedFirstRepaymentOnDate();
|
LocalDate repaymentsStartingFromDate = loan.getExpectedFirstRepaymentOnDate();
|
||||||
LocalDate interestCalculatedFromDate = loan.getInterestChargedFromDate();
|
LocalDate interestCalculatedFromDate = loan.getInterestChargedFromDate();
|
||||||
|
|
||||||
Number principalAsDecimal = loan.getLoanRepaymentScheduleDetail().getPrincipal().getAmount();
|
BigDecimal principalAsDecimal = loan.getLoanRepaymentScheduleDetail().getPrincipal().getAmount();
|
||||||
Number interestRatePerYear = loan.getLoanRepaymentScheduleDetail().getAnnualNominalInterestRate();
|
BigDecimal interestRatePerYear = loan.getLoanRepaymentScheduleDetail().getAnnualNominalInterestRate();
|
||||||
Integer numberOfInstallments = loan.getLoanRepaymentScheduleDetail().getNumberOfRepayments();
|
Integer numberOfInstallments = loan.getLoanRepaymentScheduleDetail().getNumberOfRepayments();
|
||||||
|
|
||||||
Integer repaidEvery = loan.getLoanRepaymentScheduleDetail().getRepayEvery();
|
Integer repaidEvery = loan.getLoanRepaymentScheduleDetail().getRepayEvery();
|
||||||
@@ -272,7 +273,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
Integer selectedRepaymentSchedule = loan.getLoanRepaymentScheduleDetail().getAmortizationMethod().getValue();
|
Integer selectedRepaymentSchedule = loan.getLoanRepaymentScheduleDetail().getAmortizationMethod().getValue();
|
||||||
|
|
||||||
// use annual percentage rate to re-calculate loan schedule for late disbursement
|
// use annual percentage rate to re-calculate loan schedule for late disbursement
|
||||||
Number interestRatePerPeriod = interestRatePerYear;
|
BigDecimal interestRatePerPeriod = interestRatePerYear;
|
||||||
Integer interestRateFrequencyMethod = PeriodFrequencyType.YEARS.getValue();
|
Integer interestRateFrequencyMethod = PeriodFrequencyType.YEARS.getValue();
|
||||||
|
|
||||||
Integer interestMethod = loan.getLoanRepaymentScheduleDetail().getInterestMethod().getValue();
|
Integer interestMethod = loan.getLoanRepaymentScheduleDetail().getInterestMethod().getValue();
|
||||||
|
|||||||
+1
-1
@@ -91,7 +91,7 @@ public class OfficeWritePlatformServiceJpaRepositoryImpl implements OfficeWriteP
|
|||||||
office.update(parent);
|
office.update(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.officeRepository.save(office);
|
this.officeRepository.saveAndFlush(office);
|
||||||
|
|
||||||
return office.getId();
|
return office.getId();
|
||||||
} catch (DataIntegrityViolationException dve) {
|
} catch (DataIntegrityViolationException dve) {
|
||||||
|
|||||||
Reference in New Issue
Block a user