merging Mardukars work arounf standing instructions

This commit is contained in:
Vishwas Babu A J
2014-06-30 18:28:26 -07:00
6 changed files with 256 additions and 4 deletions
+224
View File
@@ -316,6 +316,14 @@
<td><a href="#standinginstruction_update">Update Standing Instruction</a></td>
<td><a href="#standinginstruction_delete">Delete Standing Instruction(status change)</a></td>
</tr>
<tr>
<td></td>
<td>standinginstructions/history</td>
<td></td>
<td><a href="#standinginstructions_history">Standinginstructions History</a></td>
<td></td>
<td></td>
</tr>
<tr>
<td><a href="#accounttransfers">Account Transfer</a></td>
<td>accounttransfers</td>
@@ -24532,6 +24540,214 @@ No Request Body:
</code>
</div>
</div>
<a id="standinginstructions_history" name="standinginstructions_history" class="old-syle-anchor">&nbsp;</a>
<div class="method-section">
<div class="method-description">
<h2>Standing Instructions Logged History:</h2>
<p>The <i>list</i> capability of history can support <b>pagination</b> and <b>sorting</b>.</p>
<h5>Optional Arguments</h5>
<dl class="argument-list">
<dt>offset</dt>
<dd>
Integer <span>optional</span>, defaults to 0
</dd>
<dd>Indicates from what result to start from.</dd>
<dt>limit</dt>
<dd>
Integer <span>optional</span>, defaults to 200
</dd>
<dd>Restricts the size of results returned. To override the default and return all entries you must explicitly pass a non-positive integer value for limit e.g. limit=0, or limit=-1</dd>
<dt>orderBy</dt>
<dd>
String <span>optional</span>, one of <span>name,standingInstructionId</span>
</dd>
<dd>Orders the results by the field indicated.</dd>
<dt>sortBy</dt>
<dd>
String <span>optional</span>, one of <span>ASC, DESC</span>
</dd>
<dd>Indicates what way to order results if <i>orderBy</i> is used.</dd>
<dt>clientId</dt>
<dd>
Integer <span>optional</span>
</dd>
<dd>Use clientId of clients to restrict results.</dd>
<dt>clientName</dt>
<dd>
String <span>optional</span>
</dd>
<dd>Use displayName of clients to restrict results.</dd>
<dt>fromAccountId</dt>
<dd>
Integer <span>optional</span>
</dd>
<dd>Use fromAccountId of standing instruction transaction to restrict results. fromAccountId is id of <i>fromAccountType</i>.</dd>
<dt>fromAccountType</dt>
<dd>
Integer <span>optional</span>
</dd>
<dd>Use fromAccountType of standing instruction transaction to restrict results. fromAccountType is enum value entity type Ex:Loan Account:1, Savings Account:2</dd>
<dt>transferType</dt>
<dd>
Integer <span>optional</span>
</dd>
<dd>Use transferType of standing instruction transaction to restrict results. transferType is enum value transfer type Ex:Loan Repayment:2, Account Transfer:1</dd>
<dt>fromDate</dt>
<dd>
Date<span>optional</span>
</dd>
<dd>Filters for transactions whose entry Date is greater than or equal to the passed in Date
</dd>
<dt>toDate</dt>
<dd>
Date <span>optional</span>
</dd>
<dd>Filters for transactions whose entry Date is lesser than or equal to the passed in Date
</dd>
<dt>sqlSearch</dt>
<dd>
String <span>optional</span>
</dd>
<dd>Use an sql fragment valid for the underlying standing instruction schema to filter results. e.g. name like %K%</dd>
</dl>
<p>Example Requests : </p>
<div class=apiClick>standinginstructions/history</div>
<br>
<div class=apiClick>standinginstructions/history?orderBy=name&sortOrder=DESC</div>
<br>
<div class=apiClick>standinginstructions/history?offset=10&limit=50</div>
<br>
</div>
<div class="method-example">
<code class="method-declaration">GET https://DomainName/api/v1/standinginstructions/history</code>
<code class="method-response">
{
"totalFilteredRecords": 2,
"pageItems": [
{
"standingInstructionId": 1,
"name": "ACC Transfer",
"fromOffice": {
"id": 1,
"name": "Head Office"
},
"fromClient": {
"id": 1,
"displayName": "Test client",
"officeId": 1,
"officeName": "Head Office"
},
"fromAccountType": {
"id": 2,
"code": "accountType.savings",
"value": "Savings Account"
},
"fromAccount": {
"id": 2,
"accountNo": "000000002",
"productId": 1,
"productName": "General Savings"
},
"toAccountType": {
"id": 2,
"code": "accountType.savings",
"value": "Savings Account"
},
"toAccount": {
"id": 1,
"accountNo": "000000001",
"productId": 1,
"productName": "General Savings"
},
"toOffice": {
"id": 1,
"name": "Head Office"
},
"toClient": {
"id": 1,
"displayName": "Test client",
"officeId": 1,
"officeName": "Head Office"
},
"amount": 10,
"status": "success",
"executionTime": [
2014,
6,
30
],
"errorLog": ""
},
{
"standingInstructionId": 2,
"name": "Pay overdues",
"fromOffice": {
"id": 1,
"name": "Head Office"
},
"fromClient": {
"id": 1,
"displayName": "Test client",
"officeId": 1,
"officeName": "Head Office"
},
"fromAccountType": {
"id": 2,
"code": "accountType.savings",
"value": "Savings Account"
},
"fromAccount": {
"id": 1,
"accountNo": "000000001",
"productId": 1,
"productName": "General Savings"
},
"toAccountType": {
"id": 1,
"code": "accountType.loan",
"value": "Loan Account"
},
"toAccount": {
"id": 1,
"accountNo": "000000001",
"productId": 1,
"productName": "Daily Loan"
},
"toOffice": {
"id": 1,
"name": "Head Office"
},
"toClient": {
"id": 1,
"displayName": "Test client",
"officeId": 1,
"officeName": "Head Office"
},
"amount": 7038.01,
"status": "success",
"executionTime": [
2014,
6,
30
],
"errorLog": ""
}
]
}
</code>
</div>
</div>
<!-- End Account Trasfer Standing Instrution-->
@@ -30638,6 +30854,14 @@ No Request Body:
<td><a href="#standinginstruction_update">Update Standing Instruction</a></td>
<td><a href="#standinginstruction_delete">Delete Standing Instruction(status change)</a></td>
</tr>
<tr>
<td></td>
<td>standinginstructions/history</td>
<td></td>
<td><a href="#standinginstructions_history">Standinginstructions History</a></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>standinginstructions/template</td>
@@ -717,6 +717,7 @@ public class FixedDepositTest {
todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime()));
currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
principal += interestPerMonth;
@@ -824,6 +825,7 @@ public class FixedDepositTest {
todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime()));
currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
principal += interestPerMonth;
@@ -936,6 +938,7 @@ public class FixedDepositTest {
todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime()));
currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
principal += interestPerMonth;
@@ -1051,6 +1054,7 @@ public class FixedDepositTest {
todaysDate.add(Calendar.DATE, daysInMonth);
System.out.println(monthDayFormat.format(todaysDate.getTime()));
currentDate = currentDate - 1;
interestPerMonth = (float) (interestPerDay * principal * currentDate);
System.out.println("IPM = " + interestPerMonth);
principal += interestPerMonth;
@@ -8,6 +8,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import org.junit.Assert;
import org.junit.Before;
@@ -33,6 +34,8 @@ import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
import org.mifosplatform.integrationtests.common.savings.SavingsAccountHelper;
import org.mifosplatform.integrationtests.common.savings.SavingsProductHelper;
import org.mifosplatform.integrationtests.common.savings.SavingsStatusChecker;
import org.mifosplatform.portfolio.account.PortfolioAccountType;
import org.mifosplatform.portfolio.account.domain.AccountTransferType;
import com.jayway.restassured.builder.RequestSpecBuilder;
import com.jayway.restassured.builder.ResponseSpecBuilder;
@@ -628,6 +631,16 @@ public class SchedulerJobsTestResults {
fromSavingsBalanceAfter);
Assert.assertEquals("Verifying To Savings Balance after Successful completion of Scheduler Job", expectedToSavingsBalance,
toSavingsBalanceAfter);
Integer fromAccountType = PortfolioAccountType.SAVINGS.getValue();
Integer transferType = AccountTransferType.ACCOUNT_TRANSFER.getValue();
List<HashMap> standinInstructionHistoryData = this.standingInstructionsHelper.getStandingInstructionHistory(fromSavingsId,
fromAccountType, clientID, transferType);
Assert.assertEquals("Verifying the no of stainding instruction transactions logged for the client", 1,
standinInstructionHistoryData.size());
HashMap loggedTransaction = standinInstructionHistoryData.get(0);
Assert.assertEquals("Verifying transferred amount and logged transaction amounts", (Float) standingInstructionData.get("amount"),
(Float) loggedTransaction.get("amount"));
}
@@ -1,6 +1,7 @@
package org.mifosplatform.integrationtests.common;
import java.util.HashMap;
import java.util.List;
import org.mifosplatform.integrationtests.common.Utils;
@@ -10,7 +11,7 @@ import com.google.gson.Gson;
import com.jayway.restassured.specification.RequestSpecification;
import com.jayway.restassured.specification.ResponseSpecification;
@SuppressWarnings({ "unused", "rawtypes" })
@SuppressWarnings({ "unused", "rawtypes", "unchecked" })
public class StandingInstructionsHelper {
private static final String STANDING_INSTRUCTIONS_URL = "/mifosng-provider/api/v1/standinginstructions";
@@ -95,4 +96,14 @@ public class StandingInstructionsHelper {
final HashMap response = Utils.performServerGet(this.requestSpec, this.responseSpec, GET_STANDING_INSTRUCTION_BY_ID_URL, "");
return response;
}
public List<HashMap> getStandingInstructionHistory(Integer fromSavingsId, Integer fromAccountType, Integer fromClientId, Integer transferType) {
final String STANDING_INSTRUCTIONS_HISTORY_URL = STANDING_INSTRUCTIONS_URL + "/history?" + Utils.TENANT_IDENTIFIER
+ "&fromSavingsId=" + fromSavingsId + "&fromAccountType=" + fromAccountType + "&clientId=" + fromClientId
+ "&transferType=" + transferType;
System.out.println("STANDING_INSTRUCTIONS_HISTORY_URL="+STANDING_INSTRUCTIONS_HISTORY_URL);
final List<HashMap> response = (List<HashMap>) Utils.performServerGet(this.requestSpec, this.responseSpec,
STANDING_INSTRUCTIONS_HISTORY_URL, "pageItems");
return response;
}
}
@@ -13,7 +13,7 @@ import org.mifosplatform.portfolio.account.AccountDetailConstants;
public class StandingInstructionApiConstants {
public static final String STANDING_INSTRUCTION_RESOURCE_NAME = "standinginstructions";
public static final String STANDING_INSTRUCTION_RESOURCE_NAME = "standinginstruction";
public static final String nameParamName = "name";
public static final String priorityParamName = "priority";
@@ -817,11 +817,11 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
sqlBuilder.append("sp.min_balance_for_interest_calculation as minBalanceForInterestCalculation, ");
sqlBuilder.append("sp.allow_overdraft as allowOverdraft, ");
sqlBuilder.append("sp.overdraft_limit as overdraftLimit, ");
sqlBuilder.append("sp.min_required_balance as minRequiredBalance, ");
sqlBuilder.append("sp.allow_overdraft_min_balance as allowOverdraftMinBalance ");
// sqlBuilder.append("sp.annual_fee_amount as annualFeeAmount,");
// sqlBuilder.append("sp.annual_fee_on_month as annualFeeOnMonth, ");
// sqlBuilder.append("sp.annual_fee_on_day as annualFeeOnDay ");
sqlBuilder.append("sp.min_required_balance as minRequiredBalance, ");
sqlBuilder.append("sp.allow_overdraft_min_balance as allowOverdraftMinBalance ");
sqlBuilder.append("from m_savings_product sp ");
sqlBuilder.append("join m_currency curr on curr.code = sp.currency_code ");