merge master to develop
This commit is contained in:
@@ -1 +1 @@
|
||||
releaseVersion=1.2.0.RELEASE
|
||||
releaseVersion=1.2.1.RELEASE
|
||||
+20
-13
@@ -7,6 +7,7 @@ package org.mifosplatform.portfolio.client.data;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.data.EnumOptionData;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||
import org.mifosplatform.portfolio.savings.data.SavingsAccountStatusEnumData;
|
||||
|
||||
/**
|
||||
* Immutable data object for client loan accounts.
|
||||
@@ -27,7 +28,8 @@ public class ClientAccountSummaryData {
|
||||
private final Integer accountStatusId;
|
||||
private final LoanStatusEnumData status;
|
||||
@SuppressWarnings("unused")
|
||||
private final EnumOptionData loanType;
|
||||
private final EnumOptionData loanType;
|
||||
private final SavingsAccountStatusEnumData savingAccountStatus;
|
||||
|
||||
public ClientAccountSummaryData(final Long id, final String externalId, final Long productId, final String loanProductName,
|
||||
final Integer loanStatusId) {
|
||||
@@ -39,20 +41,9 @@ public class ClientAccountSummaryData {
|
||||
this.accountStatusId = loanStatusId;
|
||||
this.status = null;
|
||||
this.loanType = null;
|
||||
this.savingAccountStatus = null;
|
||||
}
|
||||
|
||||
public ClientAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
|
||||
final String loanProductName, final LoanStatusEnumData loanStatus) {
|
||||
this.id = id;
|
||||
this.accountNo = accountNo;
|
||||
this.externalId = externalId;
|
||||
this.productId = productId;
|
||||
this.productName = loanProductName;
|
||||
this.accountStatusId = null;
|
||||
this.status = loanStatus;
|
||||
this.loanType = null;
|
||||
}
|
||||
|
||||
public ClientAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
|
||||
final String loanProductName, final LoanStatusEnumData loanStatus, final EnumOptionData loanType) {
|
||||
this.id = id;
|
||||
@@ -63,12 +54,28 @@ public class ClientAccountSummaryData {
|
||||
this.accountStatusId = null;
|
||||
this.status = loanStatus;
|
||||
this.loanType = loanType;
|
||||
this.savingAccountStatus = null;
|
||||
}
|
||||
|
||||
public ClientAccountSummaryData(final Long id, final String accountNo, final String externalId, final Long productId,
|
||||
final String loanProductName, final SavingsAccountStatusEnumData savingAccountStatus) {
|
||||
this.id = id;
|
||||
this.accountNo = accountNo;
|
||||
this.externalId = externalId;
|
||||
this.productId = productId;
|
||||
this.productName = loanProductName;
|
||||
this.accountStatusId = null;
|
||||
this.status = null;
|
||||
this.loanType = null;
|
||||
this.savingAccountStatus = savingAccountStatus;
|
||||
}
|
||||
|
||||
public Integer accountStatusId() {
|
||||
Integer accountStatus = this.accountStatusId;
|
||||
if (accountStatus == null && this.status != null) {
|
||||
accountStatus = this.status.id().intValue();
|
||||
} else if (accountStatus == null && this.savingAccountStatus != null) {
|
||||
accountStatus = this.savingAccountStatus.id().intValue();
|
||||
}
|
||||
return accountStatus;
|
||||
}
|
||||
|
||||
+22
-7
@@ -31,6 +31,9 @@ import org.mifosplatform.portfolio.group.data.GroupGeneralData;
|
||||
import org.mifosplatform.portfolio.group.service.SearchParameters;
|
||||
import org.mifosplatform.portfolio.loanaccount.data.LoanStatusEnumData;
|
||||
import org.mifosplatform.portfolio.loanproduct.service.LoanEnumerations;
|
||||
import org.mifosplatform.portfolio.savings.data.SavingsAccountStatusEnumData;
|
||||
import org.mifosplatform.portfolio.savings.service.SavingStatusMapper;
|
||||
import org.mifosplatform.portfolio.savings.service.SavingsEnumerations;
|
||||
import org.mifosplatform.useradministration.domain.AppUser;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
@@ -410,8 +413,18 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
final List<ClientAccountSummaryData> savingsAccounts = this.jdbcTemplate.query(savingsSql, savingsAccountSummaryDataMapper,
|
||||
new Object[] { clientId });
|
||||
|
||||
approvedSavingAccounts.addAll(savingsAccounts);
|
||||
if (results != null) {
|
||||
for (ClientAccountSummaryData row : savingsAccounts) {
|
||||
|
||||
SavingStatusMapper statusMapper = new SavingStatusMapper(row.accountStatusId());
|
||||
|
||||
if (statusMapper.isOpen()) {
|
||||
approvedSavingAccounts.add(row);
|
||||
} else {
|
||||
pendingApprovalSavingAccounts.add(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
return new ClientAccountSummaryCollectionData(pendingApprovalLoans, awaitingDisbursalLoans, openLoans, closedLoans,
|
||||
pendingApprovalDepositAccounts, approvedDepositAccounts, withdrawnByClientDespositAccounts, rejectedDepositAccounts,
|
||||
closedDepositAccounts, preclosedDepositAccounts, maturedDepositAccounts, pendingApprovalSavingAccounts,
|
||||
@@ -445,7 +458,7 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
|
||||
public ClientSavingsAccountSummaryDataMapper() {
|
||||
StringBuilder accountsSummary = new StringBuilder();
|
||||
accountsSummary.append("sa.id as id, sa.account_no as accountNo, sa.external_id as externalId,");
|
||||
accountsSummary.append("sa.id as id, sa.account_no as accountNo, sa.external_id as externalId, sa.status_enum as statusEnum, ");
|
||||
accountsSummary.append("sa.product_id as productId, p.name as productName ");
|
||||
accountsSummary.append("from m_savings_account sa ");
|
||||
accountsSummary.append("join m_savings_product as p on p.id = sa.product_id ");
|
||||
@@ -464,10 +477,11 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
final String accountNo = rs.getString("accountNo");
|
||||
final String externalId = rs.getString("externalId");
|
||||
final Long productId = JdbcSupport.getLong(rs, "productId");
|
||||
final String loanProductName = rs.getString("productName");
|
||||
final LoanStatusEnumData loanStatus = null;
|
||||
final String savingsProductName = rs.getString("productName");
|
||||
final Integer statusId = JdbcSupport.getInteger(rs, "statusEnum");
|
||||
final SavingsAccountStatusEnumData savingAccountStatus = SavingsEnumerations.status(statusId);
|
||||
|
||||
return new ClientAccountSummaryData(id, accountNo, externalId, productId, loanProductName, loanStatus);
|
||||
return new ClientAccountSummaryData(id, accountNo, externalId, productId, savingsProductName, savingAccountStatus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -476,8 +490,9 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService
|
||||
public String loanAccountSummarySchema() {
|
||||
|
||||
StringBuilder accountsSummary = new StringBuilder("l.id as id, l.account_no as accountNo, l.external_id as externalId,");
|
||||
accountsSummary.append("l.product_id as productId, lp.name as productName,").append("l.loan_status_id as statusId, l.loan_type_enum as loanType ")
|
||||
.append("from m_loan l ").append("LEFT JOIN m_product_loan AS lp ON lp.id = l.product_id ");
|
||||
accountsSummary.append("l.product_id as productId, lp.name as productName,")
|
||||
.append("l.loan_status_id as statusId, l.loan_type_enum as loanType ").append("from m_loan l ")
|
||||
.append("LEFT JOIN m_product_loan AS lp ON lp.id = l.product_id ");
|
||||
|
||||
return accountsSummary.toString();
|
||||
}
|
||||
|
||||
+4
-1
@@ -10,7 +10,6 @@ package org.mifosplatform.portfolio.savings.data;
|
||||
*/
|
||||
public class SavingsAccountStatusEnumData {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private final Long id;
|
||||
@SuppressWarnings("unused")
|
||||
private final String code;
|
||||
@@ -32,4 +31,8 @@ public class SavingsAccountStatusEnumData {
|
||||
this.active = active;
|
||||
this.closed = closed;
|
||||
}
|
||||
|
||||
public Long id() {
|
||||
return this.id;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -151,7 +151,7 @@ public class SavingsProductDataValidator {
|
||||
|
||||
if (this.fromApiJsonHelper.parameterExists(annualFeeAmountParamName, element)) {
|
||||
final BigDecimal annualFeeAmount = fromApiJsonHelper.extractBigDecimalWithLocaleNamed(annualFeeAmountParamName, element);
|
||||
baseDataValidator.reset().parameter(annualFeeAmountParamName).value(annualFeeAmount).notNull().positiveAmount();
|
||||
baseDataValidator.reset().parameter(annualFeeAmountParamName).value(annualFeeAmount).ignoreIfNull().positiveAmount();
|
||||
|
||||
if (annualFeeAmount != null) {
|
||||
MonthDay monthDayOfAnnualFee = fromApiJsonHelper.extractMonthDayNamed(annualFeeOnMonthDayParamName, element);
|
||||
|
||||
+4
-3
@@ -800,9 +800,10 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
||||
existingReversedTransactionIds.addAll(findExistingReversedTransactionIds());
|
||||
|
||||
final Money amount = Money.of(this.currency, transactionAmount);
|
||||
|
||||
final SavingsAccountTransaction transaction = SavingsAccountTransaction.deposit(this, paymentDetail, transactionDate, amount);
|
||||
this.transactions.add(transaction);
|
||||
|
||||
|
||||
this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper, this.transactions);
|
||||
|
||||
final LocalDate today = DateUtils.getLocalDateOfTenant();
|
||||
@@ -877,9 +878,9 @@ public class SavingsAccount extends AbstractPersistable<Long> {
|
||||
|
||||
final Money transactionAmountMoney = Money.of(this.currency, transactionAmount);
|
||||
|
||||
if (isNotEnoughFundsToWithdraw(transactionAmountMoney)) {
|
||||
if (this.summary.getAccountBalance(this.currency).isLessThan(transactionAmountMoney.plus(this.withdrawalFeeAmount))) {
|
||||
//
|
||||
throw new InsufficientAccountBalanceException("transactionAmount", getAccountBalance(), transactionAmount);
|
||||
throw new InsufficientAccountBalanceException("transactionAmount", getAccountBalance(), this.withdrawalFeeAmount, transactionAmount);
|
||||
}
|
||||
|
||||
final SavingsAccountTransaction transaction = SavingsAccountTransaction.withdrawal(this, paymentDetail, transactionDate,
|
||||
|
||||
+3
-3
@@ -15,8 +15,8 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRul
|
||||
*/
|
||||
public class InsufficientAccountBalanceException extends AbstractPlatformDomainRuleException {
|
||||
|
||||
public InsufficientAccountBalanceException(final String paramName, final BigDecimal accountBalance, final BigDecimal withdrawalRequested) {
|
||||
super("error.msg.savingsaccount.transaction.insufficient.account.balance", "Insufficient account balance.", paramName,
|
||||
accountBalance, withdrawalRequested);
|
||||
public InsufficientAccountBalanceException(final String paramName, final BigDecimal accountBalance, final BigDecimal withdrawalFee, final BigDecimal transactionAmount) {
|
||||
super(withdrawalFee != null? "error.msg.savingsaccount.transaction.insufficient.account.balance.withdraw" : "error.msg.savingsaccount.transaction.insufficient.account.balance",
|
||||
"Insufficient account balance.", paramName, accountBalance, withdrawalFee, transactionAmount);
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -9,8 +9,9 @@ import org.mifosplatform.infrastructure.core.exception.AbstractPlatformDomainRul
|
||||
|
||||
public class InvalidSavingsAccountStateTransitionException extends AbstractPlatformDomainRuleException {
|
||||
|
||||
public InvalidSavingsAccountStateTransitionException(final String action, String postFix, String defaultUserMessage, Object... defaultUserMessageArgs) {
|
||||
super("error.msg.saving." + action + "." + postFix, defaultUserMessage, defaultUserMessageArgs);
|
||||
}
|
||||
public InvalidSavingsAccountStateTransitionException(final String action, final String postFix, final String defaultUserMessage,
|
||||
final Object... defaultUserMessageArgs) {
|
||||
super("error.msg.saving." + action + "." + postFix, defaultUserMessage, defaultUserMessageArgs);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package org.mifosplatform.portfolio.savings.service;
|
||||
|
||||
public class SavingStatusMapper {
|
||||
|
||||
private final Integer statusId;
|
||||
|
||||
public SavingStatusMapper(Integer statusId) {
|
||||
this.statusId = statusId;
|
||||
}
|
||||
|
||||
public boolean isPendingApproval() {
|
||||
return Integer.valueOf(100).equals(statusId);
|
||||
}
|
||||
|
||||
public boolean isOpen() {
|
||||
return Integer.valueOf(300).equals(statusId);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user