For UI
This commit is contained in:
@@ -231,7 +231,9 @@ public class ClientsApiResource {
|
||||
Set<String> typicalResponseParameters = new HashSet<String>(
|
||||
Arrays.asList("pendingApprovalLoans", "awaitingDisbursalLoans", "openLoans", "closedLoans",
|
||||
"anyLoanCount", "pendingApprovalLoanCount", "awaitingDisbursalLoanCount", "activeLoanCount", "closedLoanCount",
|
||||
"pendingApprovalDespositAccountsCount", "pendingApprovalDespositAccounts", "approvedDespositAccountsCount", "approvedDespositAccounts")
|
||||
"pendingApprovalDespositAccountsCount", "pendingApprovalDespositAccounts", "approvedDespositAccountsCount", "approvedDespositAccounts",
|
||||
"withdrawnByClientDespositAccountsCount","withdrawnByClientDespositAccounts","closedDepositAccountsCount","closedDepositAccounts",
|
||||
"rejectedDepositAccountsCount","rejectedDepositAccounts","preclosedDepositAccountsCount","preclosedDepositAccounts")
|
||||
);
|
||||
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
|
||||
+4
-1
@@ -1,5 +1,6 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@@ -111,6 +112,7 @@ public class DepositAccountsApiResource {
|
||||
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
|
||||
DepositPermissionData permissions = null;
|
||||
BigDecimal availableInterestForWithdrawal = null;
|
||||
|
||||
if (responseParameters.isEmpty()) {
|
||||
responseParameters.addAll(typicalResponseParameters);
|
||||
@@ -127,11 +129,12 @@ public class DepositAccountsApiResource {
|
||||
Set<String> associationParameters = ApiParameterHelper.extractAssociationsForResponseIfProvided(uriInfo.getQueryParameters());
|
||||
if (!associationParameters.isEmpty()) {
|
||||
if (associationParameters.contains("all")) {
|
||||
responseParameters.addAll(Arrays.asList("permissions"));
|
||||
responseParameters.addAll(Arrays.asList("permissions","availableInterestForWithdrawal"));
|
||||
} else {
|
||||
responseParameters.addAll(associationParameters);
|
||||
}
|
||||
permissions = this.depositAccountReadPlatformService.retrieveDepositAccountsPermissions(account);
|
||||
availableInterestForWithdrawal = this.depositAccountReadPlatformService.retrieveAvailableInterestForWithdrawal(account);
|
||||
account = new DepositAccountData(account, permissions, account.getTransactions());
|
||||
}
|
||||
|
||||
|
||||
+54
-1
@@ -20,6 +20,14 @@ public class ClientAccountSummaryCollectionData {
|
||||
private final List<ClientAccountSummaryData> pendingApprovalDepositAccounts;
|
||||
private final int approvedDespositAccountsCount;
|
||||
private final List<ClientAccountSummaryData> approvedDepositAccounts;
|
||||
private final int withdrawnByClientDespositAccountsCount;
|
||||
private final List<ClientAccountSummaryData> withdrawnByClientDespositAccounts;
|
||||
private final int closedDepositAccountsCount;
|
||||
private final List<ClientAccountSummaryData> closedDepositAccounts;
|
||||
private final int rejectedDepositAccountsCount;
|
||||
private final List<ClientAccountSummaryData> rejectedDepositAccounts;
|
||||
private final int preclosedDepositAccountsCount;
|
||||
private final List<ClientAccountSummaryData> preclosedDepositAccounts;
|
||||
|
||||
public ClientAccountSummaryCollectionData(
|
||||
final List<ClientAccountSummaryData> pendingApprovalLoans,
|
||||
@@ -27,13 +35,21 @@ public class ClientAccountSummaryCollectionData {
|
||||
final List<ClientAccountSummaryData> openLoans,
|
||||
final List<ClientAccountSummaryData> closedLoans,
|
||||
final List<ClientAccountSummaryData> pendingApprovalDepositAccounts,
|
||||
final List<ClientAccountSummaryData> approvedDepositAccounts) {
|
||||
final List<ClientAccountSummaryData> approvedDepositAccounts,
|
||||
final List<ClientAccountSummaryData> withdrawnByClientDespositAccounts,
|
||||
final List<ClientAccountSummaryData> rejectedDepositAccounts,
|
||||
final List<ClientAccountSummaryData> closedDepositAccounts,
|
||||
final List<ClientAccountSummaryData> preclosedDepositAccounts) {
|
||||
this.pendingApprovalLoans = pendingApprovalLoans;
|
||||
this.awaitingDisbursalLoans = awaitingDisbursalLoans;
|
||||
this.openLoans = openLoans;
|
||||
this.closedLoans = closedLoans;
|
||||
this.pendingApprovalDepositAccounts = pendingApprovalDepositAccounts;
|
||||
this.approvedDepositAccounts = approvedDepositAccounts;
|
||||
this.withdrawnByClientDespositAccounts = withdrawnByClientDespositAccounts;
|
||||
this.closedDepositAccounts = closedDepositAccounts;
|
||||
this.rejectedDepositAccounts = rejectedDepositAccounts;
|
||||
this.preclosedDepositAccounts = preclosedDepositAccounts;
|
||||
|
||||
this.pendingApprovalLoanCount = this.pendingApprovalLoans.size();
|
||||
this.awaitingDisbursalLoanCount = this.awaitingDisbursalLoans.size();
|
||||
@@ -43,6 +59,11 @@ public class ClientAccountSummaryCollectionData {
|
||||
|
||||
this.pendingApprovalDespositAccountsCount = this.pendingApprovalDepositAccounts.size();
|
||||
this.approvedDespositAccountsCount = this.approvedDepositAccounts.size();
|
||||
this.withdrawnByClientDespositAccountsCount = this.withdrawnByClientDespositAccounts.size();
|
||||
this.closedDepositAccountsCount = this.closedDepositAccounts.size();
|
||||
this.rejectedDepositAccountsCount = this.rejectedDepositAccounts.size();
|
||||
this.preclosedDepositAccountsCount = this.preclosedDepositAccounts.size();
|
||||
|
||||
}
|
||||
|
||||
public int getAnyLoanCount() {
|
||||
@@ -96,4 +117,36 @@ public class ClientAccountSummaryCollectionData {
|
||||
public List<ClientAccountSummaryData> getApprovedDepositAccounts() {
|
||||
return approvedDepositAccounts;
|
||||
}
|
||||
|
||||
public int getWithdrawnByClientDespositAccountsCount() {
|
||||
return withdrawnByClientDespositAccountsCount;
|
||||
}
|
||||
|
||||
public List<ClientAccountSummaryData> getWithdrawnByClientDespositAccounts() {
|
||||
return withdrawnByClientDespositAccounts;
|
||||
}
|
||||
|
||||
public int getClosedDepositAccountsCount() {
|
||||
return closedDepositAccountsCount;
|
||||
}
|
||||
|
||||
public List<ClientAccountSummaryData> getClosedDepositAccounts() {
|
||||
return closedDepositAccounts;
|
||||
}
|
||||
|
||||
public int getRejectedDepositAccountsCount() {
|
||||
return rejectedDepositAccountsCount;
|
||||
}
|
||||
|
||||
public List<ClientAccountSummaryData> getRejectedDepositAccounts() {
|
||||
return rejectedDepositAccounts;
|
||||
}
|
||||
|
||||
public int getPreclosedDepositAccountsCount() {
|
||||
return preclosedDepositAccountsCount;
|
||||
}
|
||||
|
||||
public List<ClientAccountSummaryData> getPreclosedDepositAccounts() {
|
||||
return preclosedDepositAccounts;
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -262,7 +262,8 @@ public class DepositAccountData {
|
||||
final EnumOptionData interestCompoundedEveryPeriodType,
|
||||
final boolean renewalAllowed,
|
||||
final boolean preClosureAllowed,
|
||||
final BigDecimal preClosureInterestRate) {
|
||||
final BigDecimal preClosureInterestRate,
|
||||
final boolean interestCompoundingAllowed) {
|
||||
this.id=null;
|
||||
this.externalId = null;
|
||||
this.status = null;
|
||||
@@ -298,7 +299,7 @@ public class DepositAccountData {
|
||||
this.permissions = null;
|
||||
this.interestPaid=null;
|
||||
this.isInterestWithdrawable=false;
|
||||
this.interestCompoundingAllowed=true;
|
||||
this.interestCompoundingAllowed=interestCompoundingAllowed;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
|
||||
+7
-6
@@ -6,17 +6,18 @@ public class DepositPermissionData {
|
||||
private final boolean withdrawnByApplicantAllowed;
|
||||
private final boolean undoApprovalAllowed;
|
||||
private final boolean pendingApproval;
|
||||
//private final boolean isActive;
|
||||
private final boolean isInterestWithdrawalAllowed;
|
||||
|
||||
private final boolean anyActionOnAccountAllowed;
|
||||
|
||||
|
||||
public DepositPermissionData(final boolean rejectAllowed,final boolean withdrawnByApplicantAllowed,final boolean undoApprovalAllowed,final boolean pendingApproval) {
|
||||
public DepositPermissionData(final boolean rejectAllowed,final boolean withdrawnByApplicantAllowed,final boolean undoApprovalAllowed,final boolean pendingApproval,final boolean interestWithdrawalAllowed) {
|
||||
this.rejectAllowed = rejectAllowed;
|
||||
this.withdrawnByApplicantAllowed = withdrawnByApplicantAllowed;
|
||||
this.undoApprovalAllowed = undoApprovalAllowed;
|
||||
this.pendingApproval = pendingApproval;
|
||||
this.anyActionOnAccountAllowed = isRejectAllowed() || isPendingApproval() || isUndoApprovalAllowed() || isWithdrawnByApplicantAllowed();
|
||||
this.isInterestWithdrawalAllowed = interestWithdrawalAllowed;
|
||||
this.anyActionOnAccountAllowed = isRejectAllowed() || isPendingApproval() || isUndoApprovalAllowed() || isWithdrawnByApplicantAllowed() || isInterestWithdrawalAllowed();
|
||||
}
|
||||
|
||||
public boolean isRejectAllowed() {
|
||||
@@ -39,7 +40,7 @@ public class DepositPermissionData {
|
||||
return anyActionOnAccountAllowed;
|
||||
}
|
||||
|
||||
/*public boolean isActive() {
|
||||
return isActive;
|
||||
}*/
|
||||
public boolean isInterestWithdrawalAllowed() {
|
||||
return isInterestWithdrawalAllowed;
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -109,8 +109,8 @@ public class GoogleGsonApiJsonSerializerService implements ApiJsonSerializerServ
|
||||
"interestCompoundedEvery", "interestCompoundedEveryPeriodType",
|
||||
"renewalAllowed","preClosureAllowed","preClosureInterestRate",
|
||||
"withdrawnonDate","rejectedonDate","closedonDate","transactions",
|
||||
"permissions","isInterestWithdrawable","interestPaid","interestCompoundingAllowed"
|
||||
)
|
||||
"permissions","isInterestWithdrawable","interestPaid","interestCompoundingAllowed",
|
||||
"availableInterestForWithdrawal")
|
||||
);
|
||||
|
||||
private static final Set<String> CLIENT_DATA_PARAMETERS = new HashSet<String>(
|
||||
@@ -125,7 +125,11 @@ public class GoogleGsonApiJsonSerializerService implements ApiJsonSerializerServ
|
||||
"activeLoanCount", "closedLoanCount",
|
||||
"pendingApprovalDespositAccountsCount",
|
||||
"pendingApprovalDespositAccounts",
|
||||
"approvedDespositAccountsCount", "approvedDespositAccounts"));
|
||||
"approvedDespositAccountsCount", "approvedDespositAccounts",
|
||||
"withdrawnByClientDespositAccountsCount","withdrawnByClientDespositAccounts",
|
||||
"closedDepositAccountsCount","closedDepositAccounts",
|
||||
"rejectedDepositAccountsCount","rejectedDepositAccounts",
|
||||
"preclosedDepositAccountsCount","preclosedDepositAccounts"));
|
||||
|
||||
private static final Set<String> GROUP_DATA_PARAMETERS = new HashSet<String>(
|
||||
Arrays.asList("id", "name", "externalId", "clientMembers",
|
||||
|
||||
+15
-4
@@ -196,8 +196,10 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
|
||||
List<ClientAccountSummaryData> pendingApprovalDepositAccounts = new ArrayList<ClientAccountSummaryData>();
|
||||
List<ClientAccountSummaryData> approvedDepositAccounts = new ArrayList<ClientAccountSummaryData>();
|
||||
// List<ClientLoanAccountSummaryData> openDepositAccounts = new ArrayList<ClientLoanAccountSummaryData>();
|
||||
// List<ClientLoanAccountSummaryData> closedDepositAccounts = new ArrayList<ClientLoanAccountSummaryData>();
|
||||
List<ClientAccountSummaryData> withdrawnByClientDespositAccounts = new ArrayList<ClientAccountSummaryData>();
|
||||
List<ClientAccountSummaryData> closedDepositAccounts = new ArrayList<ClientAccountSummaryData>();
|
||||
List<ClientAccountSummaryData> rejectedDepositAccounts = new ArrayList<ClientAccountSummaryData>();
|
||||
List<ClientAccountSummaryData> preclosedDepositAccounts = new ArrayList<ClientAccountSummaryData>();
|
||||
|
||||
ClientDespoitAccountSummaryDataMapper depositAccountMapper = new ClientDespoitAccountSummaryDataMapper();
|
||||
|
||||
@@ -210,12 +212,21 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
pendingApprovalDepositAccounts.add(row);
|
||||
} else if (row.getAccountStatusId() == 300) {
|
||||
approvedDepositAccounts.add(row);
|
||||
}
|
||||
} else if (row.getAccountStatusId() == 400) {
|
||||
withdrawnByClientDespositAccounts.add(row);
|
||||
} else if (row.getAccountStatusId() == 500) {
|
||||
rejectedDepositAccounts.add(row);
|
||||
} else if (row.getAccountStatusId() == 600) {
|
||||
closedDepositAccounts.add(row);
|
||||
} else if (row.getAccountStatusId() == 800) {
|
||||
preclosedDepositAccounts.add(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new ClientAccountSummaryCollectionData(pendingApprovalLoans, awaitingDisbursalLoans, openLoans, closedLoans,
|
||||
pendingApprovalDepositAccounts, approvedDepositAccounts);
|
||||
pendingApprovalDepositAccounts, approvedDepositAccounts, withdrawnByClientDespositAccounts,
|
||||
rejectedDepositAccounts,closedDepositAccounts,preclosedDepositAccounts);
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
throw new ClientNotFoundException(clientId);
|
||||
}
|
||||
|
||||
+3
-2
@@ -293,7 +293,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
getInterestCompoundedFrequencyType());
|
||||
}
|
||||
this.interestAccrued = futureValueOnMaturity.minus(getDeposit()).getAmount();
|
||||
this.total = this.interestCompoundingAllowed ? futureValueOnMaturity.getAmount() : getDeposit().getAmount();
|
||||
this.total = futureValueOnMaturity.getAmount();
|
||||
|
||||
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(getDeposit(), getActualCommencementDate(),getAccuredInterest());
|
||||
depositaccountTransaction.updateAccount(this);
|
||||
@@ -593,7 +593,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
interestCompoundedEvery,
|
||||
this.product.getInterestCompoundedEveryPeriodType());
|
||||
}
|
||||
this.total = account.isInterestCompoundingAllowed()?accuredtotalAmount.getAmount():getDeposit().getAmount();
|
||||
this.total = account.isInterestCompoundingAllowed()?accuredtotalAmount.getAmount():BigDecimal.valueOf(accuredtotalAmount.getAmount().doubleValue()-this.interstPaid.doubleValue());
|
||||
this.interestAccrued = accuredtotalAmount.minus(deposit).getAmount();
|
||||
|
||||
}
|
||||
@@ -605,6 +605,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
|
||||
depositAccountTransaction.updateAccount(this);
|
||||
this.depositaccountTransactions.add(depositAccountTransaction);
|
||||
this.interstPaid = this.interstPaid.add(interest.getAmount());
|
||||
this.total = this.total.subtract(this.interstPaid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,5 +1,6 @@
|
||||
package org.mifosng.platform.saving.service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.mifosng.platform.api.data.DepositAccountData;
|
||||
@@ -13,5 +14,7 @@ public interface DepositAccountReadPlatformService {
|
||||
|
||||
DepositAccountData retrieveNewDepositAccountDetails(Long clientId, Long productId);
|
||||
|
||||
DepositPermissionData retrieveDepositAccountsPermissions(DepositAccountData depositAccountData);
|
||||
DepositPermissionData retrieveDepositAccountsPermissions(DepositAccountData depositAccountData);
|
||||
|
||||
BigDecimal retrieveAvailableInterestForWithdrawal(DepositAccountData account);
|
||||
}
|
||||
|
||||
+12
-2
@@ -6,6 +6,7 @@ import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.joda.time.LocalDate;
|
||||
import org.joda.time.Months;
|
||||
import org.mifosng.platform.api.data.ClientData;
|
||||
import org.mifosng.platform.api.data.CurrencyData;
|
||||
import org.mifosng.platform.api.data.DepositAccountData;
|
||||
@@ -122,7 +123,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
currency, selectedProduct.getMinimumBalance(), selectedProduct.getMaturityDefaultInterestRate(),
|
||||
selectedProduct.getTenureInMonths(), selectedProduct.getInterestCompoundedEvery(), selectedProduct.getInterestCompoundedEveryPeriodType(),
|
||||
selectedProduct.isRenewalAllowed(), selectedProduct.isPreClosureAllowed(),
|
||||
selectedProduct.getPreClosureInterestRate());
|
||||
selectedProduct.getPreClosureInterestRate(),selectedProduct.isInterestCompoundingAllowed());
|
||||
} else {
|
||||
accountData = DepositAccountData.createFrom(clientAccount.getId(), clientAccount.getDisplayName());
|
||||
}
|
||||
@@ -256,7 +257,16 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
|
||||
//boolean isActive = (depositAccountData.getStatus().getId().equals(300L));
|
||||
boolean rejectAllowed = pendingApproval;
|
||||
boolean withdrawnByApplicantAllowed = pendingApproval;
|
||||
boolean interestWithdrawAllowed = depositAccountData.isInterestWithdrawable();
|
||||
|
||||
return new DepositPermissionData(rejectAllowed, withdrawnByApplicantAllowed, undoApprovalAllowed, pendingApproval);
|
||||
return new DepositPermissionData(rejectAllowed, withdrawnByApplicantAllowed, undoApprovalAllowed, pendingApproval, interestWithdrawAllowed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BigDecimal retrieveAvailableInterestForWithdrawal(DepositAccountData account) {
|
||||
BigDecimal interstGettingForPeriod = BigDecimal.valueOf(account.getActualInterestAccrued().doubleValue()/new Double(account.getTenureInMonths()));
|
||||
Integer noOfMonthsforInterestCal = Months.monthsBetween(account.getActualCommencementDate(), new LocalDate()).getMonths();
|
||||
Integer noOfPeriods = noOfMonthsforInterestCal / account.getInterestCompoundedEvery();
|
||||
return BigDecimal.valueOf(interstGettingForPeriod.multiply(new BigDecimal(noOfPeriods)).doubleValue()-account.getInterestPaid().doubleValue());
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -336,7 +336,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
if (account == null || account.isDeleted()) {
|
||||
throw new DepositAccountNotFoundException(command.getAccountId());
|
||||
}
|
||||
if(account.isInterestWithdrawable()){
|
||||
if(account.isInterestWithdrawable() && !account.isInterestCompoundingAllowed()){
|
||||
/*BigDecimal interstGettingForPeriod = BigDecimal.valueOf(account.getAccuredInterest().getAmount().doubleValue()/new Double(account.getTenureInMonths()));
|
||||
LocalDate lastInterestTakenDate = getLastTxnDate(account);
|
||||
Integer noOfMonthsforInterestCal = Months.monthsBetween(lastInterestTakenDate, new LocalDate()).getMonths();
|
||||
|
||||
Reference in New Issue
Block a user