Merge pull request #928 from lingalamadhukar/MIFOSX-1267
Bug Fixes for 1.23 release
This commit is contained in:
+16
-13
@@ -24,6 +24,7 @@ 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.loanproduct.domain.LoanProduct;
|
import org.mifosplatform.portfolio.loanproduct.domain.LoanProduct;
|
||||||
|
import org.mifosplatform.portfolio.savings.DepositAccountType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@@ -145,7 +146,7 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
|
|||||||
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
throwExceptionIfValidationWarningsExist(dataValidationErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void validateForSavingsProductCreate(final String json) {
|
public void validateForSavingsProductCreate(final String json, DepositAccountType accountType) {
|
||||||
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
|
||||||
|
|
||||||
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
final List<ApiParameterError> dataValidationErrors = new ArrayList<ApiParameterError>();
|
||||||
@@ -191,20 +192,22 @@ public final class ProductToGLAccountMappingFromApiJsonDeserializer {
|
|||||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue())
|
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_PENALTIES.getValue())
|
||||||
.value(incomeFromPenaltyId).notNull().integerGreaterThanZero();
|
.value(incomeFromPenaltyId).notNull().integerGreaterThanZero();
|
||||||
|
|
||||||
final Long overdraftAccount = this.fromApiJsonHelper.extractLongNamed(
|
if (!accountType.equals(DepositAccountType.RECURRING_DEPOSIT) && !accountType.equals(DepositAccountType.FIXED_DEPOSIT)) {
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element);
|
final Long overdraftAccount = this.fromApiJsonHelper.extractLongNamed(
|
||||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue())
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue(), element);
|
||||||
.value(overdraftAccount).notNull().integerGreaterThanZero();
|
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.OVERDRAFT_PORTFOLIO_CONTROL.getValue())
|
||||||
|
.value(overdraftAccount).notNull().integerGreaterThanZero();
|
||||||
|
|
||||||
final Long incomeFromInterest = this.fromApiJsonHelper.extractLongNamed(
|
final Long incomeFromInterest = this.fromApiJsonHelper.extractLongNamed(
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), element);
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue(), element);
|
||||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue())
|
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_INTEREST.getValue())
|
||||||
.value(incomeFromInterest).notNull().integerGreaterThanZero();
|
.value(incomeFromInterest).notNull().integerGreaterThanZero();
|
||||||
|
|
||||||
final Long writtenOff = this.fromApiJsonHelper.extractLongNamed(
|
final Long writtenOff = this.fromApiJsonHelper.extractLongNamed(
|
||||||
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), element);
|
SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue(), element);
|
||||||
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()).value(writtenOff)
|
baseDataValidator.reset().parameter(SAVINGS_PRODUCT_ACCOUNTING_PARAMS.LOSSES_WRITTEN_OFF.getValue()).value(writtenOff)
|
||||||
.notNull().integerGreaterThanZero();
|
.notNull().integerGreaterThanZero();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -265,7 +265,7 @@ public class ProductToGLAccountMappingWritePlatformServiceImpl implements Produc
|
|||||||
* for the product and recreate a new set of mappings
|
* for the product and recreate a new set of mappings
|
||||||
***/
|
***/
|
||||||
if (accountingRuleChanged) {
|
if (accountingRuleChanged) {
|
||||||
this.deserializer.validateForSavingsProductCreate(command.json());
|
this.deserializer.validateForSavingsProductCreate(command.json(), accountType);
|
||||||
this.savingsProductToGLAccountMappingHelper.deleteSavingsProductToGLAccountMapping(savingsProductId);
|
this.savingsProductToGLAccountMappingHelper.deleteSavingsProductToGLAccountMapping(savingsProductId);
|
||||||
createSavingProductToGLAccountMapping(savingsProductId, command, accountType);
|
createSavingProductToGLAccountMapping(savingsProductId, command, accountType);
|
||||||
changes = this.savingsProductToGLAccountMappingHelper.populateChangesForNewSavingsProductToGLAccountMappingCreation(element,
|
changes = this.savingsProductToGLAccountMappingHelper.populateChangesForNewSavingsProductToGLAccountMappingCreation(element,
|
||||||
|
|||||||
+2
@@ -128,6 +128,7 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
final Map<String, Object> termAndPreClosureChanges = accountTermAndPreClosure.update(command, baseDataValidator);
|
final Map<String, Object> termAndPreClosureChanges = accountTermAndPreClosure.update(command, baseDataValidator);
|
||||||
actualChanges.putAll(termAndPreClosureChanges);
|
actualChanges.putAll(termAndPreClosureChanges);
|
||||||
validateDomainRules(baseDataValidator);
|
validateDomainRules(baseDataValidator);
|
||||||
|
super.validateInterestPostingAndCompoundingPeriodTypes(baseDataValidator);
|
||||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,6 +628,7 @@ public class FixedDepositAccount extends SavingsAccount {
|
|||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||||
.resource(FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME);
|
.resource(FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME);
|
||||||
validateDomainRules(baseDataValidator);
|
validateDomainRules(baseDataValidator);
|
||||||
|
super.validateInterestPostingAndCompoundingPeriodTypes(baseDataValidator);
|
||||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
@@ -166,6 +166,7 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
recurringDetail.update(command);
|
recurringDetail.update(command);
|
||||||
|
|
||||||
validateDomainRules(baseDataValidator);
|
validateDomainRules(baseDataValidator);
|
||||||
|
super.validateInterestPostingAndCompoundingPeriodTypes(baseDataValidator);
|
||||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -866,6 +867,7 @@ public class RecurringDepositAccount extends SavingsAccount {
|
|||||||
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors)
|
||||||
.resource(RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME);
|
.resource(RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME);
|
||||||
validateDomainRules(baseDataValidator);
|
validateDomainRules(baseDataValidator);
|
||||||
|
super.validateInterestPostingAndCompoundingPeriodTypes(baseDataValidator);
|
||||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+40
@@ -21,6 +21,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -2027,6 +2028,8 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
.failWithCode("cannot.exceed.product.value");
|
.failWithCode("cannot.exceed.product.value");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateInterestPostingAndCompoundingPeriodTypes(baseDataValidator);
|
||||||
|
|
||||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2051,4 +2054,41 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
|||||||
return getActivationLocalDate().isEqual(getSubmittedOnLocalDate());
|
return getActivationLocalDate().isEqual(getSubmittedOnLocalDate());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validateInterestPostingAndCompoundingPeriodTypes(final DataValidatorBuilder baseDataValidator) {
|
||||||
|
Map<SavingsPostingInterestPeriodType, List<SavingsCompoundingInterestPeriodType>> postingtoCompoundMap = new HashMap<SavingsPostingInterestPeriodType, List<SavingsCompoundingInterestPeriodType>>();
|
||||||
|
postingtoCompoundMap.put(
|
||||||
|
SavingsPostingInterestPeriodType.MONTHLY,
|
||||||
|
Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
|
||||||
|
SavingsCompoundingInterestPeriodType.MONTHLY }));
|
||||||
|
|
||||||
|
postingtoCompoundMap.put(
|
||||||
|
SavingsPostingInterestPeriodType.QUATERLY,
|
||||||
|
Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
|
||||||
|
SavingsCompoundingInterestPeriodType.MONTHLY, SavingsCompoundingInterestPeriodType.QUATERLY }));
|
||||||
|
|
||||||
|
postingtoCompoundMap.put(
|
||||||
|
SavingsPostingInterestPeriodType.BIANNUAL,
|
||||||
|
Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
|
||||||
|
SavingsCompoundingInterestPeriodType.MONTHLY, SavingsCompoundingInterestPeriodType.QUATERLY,
|
||||||
|
SavingsCompoundingInterestPeriodType.BI_ANNUAL }));
|
||||||
|
|
||||||
|
postingtoCompoundMap.put(
|
||||||
|
SavingsPostingInterestPeriodType.ANNUAL,
|
||||||
|
Arrays.asList(new SavingsCompoundingInterestPeriodType[] { SavingsCompoundingInterestPeriodType.DAILY,
|
||||||
|
SavingsCompoundingInterestPeriodType.MONTHLY, SavingsCompoundingInterestPeriodType.QUATERLY,
|
||||||
|
SavingsCompoundingInterestPeriodType.BI_ANNUAL, SavingsCompoundingInterestPeriodType.ANNUAL }));
|
||||||
|
|
||||||
|
SavingsPostingInterestPeriodType savingsPostingInterestPeriodType = SavingsPostingInterestPeriodType
|
||||||
|
.fromInt(interestPostingPeriodType);
|
||||||
|
SavingsCompoundingInterestPeriodType savingsCompoundingInterestPeriodType = SavingsCompoundingInterestPeriodType
|
||||||
|
.fromInt(interestCompoundingPeriodType);
|
||||||
|
|
||||||
|
if (postingtoCompoundMap.get(savingsPostingInterestPeriodType) == null
|
||||||
|
|| !postingtoCompoundMap.get(savingsPostingInterestPeriodType).contains(savingsCompoundingInterestPeriodType)) {
|
||||||
|
baseDataValidator.failWithCodeNoParameterAddedToErrorCode("posting.period.type.is.less.than.compound.period.type",
|
||||||
|
savingsPostingInterestPeriodType.name(), savingsCompoundingInterestPeriodType.name());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -699,7 +699,7 @@ public class SavingsEnumerations {
|
|||||||
case INVALID:
|
case INVALID:
|
||||||
break;
|
break;
|
||||||
case WITHDRAW_DEPOSIT:
|
case WITHDRAW_DEPOSIT:
|
||||||
optionData = new EnumOptionData(DepositAccountOnClosureType.WITHDRAW_DEPOSIT.getValue().longValue(), DepositAccountOnClosureType.WITHDRAW_DEPOSIT.getCode(), "Withdra Deposit");
|
optionData = new EnumOptionData(DepositAccountOnClosureType.WITHDRAW_DEPOSIT.getValue().longValue(), DepositAccountOnClosureType.WITHDRAW_DEPOSIT.getCode(), "Withdraw Deposit");
|
||||||
break;
|
break;
|
||||||
case TRANSFER_TO_SAVINGS:
|
case TRANSFER_TO_SAVINGS:
|
||||||
optionData = new EnumOptionData(DepositAccountOnClosureType.TRANSFER_TO_SAVINGS.getValue().longValue(), DepositAccountOnClosureType.TRANSFER_TO_SAVINGS.getCode(), "Transfer to Savings");
|
optionData = new EnumOptionData(DepositAccountOnClosureType.TRANSFER_TO_SAVINGS.getValue().longValue(), DepositAccountOnClosureType.TRANSFER_TO_SAVINGS.getCode(), "Transfer to Savings");
|
||||||
|
|||||||
Reference in New Issue
Block a user