updates to MIFOSX-1700

This commit is contained in:
Vishwas Babu A J
2014-12-07 13:59:10 -08:00
parent 002ef06d51
commit 452d97cfb0
2 changed files with 15 additions and 1 deletions
@@ -9,7 +9,9 @@ import static org.mifosplatform.portfolio.savings.DepositsApiConstants.mandatory
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.MathContext; import java.math.MathContext;
import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.persistence.Column; import javax.persistence.Column;
@@ -21,8 +23,11 @@ import javax.persistence.Table;
import org.joda.time.LocalDate; import org.joda.time.LocalDate;
import org.mifosplatform.infrastructure.core.api.JsonCommand; import org.mifosplatform.infrastructure.core.api.JsonCommand;
import org.mifosplatform.infrastructure.core.data.ApiParameterError;
import org.mifosplatform.infrastructure.core.exception.PlatformApiDataValidationException;
import org.mifosplatform.infrastructure.core.service.DateUtils; import org.mifosplatform.infrastructure.core.service.DateUtils;
import org.mifosplatform.organisation.monetary.domain.Money; import org.mifosplatform.organisation.monetary.domain.Money;
import org.mifosplatform.portfolio.savings.DepositsApiConstants;
import org.springframework.data.jpa.domain.AbstractPersistable; import org.springframework.data.jpa.domain.AbstractPersistable;
@Entity @Entity
@@ -101,6 +106,14 @@ public class DepositAccountRecurringDetail extends AbstractPersistable<Long> {
actualChanges.put(mandatoryRecommendedDepositAmountParamName, newMandatoryRecommendedDepositAmount); actualChanges.put(mandatoryRecommendedDepositAmountParamName, newMandatoryRecommendedDepositAmount);
this.mandatoryRecommendedDepositAmount = newMandatoryRecommendedDepositAmount; this.mandatoryRecommendedDepositAmount = newMandatoryRecommendedDepositAmount;
RecurringDepositAccount depositAccount = (RecurringDepositAccount) this.account; RecurringDepositAccount depositAccount = (RecurringDepositAccount) this.account;
if (depositAccount.isNotActive()) {
final String defaultUserMessage = "Updates to the recommended deposit amount are allowed only when the underlying account is active.";
final ApiParameterError error = ApiParameterError.generalError("error.msg."
+ DepositsApiConstants.RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME + ".is.not.active", defaultUserMessage);
final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
dataValidationErrors.add(error);
throw new PlatformApiDataValidationException(dataValidationErrors);
}
depositAccount.updateScheduleInstallmentsWithNewRecommendedDepositAmount(newMandatoryRecommendedDepositAmount, effectiveDate); depositAccount.updateScheduleInstallmentsWithNewRecommendedDepositAmount(newMandatoryRecommendedDepositAmount, effectiveDate);
depositAccount.updateOverduePayments(DateUtils.getLocalDateOfTenant()); depositAccount.updateOverduePayments(DateUtils.getLocalDateOfTenant());
MathContext mc = MathContext.DECIMAL64; MathContext mc = MathContext.DECIMAL64;
@@ -833,7 +833,8 @@ public class RecurringDepositAccount extends SavingsAccount {
// reset all installments to process from the beginning, also update // reset all installments to process from the beginning, also update
// deposit amount as necessary // deposit amount as necessary
for (RecurringDepositScheduleInstallment currentInstallment : depositScheduleInstallments()) { for (RecurringDepositScheduleInstallment currentInstallment : depositScheduleInstallments()) {
if (currentInstallment.dueDate().isAfter(depositAmountupdatedFromDate)) { if (currentInstallment.dueDate().isAfter(depositAmountupdatedFromDate)
|| currentInstallment.dueDate().isEqual(depositAmountupdatedFromDate)) {
currentInstallment.updateDepositAmountAndResetDerivedFields(newDepositAmount); currentInstallment.updateDepositAmountAndResetDerivedFields(newDepositAmount);
} else { } else {
currentInstallment.resetDerivedFields(); currentInstallment.resetDerivedFields();