tidy up validation of savings accounts.
This commit is contained in:
+3
-1
@@ -46,7 +46,9 @@ public enum SavingsCompoundingInterestPeriodType {
|
|||||||
public static Object[] integerValues() {
|
public static Object[] integerValues() {
|
||||||
List<Integer> values = new ArrayList<Integer>();
|
List<Integer> values = new ArrayList<Integer>();
|
||||||
for (SavingsCompoundingInterestPeriodType enumType : values()) {
|
for (SavingsCompoundingInterestPeriodType enumType : values()) {
|
||||||
values.add(enumType.getValue());
|
if (enumType.getValue() > 0) {
|
||||||
|
values.add(enumType.getValue());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return values.toArray();
|
return values.toArray();
|
||||||
|
|||||||
+14
@@ -5,6 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.portfolio.savings;
|
package org.mifosplatform.portfolio.savings;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <ul>
|
* <ul>
|
||||||
* People typically use either of the following settings when calculating there
|
* People typically use either of the following settings when calculating there
|
||||||
@@ -35,6 +38,17 @@ public enum SavingsInterestCalculationDaysInYearType {
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object[] integerValues() {
|
||||||
|
List<Integer> values = new ArrayList<Integer>();
|
||||||
|
for (SavingsInterestCalculationDaysInYearType enumType : values()) {
|
||||||
|
if (enumType.getValue() > 0) {
|
||||||
|
values.add(enumType.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return values.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
public static SavingsInterestCalculationDaysInYearType fromInt(final Integer type) {
|
public static SavingsInterestCalculationDaysInYearType fromInt(final Integer type) {
|
||||||
SavingsInterestCalculationDaysInYearType repaymentFrequencyType = SavingsInterestCalculationDaysInYearType.INVALID;
|
SavingsInterestCalculationDaysInYearType repaymentFrequencyType = SavingsInterestCalculationDaysInYearType.INVALID;
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
|
|||||||
+14
@@ -5,6 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.portfolio.savings;
|
package org.mifosplatform.portfolio.savings;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <ul>
|
* <ul>
|
||||||
* There are two methods to calculate the interest on a savings account:
|
* There are two methods to calculate the interest on a savings account:
|
||||||
@@ -49,6 +52,17 @@ public enum SavingsInterestCalculationType {
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object[] integerValues() {
|
||||||
|
List<Integer> values = new ArrayList<Integer>();
|
||||||
|
for (SavingsInterestCalculationType enumType : values()) {
|
||||||
|
if (enumType.getValue() > 0) {
|
||||||
|
values.add(enumType.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return values.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
public static SavingsInterestCalculationType fromInt(final Integer type) {
|
public static SavingsInterestCalculationType fromInt(final Integer type) {
|
||||||
SavingsInterestCalculationType repaymentFrequencyType = SavingsInterestCalculationType.INVALID;
|
SavingsInterestCalculationType repaymentFrequencyType = SavingsInterestCalculationType.INVALID;
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
|
|||||||
+14
@@ -5,6 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.portfolio.savings;
|
package org.mifosplatform.portfolio.savings;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The interest posting period is the span of time at the end of which savings
|
* The interest posting period is the span of time at the end of which savings
|
||||||
* earned but not yet credited/posted in a client's account is credited/posted.
|
* earned but not yet credited/posted in a client's account is credited/posted.
|
||||||
@@ -32,6 +35,17 @@ public enum SavingsPostingInterestPeriodType {
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object[] integerValues() {
|
||||||
|
List<Integer> values = new ArrayList<Integer>();
|
||||||
|
for (SavingsPostingInterestPeriodType enumType : values()) {
|
||||||
|
if (enumType.getValue() > 0) {
|
||||||
|
values.add(enumType.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return values.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
public static SavingsPostingInterestPeriodType fromInt(final Integer type) {
|
public static SavingsPostingInterestPeriodType fromInt(final Integer type) {
|
||||||
SavingsPostingInterestPeriodType repaymentFrequencyType = SavingsPostingInterestPeriodType.INVALID;
|
SavingsPostingInterestPeriodType repaymentFrequencyType = SavingsPostingInterestPeriodType.INVALID;
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
|
|||||||
+14
@@ -5,6 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.mifosplatform.portfolio.savings;
|
package org.mifosplatform.portfolio.savings;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public enum SavingsWithdrawalFeesType {
|
public enum SavingsWithdrawalFeesType {
|
||||||
|
|
||||||
INVALID(0, "savingsWithdrawalFeesType.invalid"), //
|
INVALID(0, "savingsWithdrawalFeesType.invalid"), //
|
||||||
@@ -27,6 +30,17 @@ public enum SavingsWithdrawalFeesType {
|
|||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object[] integerValues() {
|
||||||
|
List<Integer> values = new ArrayList<Integer>();
|
||||||
|
for (SavingsWithdrawalFeesType enumType : values()) {
|
||||||
|
if (enumType.getValue() > 0) {
|
||||||
|
values.add(enumType.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return values.toArray();
|
||||||
|
}
|
||||||
|
|
||||||
public static SavingsWithdrawalFeesType fromInt(final Integer type) {
|
public static SavingsWithdrawalFeesType fromInt(final Integer type) {
|
||||||
|
|
||||||
SavingsWithdrawalFeesType withdrawalFeeType = SavingsWithdrawalFeesType.INVALID;
|
SavingsWithdrawalFeesType withdrawalFeeType = SavingsWithdrawalFeesType.INVALID;
|
||||||
|
|||||||
+27
-10
@@ -10,6 +10,7 @@ import static org.mifosplatform.portfolio.savings.SavingsApiConstants.annualFeeA
|
|||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.annualFeeOnMonthDayParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.annualFeeOnMonthDayParamName;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.clientIdParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.clientIdParamName;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.externalIdParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.externalIdParamName;
|
||||||
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.fieldOfficerIdParamName;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.groupIdParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.groupIdParamName;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.interestCalculationDaysInYearTypeParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.interestCalculationDaysInYearTypeParamName;
|
||||||
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.interestCalculationTypeParamName;
|
import static org.mifosplatform.portfolio.savings.SavingsApiConstants.interestCalculationTypeParamName;
|
||||||
@@ -39,6 +40,11 @@ import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
|||||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||||
import org.mifosplatform.portfolio.savings.SavingsApiConstants;
|
import org.mifosplatform.portfolio.savings.SavingsApiConstants;
|
||||||
|
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
|
||||||
|
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
|
||||||
|
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
|
||||||
|
import org.mifosplatform.portfolio.savings.SavingsPostingInterestPeriodType;
|
||||||
|
import org.mifosplatform.portfolio.savings.SavingsWithdrawalFeesType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -84,6 +90,11 @@ public class SavingsAccountDataValidator {
|
|||||||
final Long productId = fromApiJsonHelper.extractLongNamed(productIdParamName, element);
|
final Long productId = fromApiJsonHelper.extractLongNamed(productIdParamName, element);
|
||||||
baseDataValidator.reset().parameter(productIdParamName).value(productId).notNull().integerGreaterThanZero();
|
baseDataValidator.reset().parameter(productIdParamName).value(productId).notNull().integerGreaterThanZero();
|
||||||
|
|
||||||
|
if (fromApiJsonHelper.parameterExists(fieldOfficerIdParamName, element)) {
|
||||||
|
final Long fieldOfficerId = fromApiJsonHelper.extractLongNamed(fieldOfficerIdParamName, element);
|
||||||
|
baseDataValidator.reset().parameter(fieldOfficerIdParamName).value(fieldOfficerId).notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
|
||||||
final LocalDate submittedOnDate = fromApiJsonHelper.extractLocalDateNamed(submittedOnDateParamName, element);
|
final LocalDate submittedOnDate = fromApiJsonHelper.extractLocalDateNamed(submittedOnDateParamName, element);
|
||||||
baseDataValidator.reset().parameter(submittedOnDateParamName).value(submittedOnDate).notNull();
|
baseDataValidator.reset().parameter(submittedOnDateParamName).value(submittedOnDate).notNull();
|
||||||
|
|
||||||
@@ -106,28 +117,28 @@ public class SavingsAccountDataValidator {
|
|||||||
final Integer interestCompoundingPeriodType = fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
final Integer interestCompoundingPeriodType = fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
||||||
interestCompoundingPeriodTypeParamName, element);
|
interestCompoundingPeriodTypeParamName, element);
|
||||||
baseDataValidator.reset().parameter(interestCompoundingPeriodTypeParamName).value(interestCompoundingPeriodType).notNull()
|
baseDataValidator.reset().parameter(interestCompoundingPeriodTypeParamName).value(interestCompoundingPeriodType).notNull()
|
||||||
.isOneOfTheseValues(new Object[] { 1, 2, 3, 4, 5, 6, 7, 8 });
|
.isOneOfTheseValues(SavingsCompoundingInterestPeriodType.integerValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromApiJsonHelper.parameterExists(interestPostingPeriodTypeParamName, element)) {
|
if (fromApiJsonHelper.parameterExists(interestPostingPeriodTypeParamName, element)) {
|
||||||
final Integer interestPostingPeriodType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestPostingPeriodTypeParamName,
|
final Integer interestPostingPeriodType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestPostingPeriodTypeParamName,
|
||||||
element);
|
element);
|
||||||
baseDataValidator.reset().parameter(interestPostingPeriodTypeParamName).value(interestPostingPeriodType).notNull()
|
baseDataValidator.reset().parameter(interestPostingPeriodTypeParamName).value(interestPostingPeriodType).notNull()
|
||||||
.isOneOfTheseValues(new Object[] { 4, 5, 6, 7 });
|
.isOneOfTheseValues(SavingsPostingInterestPeriodType.integerValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromApiJsonHelper.parameterExists(interestCalculationTypeParamName, element)) {
|
if (fromApiJsonHelper.parameterExists(interestCalculationTypeParamName, element)) {
|
||||||
final Integer interestCalculationType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestCalculationTypeParamName,
|
final Integer interestCalculationType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestCalculationTypeParamName,
|
||||||
element);
|
element);
|
||||||
baseDataValidator.reset().parameter(interestCalculationTypeParamName).value(interestCalculationType).notNull()
|
baseDataValidator.reset().parameter(interestCalculationTypeParamName).value(interestCalculationType).notNull()
|
||||||
.isOneOfTheseValues(new Object[] { 1, 2 });
|
.isOneOfTheseValues(SavingsInterestCalculationType.integerValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromApiJsonHelper.parameterExists(interestCalculationDaysInYearTypeParamName, element)) {
|
if (fromApiJsonHelper.parameterExists(interestCalculationDaysInYearTypeParamName, element)) {
|
||||||
final Integer interestCalculationDaysInYearType = fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
final Integer interestCalculationDaysInYearType = fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
||||||
interestCalculationDaysInYearTypeParamName, element);
|
interestCalculationDaysInYearTypeParamName, element);
|
||||||
baseDataValidator.reset().parameter(interestCalculationDaysInYearTypeParamName).value(interestCalculationDaysInYearType)
|
baseDataValidator.reset().parameter(interestCalculationDaysInYearTypeParamName).value(interestCalculationDaysInYearType)
|
||||||
.notNull().isOneOfTheseValues(360, 365);
|
.notNull().isOneOfTheseValues(SavingsInterestCalculationDaysInYearType.integerValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.fromApiJsonHelper.parameterExists(minRequiredOpeningBalanceParamName, element)) {
|
if (this.fromApiJsonHelper.parameterExists(minRequiredOpeningBalanceParamName, element)) {
|
||||||
@@ -170,7 +181,8 @@ public class SavingsAccountDataValidator {
|
|||||||
|
|
||||||
if (withdrawalFeeAmount != null) {
|
if (withdrawalFeeAmount != null) {
|
||||||
final Integer withdrawalFeeType = fromApiJsonHelper.extractIntegerSansLocaleNamed(withdrawalFeeTypeParamName, element);
|
final Integer withdrawalFeeType = fromApiJsonHelper.extractIntegerSansLocaleNamed(withdrawalFeeTypeParamName, element);
|
||||||
baseDataValidator.reset().parameter(withdrawalFeeTypeParamName).value(withdrawalFeeType).isOneOfTheseValues(1, 2);
|
baseDataValidator.reset().parameter(withdrawalFeeTypeParamName).value(withdrawalFeeType)
|
||||||
|
.isOneOfTheseValues(SavingsWithdrawalFeesType.integerValues());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,6 +274,11 @@ public class SavingsAccountDataValidator {
|
|||||||
baseDataValidator.reset().parameter(productIdParamName).value(productId).notNull().integerGreaterThanZero();
|
baseDataValidator.reset().parameter(productIdParamName).value(productId).notNull().integerGreaterThanZero();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fromApiJsonHelper.parameterExists(fieldOfficerIdParamName, element)) {
|
||||||
|
final Long fieldOfficerId = fromApiJsonHelper.extractLongNamed(fieldOfficerIdParamName, element);
|
||||||
|
baseDataValidator.reset().parameter(fieldOfficerIdParamName).value(fieldOfficerId).notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
|
||||||
if (fromApiJsonHelper.parameterExists(submittedOnDateParamName, element)) {
|
if (fromApiJsonHelper.parameterExists(submittedOnDateParamName, element)) {
|
||||||
final LocalDate submittedOnDate = fromApiJsonHelper.extractLocalDateNamed(submittedOnDateParamName, element);
|
final LocalDate submittedOnDate = fromApiJsonHelper.extractLocalDateNamed(submittedOnDateParamName, element);
|
||||||
baseDataValidator.reset().parameter(submittedOnDateParamName).value(submittedOnDate).notNull();
|
baseDataValidator.reset().parameter(submittedOnDateParamName).value(submittedOnDate).notNull();
|
||||||
@@ -286,28 +303,28 @@ public class SavingsAccountDataValidator {
|
|||||||
final Integer interestCompoundingPeriodType = fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
final Integer interestCompoundingPeriodType = fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
||||||
interestCompoundingPeriodTypeParamName, element);
|
interestCompoundingPeriodTypeParamName, element);
|
||||||
baseDataValidator.reset().parameter(interestCompoundingPeriodTypeParamName).value(interestCompoundingPeriodType).notNull()
|
baseDataValidator.reset().parameter(interestCompoundingPeriodTypeParamName).value(interestCompoundingPeriodType).notNull()
|
||||||
.isOneOfTheseValues(new Object[] { 1, 2, 3, 4, 5, 6, 7, 8 });
|
.isOneOfTheseValues(SavingsCompoundingInterestPeriodType.integerValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.fromApiJsonHelper.parameterExists(interestPostingPeriodTypeParamName, element)) {
|
if (this.fromApiJsonHelper.parameterExists(interestPostingPeriodTypeParamName, element)) {
|
||||||
final Integer interestPostingPeriodType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestPostingPeriodTypeParamName,
|
final Integer interestPostingPeriodType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestPostingPeriodTypeParamName,
|
||||||
element);
|
element);
|
||||||
baseDataValidator.reset().parameter(interestPostingPeriodTypeParamName).value(interestPostingPeriodType).notNull()
|
baseDataValidator.reset().parameter(interestPostingPeriodTypeParamName).value(interestPostingPeriodType).notNull()
|
||||||
.isOneOfTheseValues(new Object[] { 4, 5, 6, 7 });
|
.isOneOfTheseValues(SavingsPostingInterestPeriodType.integerValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.fromApiJsonHelper.parameterExists(interestCalculationTypeParamName, element)) {
|
if (this.fromApiJsonHelper.parameterExists(interestCalculationTypeParamName, element)) {
|
||||||
final Integer interestCalculationType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestCalculationTypeParamName,
|
final Integer interestCalculationType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestCalculationTypeParamName,
|
||||||
element);
|
element);
|
||||||
baseDataValidator.reset().parameter(interestCalculationTypeParamName).value(interestCalculationType).notNull()
|
baseDataValidator.reset().parameter(interestCalculationTypeParamName).value(interestCalculationType).notNull()
|
||||||
.isOneOfTheseValues(new Object[] { 1, 2 });
|
.isOneOfTheseValues(SavingsInterestCalculationType.integerValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.fromApiJsonHelper.parameterExists(interestCalculationDaysInYearTypeParamName, element)) {
|
if (this.fromApiJsonHelper.parameterExists(interestCalculationDaysInYearTypeParamName, element)) {
|
||||||
final Integer interestCalculationDaysInYearType = fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
final Integer interestCalculationDaysInYearType = fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
||||||
interestCalculationDaysInYearTypeParamName, element);
|
interestCalculationDaysInYearTypeParamName, element);
|
||||||
baseDataValidator.reset().parameter(interestCalculationDaysInYearTypeParamName).value(interestCalculationDaysInYearType)
|
baseDataValidator.reset().parameter(interestCalculationDaysInYearTypeParamName).value(interestCalculationDaysInYearType)
|
||||||
.notNull().isOneOfTheseValues(360, 365);
|
.notNull().isOneOfTheseValues(SavingsInterestCalculationDaysInYearType.integerValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.fromApiJsonHelper.parameterExists(minRequiredOpeningBalanceParamName, element)) {
|
if (this.fromApiJsonHelper.parameterExists(minRequiredOpeningBalanceParamName, element)) {
|
||||||
@@ -339,7 +356,7 @@ public class SavingsAccountDataValidator {
|
|||||||
if (this.fromApiJsonHelper.parameterExists(withdrawalFeeTypeParamName, element)) {
|
if (this.fromApiJsonHelper.parameterExists(withdrawalFeeTypeParamName, element)) {
|
||||||
final Integer withdrawalFeeType = fromApiJsonHelper.extractIntegerSansLocaleNamed(withdrawalFeeTypeParamName, element);
|
final Integer withdrawalFeeType = fromApiJsonHelper.extractIntegerSansLocaleNamed(withdrawalFeeTypeParamName, element);
|
||||||
baseDataValidator.reset().parameter(withdrawalFeeTypeParamName).value(withdrawalFeeType).ignoreIfNull()
|
baseDataValidator.reset().parameter(withdrawalFeeTypeParamName).value(withdrawalFeeType).ignoreIfNull()
|
||||||
.isOneOfTheseValues(1, 2);
|
.isOneOfTheseValues(SavingsWithdrawalFeesType.integerValues());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.fromApiJsonHelper.parameterExists(annualFeeAmountParamName, element)) {
|
if (this.fromApiJsonHelper.parameterExists(annualFeeAmountParamName, element)) {
|
||||||
|
|||||||
+9
-4
@@ -41,6 +41,10 @@ import org.mifosplatform.infrastructure.core.exception.InvalidJsonException;
|
|||||||
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
|
||||||
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
import org.mifosplatform.infrastructure.core.serialization.FromJsonHelper;
|
||||||
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
|
import org.mifosplatform.portfolio.savings.SavingsCompoundingInterestPeriodType;
|
||||||
|
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationDaysInYearType;
|
||||||
|
import org.mifosplatform.portfolio.savings.SavingsInterestCalculationType;
|
||||||
|
import org.mifosplatform.portfolio.savings.SavingsPostingInterestPeriodType;
|
||||||
|
import org.mifosplatform.portfolio.savings.SavingsWithdrawalFeesType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -96,16 +100,16 @@ public class SavingsProductDataValidator {
|
|||||||
final Integer interestPostingPeriodType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestPostingPeriodTypeParamName,
|
final Integer interestPostingPeriodType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestPostingPeriodTypeParamName,
|
||||||
element);
|
element);
|
||||||
baseDataValidator.reset().parameter(interestPostingPeriodTypeParamName).value(interestPostingPeriodType).notNull()
|
baseDataValidator.reset().parameter(interestPostingPeriodTypeParamName).value(interestPostingPeriodType).notNull()
|
||||||
.isOneOfTheseValues(new Object[] { 4, 5, 6, 7 });
|
.isOneOfTheseValues(SavingsPostingInterestPeriodType.integerValues());
|
||||||
|
|
||||||
final Integer interestCalculationType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestCalculationTypeParamName, element);
|
final Integer interestCalculationType = fromApiJsonHelper.extractIntegerSansLocaleNamed(interestCalculationTypeParamName, element);
|
||||||
baseDataValidator.reset().parameter(interestCalculationTypeParamName).value(interestCalculationType).notNull()
|
baseDataValidator.reset().parameter(interestCalculationTypeParamName).value(interestCalculationType).notNull()
|
||||||
.isOneOfTheseValues(new Object[] { 1, 2 });
|
.isOneOfTheseValues(SavingsInterestCalculationType.integerValues());
|
||||||
|
|
||||||
final Integer interestCalculationDaysInYearType = fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
final Integer interestCalculationDaysInYearType = fromApiJsonHelper.extractIntegerSansLocaleNamed(
|
||||||
interestCalculationDaysInYearTypeParamName, element);
|
interestCalculationDaysInYearTypeParamName, element);
|
||||||
baseDataValidator.reset().parameter(interestCalculationDaysInYearTypeParamName).value(interestCalculationDaysInYearType).notNull()
|
baseDataValidator.reset().parameter(interestCalculationDaysInYearTypeParamName).value(interestCalculationDaysInYearType).notNull()
|
||||||
.isOneOfTheseValues(360, 365);
|
.isOneOfTheseValues(SavingsInterestCalculationDaysInYearType.integerValues());
|
||||||
|
|
||||||
if (this.fromApiJsonHelper.parameterExists(minRequiredOpeningBalanceParamName, element)) {
|
if (this.fromApiJsonHelper.parameterExists(minRequiredOpeningBalanceParamName, element)) {
|
||||||
final BigDecimal minOpeningBalance = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(minRequiredOpeningBalanceParamName,
|
final BigDecimal minOpeningBalance = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(minRequiredOpeningBalanceParamName,
|
||||||
@@ -147,7 +151,8 @@ public class SavingsProductDataValidator {
|
|||||||
|
|
||||||
if (withdrawalFeeAmount != null) {
|
if (withdrawalFeeAmount != null) {
|
||||||
final Integer withdrawalFeeType = fromApiJsonHelper.extractIntegerSansLocaleNamed(withdrawalFeeTypeParamName, element);
|
final Integer withdrawalFeeType = fromApiJsonHelper.extractIntegerSansLocaleNamed(withdrawalFeeTypeParamName, element);
|
||||||
baseDataValidator.reset().parameter(withdrawalFeeTypeParamName).value(withdrawalFeeType).isOneOfTheseValues(1, 2);
|
baseDataValidator.reset().parameter(withdrawalFeeTypeParamName).value(withdrawalFeeType)
|
||||||
|
.isOneOfTheseValues(SavingsWithdrawalFeesType.integerValues());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user