Merge pull request #1007 from lingalamadhukar/MIFOSX-1403
MIFOSX-1424 and api-docs update for close savings account
This commit is contained in:
@@ -17757,6 +17757,25 @@ Request Body:
|
||||
<div class="method-description">
|
||||
<h2>Close a savings account</h2>
|
||||
<p>Results in an Activated savings application being converted into an 'closed' savings account.</p>
|
||||
<p><i>closedOnDate</i> is closure date of savings account</p>
|
||||
<p><i>withdrawBalance</i> is a boolean value, true value of this field performs a withdrawal transaction with account's running balance.</p>
|
||||
<table class=matrixHeading>
|
||||
<tr class="matrixHeadingBG">
|
||||
<td><div class="mifosXHeading2">Mandatory Fields</div></td>
|
||||
</tr>
|
||||
<tr class=alt>
|
||||
<td>dateFormat,locale,closedOnDate</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<table class=matrixHeading>
|
||||
<tr class="matrixHeadingBG">
|
||||
<td><div class="mifosXHeading2">Optional Fields</div></td>
|
||||
</tr>
|
||||
<tr class=alt>
|
||||
<td>note, <i>withdrawBalance</i>, paymentTypeId, accountNumber, checkNumber, routingCode, receiptNumber, bankNumber</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="method-example">
|
||||
<code class="method-declaration">POST https://Domain Name/api/v1/savingsaccounts/{savingsId}?command=close</code>
|
||||
|
||||
+15
-1
@@ -170,9 +170,12 @@ public class ClientSavingsIntegrationTest {
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
String withdrawBalance = "false";
|
||||
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField(
|
||||
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR);
|
||||
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
|
||||
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
|
||||
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
@@ -521,9 +524,12 @@ public class ClientSavingsIntegrationTest {
|
||||
* balance, perform transactions then post interest and verify posted
|
||||
* interest
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void testSavingsAccountWithOverdraft() {
|
||||
this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec, this.responseSpec);
|
||||
final ResponseSpecification errorResponse = new ResponseSpecBuilder().expectStatusCode(400).build();
|
||||
final SavingsAccountHelper validationErrorHelper = new SavingsAccountHelper(this.requestSpec, errorResponse);
|
||||
|
||||
/***
|
||||
* Create a client to apply for savings account (overdraft account).
|
||||
@@ -647,6 +653,14 @@ public class ClientSavingsIntegrationTest {
|
||||
interestPosted = new Float(decimalFormat.format(interestPosted));
|
||||
actualInterestPosted = new Float(decimalFormat.format(actualInterestPosted));
|
||||
assertEquals("Verifying interest posted", interestPosted, actualInterestPosted);
|
||||
|
||||
todaysDate = Calendar.getInstance();
|
||||
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
String withdrawBalance = "false";
|
||||
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField(
|
||||
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
|
||||
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
|
||||
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
}
|
||||
|
||||
private HashMap activateSavingsAccount(final Integer savingsId, final String activationDate) {
|
||||
|
||||
+5
-1
@@ -3,6 +3,7 @@ package org.mifosplatform.integrationtests;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@@ -134,9 +135,12 @@ public class GroupSavingsIntegrationTest {
|
||||
savingsStatusHashMap = this.savingsAccountHelper.activateSavings(savingsId);
|
||||
SavingsStatusChecker.verifySavingsIsActive(savingsStatusHashMap);
|
||||
|
||||
DateFormat dateFormat = new SimpleDateFormat("dd MMMM yyyy");
|
||||
Calendar todaysDate = Calendar.getInstance();
|
||||
final String CLOSEDON_DATE = dateFormat.format(todaysDate.getTime());
|
||||
String withdrawBalance = "false";
|
||||
ArrayList<HashMap> savingsAccountErrorData = (ArrayList<HashMap>) validationErrorHelper.closeSavingsAccountAndGetBackRequiredField(
|
||||
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR);
|
||||
savingsId, withdrawBalance, CommonConstants.RESPONSE_ERROR, CLOSEDON_DATE);
|
||||
assertEquals("validation.msg.savingsaccount.close.results.in.balance.not.zero",
|
||||
savingsAccountErrorData.get(0).get(CommonConstants.RESPONSE_ERROR_MESSAGE_CODE));
|
||||
|
||||
|
||||
+6
-6
@@ -106,7 +106,7 @@ public class SavingsAccountHelper {
|
||||
|
||||
public HashMap closeSavingsAccount(final Integer savingsID, String withdrawBalance) {
|
||||
System.out.println("---------------------------------- CLOSE SAVINGS APPLICATION ----------------------------------");
|
||||
return performSavingApplicationActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID), getCloseAccountJSON(withdrawBalance));
|
||||
return performSavingApplicationActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID), getCloseAccountJSON(withdrawBalance, LAST_TRANSACTION_DATE));
|
||||
}
|
||||
|
||||
public Object deleteSavingsApplication(final Integer savingsId, final String jsonAttributeToGetBack) {
|
||||
@@ -266,11 +266,11 @@ public class SavingsAccountHelper {
|
||||
return josn;
|
||||
}
|
||||
|
||||
private String getCloseAccountJSON(String withdrawBalance) {
|
||||
private String getCloseAccountJSON(String withdrawBalance, String closedOnDate) {
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("locale", CommonConstants.locale);
|
||||
map.put("dateFormat", CommonConstants.dateFormat);
|
||||
map.put("closedOnDate", LAST_TRANSACTION_DATE);
|
||||
map.put("closedOnDate", closedOnDate);
|
||||
map.put("withdrawBalance", withdrawBalance);
|
||||
map.put("note", "Close Test");
|
||||
String josn = new Gson().toJson(map);
|
||||
@@ -354,10 +354,10 @@ public class SavingsAccountHelper {
|
||||
}
|
||||
|
||||
public Object closeSavingsAccountAndGetBackRequiredField(final Integer savingsID, String withdrawBalance,
|
||||
final String jsonAttributeToGetBack) {
|
||||
final String jsonAttributeToGetBack, final String closedOnDate) {
|
||||
System.out.println("---------------------------------- CLOSE SAVINGS APPLICATION ----------------------------------");
|
||||
return performSavingActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID), getCloseAccountJSON(withdrawBalance),
|
||||
jsonAttributeToGetBack);
|
||||
return performSavingActions(createSavingsOperationURL(CLOSE_SAVINGS_COMMAND, savingsID),
|
||||
getCloseAccountJSON(withdrawBalance, closedOnDate), jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
private String getPeriodChargeRequestJSON(Integer chargeId) {
|
||||
|
||||
+1
-1
@@ -1707,7 +1707,7 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
}
|
||||
}
|
||||
if (getAccountBalance().doubleValue() > 0) {
|
||||
if (getAccountBalance().doubleValue() != 0) {
|
||||
baseDataValidator.reset().failWithCodeNoParameterAddedToErrorCode("results.in.balance.not.zero");
|
||||
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user