diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java
index 68236050a..3c03d8b67 100755
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/domain/CommandWrapper.java
@@ -7,6 +7,7 @@ package org.mifosplatform.commands.domain;
import org.mifosplatform.infrastructure.accountnumberformat.service.AccountNumberFormatConstants;
import org.mifosplatform.portfolio.loanaccount.rescheduleloan.RescheduleLoansApiConstants;
+import org.mifosplatform.portfolio.savings.DepositsApiConstants;
public class CommandWrapper {
@@ -866,9 +867,11 @@ public class CommandWrapper {
public boolean isWithdrawal() {
return this.actionName.equalsIgnoreCase("WITHDRAWAL");
}
+
public boolean isWithdrawn() {
return this.actionName.equalsIgnoreCase("WITHDRAW");
}
+
public boolean isReactivated() {
return this.actionName.equalsIgnoreCase("REACTIVATE");
}
@@ -901,6 +904,10 @@ public class CommandWrapper {
return this.actionName.equalsIgnoreCase("PREMATURECLOSE") && isDepositAccountResource();
}
+ public boolean isDepositAmountUpdateForRecurringDepositAccount() {
+ return this.actionName.equalsIgnoreCase(DepositsApiConstants.UPDATE_DEPOSIT_AMOUNT.toUpperCase()) && isDepositAccountResource();
+ }
+
// End - Deposit accounts
public boolean isFinancialActivityAccountMapping() {
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java
index 9cdea17c2..4b4ee4583 100755
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/CommandWrapperBuilder.java
@@ -7,6 +7,7 @@ package org.mifosplatform.commands.service;
import org.mifosplatform.commands.domain.CommandWrapper;
import org.mifosplatform.infrastructure.accountnumberformat.service.AccountNumberFormatConstants;
+import org.mifosplatform.portfolio.savings.DepositsApiConstants;
public class CommandWrapperBuilder {
@@ -428,7 +429,7 @@ public class CommandWrapperBuilder {
this.href = "/clients/" + clientId + "?command=close&template=true";
return this;
}
-
+
public CommandWrapperBuilder rejectClient(final Long clientId) {
this.actionName = "REJECT";
this.entityName = "CLIENT";
@@ -437,7 +438,7 @@ public class CommandWrapperBuilder {
this.href = "/clients/" + clientId + "?command=reject&template=true";
return this;
}
-
+
public CommandWrapperBuilder withdrawClient(final Long clientId) {
this.actionName = "WITHDRAW";
this.entityName = "CLIENT";
@@ -446,6 +447,7 @@ public class CommandWrapperBuilder {
this.href = "/clients/" + clientId + "?command=withdraw&template=true";
return this;
}
+
public CommandWrapperBuilder reActivateClient(final Long clientId) {
this.actionName = "REACTIVATE";
this.entityName = "CLIENT";
@@ -454,6 +456,7 @@ public class CommandWrapperBuilder {
this.href = "/clients/" + clientId + "?command=reactivate&template=true";
return this;
}
+
public CommandWrapperBuilder proposeClientTransfer(final Long clientId) {
this.actionName = "PROPOSETRANSFER";
this.entityName = "CLIENT";
@@ -2027,6 +2030,15 @@ public class CommandWrapperBuilder {
return this;
}
+ public CommandWrapperBuilder updateDepositAmountForRecurringDepositAccount(final Long accountId) {
+ this.actionName = DepositsApiConstants.UPDATE_DEPOSIT_AMOUNT.toUpperCase();
+ this.entityName = "RECURRINGDEPOSITACCOUNT";
+ this.entityId = accountId;
+ this.savingsId = accountId;
+ this.href = "/recurringdepositaccounts/" + accountId + "?command=" + DepositsApiConstants.UPDATE_DEPOSIT_AMOUNT;
+ return this;
+ }
+
public CommandWrapperBuilder prematureCloseRecurringDepositAccount(final Long accountId) {
this.actionName = "PREMATURECLOSE";
this.entityName = "RECURRINGDEPOSITACCOUNT";
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
index 709293888..b65a1ddb8 100755
--- a/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/commands/service/SynchronousCommandProcessingService.java
@@ -204,13 +204,13 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
handler = this.applicationContext.getBean("rejectClientTransferCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isUpdateClientSavingsAccount()) {
handler = this.applicationContext.getBean("updateClientSavingsAccountCommandHandler", NewCommandSourceHandler.class);
- } else if(wrapper.isReject()){
+ } else if (wrapper.isReject()) {
handler = this.applicationContext.getBean("rejectClientCommandHandler", NewCommandSourceHandler.class);
- }else if(wrapper.isWithdrawn()){
+ } else if (wrapper.isWithdrawn()) {
handler = this.applicationContext.getBean("withdrawClientCommandHandler", NewCommandSourceHandler.class);
- }else if(wrapper.isReactivated()){
+ } else if (wrapper.isReactivated()) {
handler = this.applicationContext.getBean("reActivateClientCommandHandler", NewCommandSourceHandler.class);
- }else {
+ } else {
throw new UnsupportedCommandException(wrapper.commandName());
}
// end of client
@@ -609,6 +609,9 @@ public class SynchronousCommandProcessingService implements CommandProcessingSer
} else if (wrapper.isUndoApprovalOfRecurringDepositAccountApplication()) {
handler = this.applicationContext.getBean("recurringDepositAccountApplicationApprovalUndoCommandHandler",
NewCommandSourceHandler.class);
+ } else if (wrapper.isDepositAmountUpdateForRecurringDepositAccount()) {
+ handler = this.applicationContext.getBean("recurringDepositAccountUpdateDepositAmountCommandHandler",
+ NewCommandSourceHandler.class);
} else if (wrapper.isDeposit()) {
handler = this.applicationContext.getBean("recurringDepositAccountDepositCommandHandler", NewCommandSourceHandler.class);
} else if (wrapper.isWithdrawal()) {
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/DepositsApiConstants.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/DepositsApiConstants.java
index eebd01b9f..7b9a72863 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/DepositsApiConstants.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/DepositsApiConstants.java
@@ -17,7 +17,7 @@ public class DepositsApiConstants {
public static final String FIXED_DEPOSIT_PRODUCT_RESOURCE_NAME = "fixeddeposit";
public static final String RECURRING_DEPOSIT_PRODUCT_RESOURCE_NAME = "recurringdeposit";
- // Deposti accounts
+ // Deposit accounts
public static final String FIXED_DEPOSIT_ACCOUNT_RESOURCE_NAME = "fixeddepositaccount";
public static final String RECURRING_DEPOSIT_ACCOUNT_RESOURCE_NAME = "recurringdepositaccount";
@@ -47,6 +47,7 @@ public class DepositsApiConstants {
public static String COMMAND_ADJUST_TRANSACTION = "modify";
public static String COMMAND_WAIVE_CHARGE = "waive";
public static String COMMAND_PAY_CHARGE = "paycharge";
+ public static String UPDATE_DEPOSIT_AMOUNT = "updateDepositAmount";
// general
public static final String localeParamName = "locale";
@@ -138,6 +139,9 @@ public class DepositsApiConstants {
public static final String reversedParamName = "reversed";
public static final String dateParamName = "date";
+ // recurring deposits update parameters
+ public static final String effectiveDateParamName = "effectiveDate";
+
// charges parameters
public static final String chargeIdParamName = "chargeId";
public static final String chargesParamName = "charges";
@@ -331,6 +335,9 @@ public class DepositsApiConstants {
dateFormatParamName, transactionDateParamName, transactionAmountParamName, paymentTypeIdParamName,
transactionAccountNumberParamName, checkNumberParamName, routingCodeParamName, receiptNumberParamName, bankNumberParamName));
+ public static final Set
DEPOSIT_ACCOUNT_RECOMMENDED_DEPOSIT_AMOUNT_UPDATE_REQUEST_DATA_PARAMETERS = new HashSet<>(
+ Arrays.asList(localeParamName, dateFormatParamName, mandatoryRecommendedDepositAmountParamName, effectiveDateParamName));
+
public static final Set FIXED_DEPOSIT_TRANSACTION_RESPONSE_DATA_PARAMETERS = new HashSet<>(Arrays.asList(idParamName,
"accountId", accountNoParamName, "currency", "amount", dateParamName, paymentDetailDataParamName, runningBalanceParamName,
reversedParamName));
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositAccountsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositAccountsApiResource.java
index 165701cda..819ac8da6 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositAccountsApiResource.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/api/RecurringDepositAccountsApiResource.java
@@ -262,6 +262,10 @@ public class RecurringDepositAccountsApiResource {
} else if (is(commandParam, "calculateInterest")) {
final CommandWrapper commandRequest = builder.withNoJsonBody().recurringDepositAccountInterestCalculation(accountId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
+ } else if (is(commandParam, DepositsApiConstants.UPDATE_DEPOSIT_AMOUNT)) {
+ final CommandWrapper commandRequest = builder.updateDepositAmountForRecurringDepositAccount(accountId)
+ .withJson(apiRequestBodyAsJson).build();
+ result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
} else if (is(commandParam, "postInterest")) {
final CommandWrapper commandRequest = builder.recurringDepositAccountInterestPosting(accountId).build();
result = this.commandsSourceWritePlatformService.logCommandSource(commandRequest);
diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/DepositAccountTransactionDataValidator.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/DepositAccountTransactionDataValidator.java
index 1809a0672..6610cc832 100644
--- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/DepositAccountTransactionDataValidator.java
+++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/data/DepositAccountTransactionDataValidator.java
@@ -91,6 +91,32 @@ public class DepositAccountTransactionDataValidator {
throwExceptionIfValidationWarningsExist(dataValidationErrors);
}
+ public void validateDepositAmountUpdate(final JsonCommand command) {
+ final String json = command.json();
+
+ if (StringUtils.isBlank(json)) { throw new InvalidJsonException(); }
+
+ final Type typeOfMap = new TypeToken