Get the transactions for DepositAccounts
This commit is contained in:
+1
-1
@@ -68,7 +68,7 @@ public class DepositAccountsApiResource {
|
||||
"interestCompoundedEvery",
|
||||
"interestCompoundedEveryPeriodType", "renewalAllowed",
|
||||
"preClosureAllowed", "preClosureInterestRate",
|
||||
"withdrawnonDate","rejectedonDate","closedonDate"));
|
||||
"withdrawnonDate","rejectedonDate","closedonDate","transactions"));
|
||||
|
||||
|
||||
@POST
|
||||
|
||||
@@ -46,6 +46,8 @@ public class DepositAccountData {
|
||||
private final List<EnumOptionData> interestCompoundedEveryPeriodTypeOptions;
|
||||
private final List<DepositProductLookup> productOptions;
|
||||
|
||||
private Collection<DepositAccountTransactionData> transactions;
|
||||
|
||||
/*
|
||||
* used when returning account template data but only a clientId is passed, no selected product.
|
||||
*/
|
||||
@@ -87,6 +89,8 @@ public class DepositAccountData {
|
||||
this.withdrawnonDate=null;
|
||||
this.closedonDate=null;
|
||||
this.rejectedonDate=null;
|
||||
|
||||
this.transactions=null;
|
||||
}
|
||||
|
||||
public DepositAccountData(
|
||||
@@ -124,6 +128,8 @@ public class DepositAccountData {
|
||||
this.withdrawnonDate=account.getWithdrawnonDate();
|
||||
this.rejectedonDate=account.getRejectedonDate();
|
||||
this.closedonDate=account.getClosedonDate();
|
||||
|
||||
this.transactions=account.getTransactions();
|
||||
}
|
||||
|
||||
public DepositAccountData(
|
||||
@@ -184,6 +190,8 @@ public class DepositAccountData {
|
||||
this.withdrawnonDate = withdrawnonDate;
|
||||
this.rejectedonDate = rejectedonDate;
|
||||
this.closedonDate = closedonDate;
|
||||
|
||||
this.transactions = null;
|
||||
}
|
||||
|
||||
public DepositAccountData(
|
||||
@@ -230,6 +238,8 @@ public class DepositAccountData {
|
||||
this.withdrawnonDate=null;
|
||||
this.closedonDate=null;
|
||||
this.rejectedonDate=null;
|
||||
|
||||
this.transactions = null;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
@@ -347,4 +357,13 @@ public class DepositAccountData {
|
||||
public LocalDate getClosedonDate() {
|
||||
return closedonDate;
|
||||
}
|
||||
|
||||
public Collection<DepositAccountTransactionData> getTransactions() {
|
||||
return transactions;
|
||||
}
|
||||
|
||||
public void setTransactions(Collection<DepositAccountTransactionData> transactions) {
|
||||
this.transactions = transactions;
|
||||
}
|
||||
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package org.mifosng.platform.api.data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
|
||||
public class DepositAccountTransactionData {
|
||||
|
||||
private final Long transactionId;
|
||||
private final EnumOptionData transactionType;
|
||||
private final LocalDate transactionDate;
|
||||
private final BigDecimal transactionAmount;
|
||||
private final Long accountId;
|
||||
|
||||
public DepositAccountTransactionData() {
|
||||
|
||||
this.transactionId = null;
|
||||
this.accountId = null;
|
||||
this.transactionType = null;
|
||||
this.transactionDate = null;
|
||||
this.transactionAmount = null;
|
||||
|
||||
}
|
||||
|
||||
public DepositAccountTransactionData(final Long transactionId, final Long accountId, final EnumOptionData transactionType, final LocalDate transactionDate, final BigDecimal transactionAmount ){
|
||||
|
||||
this.transactionId = transactionId;
|
||||
this.accountId = accountId;
|
||||
this.transactionType = transactionType;
|
||||
this.transactionDate = transactionDate;
|
||||
this.transactionAmount = transactionAmount;
|
||||
}
|
||||
|
||||
public Long getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public Long getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public EnumOptionData getTransactionType() {
|
||||
return transactionType;
|
||||
}
|
||||
|
||||
public LocalDate getTransactionDate() {
|
||||
return transactionDate;
|
||||
}
|
||||
|
||||
public BigDecimal getTransactionAmount() {
|
||||
return transactionAmount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
+2
-1
@@ -105,7 +105,7 @@ public class GoogleGsonApiJsonSerializerService implements
|
||||
"currency", "deposit", "maturityInterestRate", "tenureInMonths",
|
||||
"interestCompoundedEvery", "interestCompoundedEveryPeriodType",
|
||||
"renewalAllowed","preClosureAllowed","preClosureInterestRate",
|
||||
"withdrawnonDate","rejectedonDate","closedonDate"
|
||||
"withdrawnonDate","rejectedonDate","closedonDate","transactions"
|
||||
)
|
||||
);
|
||||
|
||||
@@ -559,4 +559,5 @@ public class GoogleGsonApiJsonSerializerService implements
|
||||
return helper.serializedJsonFrom(gsonDeserializer,
|
||||
staff.toArray(new StaffData[staff.size()]));
|
||||
}
|
||||
|
||||
}
|
||||
+59
-3
@@ -3,12 +3,15 @@ package org.mifosng.platform.saving.service;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.mifosng.platform.api.data.ClientData;
|
||||
import org.mifosng.platform.api.data.CurrencyData;
|
||||
import org.mifosng.platform.api.data.DepositAccountData;
|
||||
import org.mifosng.platform.api.data.DepositAccountTransactionData;
|
||||
import org.mifosng.platform.api.data.DepositProductData;
|
||||
import org.mifosng.platform.api.data.DepositProductLookup;
|
||||
import org.mifosng.platform.api.data.EnumOptionData;
|
||||
@@ -50,7 +53,23 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
|
||||
String sql = "select " + mapper.schema() + " where da.is_deleted=0";
|
||||
|
||||
return this.jdbcTemplate.query(sql,mapper, new Object[]{});
|
||||
Collection<DepositAccountData> depositAccountDatas = this.jdbcTemplate.query(sql,mapper, new Object[]{});
|
||||
|
||||
DepositAccountTransactionMapper transactionMapper = new DepositAccountTransactionMapper();
|
||||
String transactionSchema = "Select "+transactionMapper.schema();
|
||||
Collection<DepositAccountTransactionData> depositAccountTransactionDatas = this.jdbcTemplate.query(transactionSchema, transactionMapper, new Object[]{});
|
||||
|
||||
for(DepositAccountData depositAccountData : depositAccountDatas){
|
||||
List<DepositAccountTransactionData> myAccountTransactionDatas = new ArrayList<DepositAccountTransactionData>();
|
||||
for(DepositAccountTransactionData depositAccountTransactionData : depositAccountTransactionDatas){
|
||||
if(depositAccountData.getId().equals(depositAccountTransactionData.getAccountId())){
|
||||
myAccountTransactionDatas.add(depositAccountTransactionData);
|
||||
}
|
||||
depositAccountData.setTransactions(myAccountTransactionDatas);
|
||||
}
|
||||
}
|
||||
|
||||
return depositAccountDatas;
|
||||
|
||||
}
|
||||
|
||||
@@ -64,6 +83,20 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
|
||||
DepositAccountData productData = this.jdbcTemplate.queryForObject(sql, mapper, new Object[] { accountId });
|
||||
|
||||
DepositAccountTransactionMapper transactionMapper = new DepositAccountTransactionMapper();
|
||||
String transactionSchema = "Select "+transactionMapper.schema() +" where txn.deposit_account_id = ? ";
|
||||
Collection<DepositAccountTransactionData> depositAccountTransactionDatas = this.jdbcTemplate.query(transactionSchema, transactionMapper, new Object[]{accountId});
|
||||
|
||||
List<DepositAccountTransactionData> myAccountTransactionDatas = new ArrayList<DepositAccountTransactionData>();
|
||||
for(DepositAccountTransactionData depositAccountTransactionData : depositAccountTransactionDatas){
|
||||
|
||||
if(productData.getId().equals(depositAccountTransactionData.getAccountId()))
|
||||
myAccountTransactionDatas.add(depositAccountTransactionData);
|
||||
|
||||
}
|
||||
|
||||
productData.setTransactions(myAccountTransactionDatas);
|
||||
|
||||
return productData;
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
throw new LoanProductNotFoundException(accountId);
|
||||
@@ -126,11 +159,11 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
+ " da.is_renewal_allowed as renewalAllowed, da.is_preclosure_allowed as preClosureAllowed, da.pre_closure_interest_rate as preClosureInterestRate, "
|
||||
+ " da.withdrawnon_date as withdrawnonDate, da.rejectedon_date as rejectedonDate, da.closedon_date as closedonDate, "
|
||||
+ " c.firstname as firstname, c.lastname as lastname, pd.name as productName,"
|
||||
+ " curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol"
|
||||
+ " curr.name as currencyName, curr.internationalized_name_code as currencyNameCode, curr.display_symbol as currencyDisplaySymbol "
|
||||
+ " from m_deposit_account da "
|
||||
+ " join m_currency curr on curr.code = da.currency_code "
|
||||
+ " join m_client c on c.id = da.client_id "
|
||||
+ " join m_product_deposit pd on pd.id = da.product_id";
|
||||
+ " join m_product_deposit pd on pd.id = da.product_id";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -190,4 +223,27 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
withdrawnonDate,rejectedonDate,closedonDate);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class DepositAccountTransactionMapper implements RowMapper<DepositAccountTransactionData>{
|
||||
|
||||
public String schema() {
|
||||
return " txn.id as transactionId, txn.deposit_account_id as accountId, txn.transaction_type_enum as transactionType, txn.transaction_date as transactionDate, txn.amount as transactionAmount "
|
||||
+ " from m_deposit_account_transaction txn";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DepositAccountTransactionData mapRow(ResultSet rs, int rowNum)
|
||||
throws SQLException {
|
||||
|
||||
Long transactionId = rs.getLong("transactionId");
|
||||
Long accountId = rs.getLong("accountId");
|
||||
Integer transactionTypeValue = JdbcSupport.getInteger(rs, "transactionType");
|
||||
EnumOptionData transactionType=DepositAccountTransactionEnumerations.depositType(transactionTypeValue);
|
||||
LocalDate transactionDate = JdbcSupport.getLocalDate(rs, "transactionDate");
|
||||
BigDecimal transactionAmount = rs.getBigDecimal("transactionAmount");
|
||||
|
||||
return new DepositAccountTransactionData(transactionId, accountId, transactionType, transactionDate, transactionAmount);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
package org.mifosng.platform.saving.service;
|
||||
|
||||
import org.mifosng.platform.api.data.EnumOptionData;
|
||||
import org.mifosng.platform.saving.domain.DepositTransactionType;
|
||||
|
||||
public class DepositAccountTransactionEnumerations {
|
||||
|
||||
public static EnumOptionData depositType(final Integer statusId) {
|
||||
return depositType(DepositTransactionType.fromInt(statusId));
|
||||
}
|
||||
|
||||
private static EnumOptionData depositType(DepositTransactionType transactionType) {
|
||||
|
||||
EnumOptionData optionData=null;
|
||||
switch (transactionType) {
|
||||
case DEPOSIT:
|
||||
optionData=new EnumOptionData(DepositTransactionType.DEPOSIT.getValue().longValue(), DepositTransactionType.DEPOSIT.getCode(), "Deposit");
|
||||
break;
|
||||
|
||||
case WITHDRAW:
|
||||
optionData=new EnumOptionData(DepositTransactionType.WITHDRAW.getValue().longValue(), DepositTransactionType.WITHDRAW.getCode(), "Withdraw");
|
||||
break;
|
||||
|
||||
case REVERSAL:
|
||||
optionData=new EnumOptionData(DepositTransactionType.REVERSAL.getValue().longValue(), DepositTransactionType.REVERSAL.getCode(), "Revarsal");
|
||||
break;
|
||||
default:
|
||||
optionData=new EnumOptionData(DepositTransactionType.INVALID.getValue().longValue(), DepositTransactionType.INVALID.getCode(), "Invalid Transaction");
|
||||
break;
|
||||
}
|
||||
return optionData;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user