Deposit documentation fixes from pull#111

This commit is contained in:
Madhukar
2013-02-11 21:37:15 +05:30
parent 91a3249c09
commit 835b034926
9 changed files with 1098 additions and 65 deletions
+1034 -20
View File
File diff suppressed because it is too large Load Diff
@@ -35,7 +35,7 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi
"currencyCode", "digitsAfterDecimal", "minimumBalance", "maximumBalance", "tenureInMonths", "maturityDefaultInterestRate",
"maturityMinInterestRate", "maturityMaxInterestRate", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed", "preClosureAllowed", "preClosureInterestRate", "interestCompoundingAllowed", "isLockinPeriodAllowed",
"lockinPeriod", "lockinPeriodType"));
"lockinPeriod", "lockinPeriodType", "currency"));
private static final Set<String> SAVINGS_DEPOSIT_ACCOUNT_DATA_PARAMETERS = new HashSet<String>(Arrays.asList("productOptions",
"interestCompoundedEveryPeriodTypeOptions", "id", "externalId", "clientId", "clientName", "productId", "productName", "status",
@@ -45,10 +45,8 @@ public class SavingProductCommandValidator {
baseDataValidator.reset().parameter("interestCalculationMethod").value(command.getInterestCalculationMethod()).ignoreIfNull();
baseDataValidator.reset().parameter("minimumBalanceForWithdrawal").value(command.getMinimumBalanceForWithdrawal()).ignoreIfNull()
.zeroOrPositiveAmount();
baseDataValidator.reset().parameter("isPartialDepositAllowed").value(command.isPartialDepositAllowed())
.trueOrFalseRequired(command.isPartialDepositAllowedChanged()).ignoreIfNull();
baseDataValidator.reset().parameter("isLockinPeriodAllowed").value(command.isLockinPeriodAllowed())
.trueOrFalseRequired(command.isLockinPeriodAllowedChanged()).ignoreIfNull();
baseDataValidator.reset().parameter("isPartialDepositAllowed").value(command.isPartialDepositAllowed()).ignoreIfNull();
baseDataValidator.reset().parameter("isLockinPeriodAllowed").value(command.isLockinPeriodAllowed()).ignoreIfNull();
baseDataValidator.reset().parameter("lockinPeriod").value(command.getLockinPeriod()).ignoreIfNull();
baseDataValidator.reset().parameter("lockinPeriodType").value(command.getLockinPeriodType()).ignoreIfNull();
@@ -110,7 +110,7 @@ public class DepositAccountData {
this.preClosureInterestRate = null;
this.interestCompoundedEveryPeriodTypeOptions = new ArrayList<EnumOptionData>();
this.productOptions = new ArrayList<DepositProductLookup>();
this.productOptions = null;
this.withdrawnonDate = null;
this.closedonDate = null;
@@ -121,17 +121,17 @@ public class DepositAccountData {
this.interestPaid = null;
this.isInterestWithdrawable = false;
this.interestCompoundingAllowed = true;
this.availableInterestForWithdrawal = new BigDecimal(0);
this.availableWithdrawalAmount = new BigDecimal(0);
this.todaysDate = new LocalDate();
this.interestCompoundingAllowed = false;
this.availableInterestForWithdrawal = null;
this.availableWithdrawalAmount = null;
this.todaysDate = null;
this.isLockinPeriodAllowed = true;
this.isLockinPeriodAllowed = false;
this.lockinPeriod = null;
this.lockinPeriodType = null;
this.availableInterest = BigDecimal.ZERO;
this.interestPostedAmount = BigDecimal.ZERO;
this.availableInterest = null;
this.interestPostedAmount = null;
this.lastInterestPostedDate = null;
this.nextInterestPostedDate = null;
@@ -169,7 +169,7 @@ public class DepositAccountData {
this.preClosureInterestRate = account.getPreClosureInterestRate();
this.interestCompoundedEveryPeriodTypeOptions = interestCompoundedEveryPeriodTypeOptions;
this.productOptions = new ArrayList<DepositProductLookup>(productOptions);
this.productOptions = defaultIfEmpty(productOptions);
this.withdrawnonDate = account.getWithdrawnonDate();
this.rejectedonDate = account.getRejectedonDate();
@@ -326,7 +326,8 @@ public class DepositAccountData {
public DepositAccountData(final Long clientId, final String clientName, final Long productId, final String productName,
final CurrencyData currency, final BigDecimal deposit, final BigDecimal interestRate, final Integer tenureInMonths,
final Integer interestCompoundedEvery, final EnumOptionData interestCompoundedEveryPeriodType, final boolean renewalAllowed,
final boolean preClosureAllowed, final BigDecimal preClosureInterestRate, final boolean interestCompoundingAllowed) {
final boolean preClosureAllowed, final BigDecimal preClosureInterestRate, final boolean interestCompoundingAllowed, Integer lockinPeriod,
EnumOptionData lockinPeriodType, boolean lockinPeriodAllowed) {
this.id = null;
this.externalId = null;
this.status = null;
@@ -365,12 +366,11 @@ public class DepositAccountData {
this.interestCompoundingAllowed = interestCompoundingAllowed;
this.availableInterestForWithdrawal = BigDecimal.ZERO;
this.availableWithdrawalAmount = BigDecimal.ZERO;
this.todaysDate = new LocalDate();
this.todaysDate = null;
// need to update in constructor's call method and update it
this.lockinPeriod = Integer.valueOf(0);
this.isLockinPeriodAllowed = true;
this.lockinPeriodType = interestCompoundedEveryPeriodType;
this.lockinPeriod = lockinPeriod;
this.isLockinPeriodAllowed = lockinPeriodAllowed;
this.lockinPeriodType = lockinPeriodType;
this.availableInterest = BigDecimal.ZERO;
this.interestPostedAmount = BigDecimal.ZERO;
@@ -593,14 +593,14 @@ public class DepositAccountData {
return BigDecimal.ZERO;
}
} else
return BigDecimal.ZERO;
return null;
return availableInterestForWithdrawal;
}
private BigDecimal determineAvalableWithdrawalAmount(final DepositAccountData account) {
BigDecimal avalablePreclosureWithdrawalAmount = BigDecimal.ZERO;
BigDecimal avalablePreclosureWithdrawalAmount = null;
if (this.status != null) {
if (account.getStatus().getId() == 300) {
// if(new LocalDate().isBefore(account.getMaturedOn()) || new
@@ -633,5 +633,13 @@ public class DepositAccountData {
return BigDecimal.valueOf(depsoitAmount.doubleValue() * days.doubleValue() * interestRateForOneDay.doubleValue());
}
private List<DepositProductLookup> defaultIfEmpty(final Collection<DepositProductLookup> collection) {
List<DepositProductLookup> returnCollection = null;
if (collection != null && !collection.isEmpty()) {
returnCollection = new ArrayList<DepositProductLookup>(collection);
}
return returnCollection;
}
}
@@ -110,7 +110,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
selectedProduct.getMaturityDefaultInterestRate(), selectedProduct.getTenureInMonths(),
selectedProduct.getInterestCompoundedEvery(), selectedProduct.getInterestCompoundedEveryPeriodType(),
selectedProduct.isRenewalAllowed(), selectedProduct.isPreClosureAllowed(), selectedProduct.getPreClosureInterestRate(),
selectedProduct.isInterestCompoundingAllowed());
selectedProduct.isInterestCompoundingAllowed(),selectedProduct.getLockinPeriod(),selectedProduct.getLockinPeriodType(),selectedProduct.isLockinPeriodAllowed());
} else {
accountData = DepositAccountData.createFrom(clientAccount.id(), clientAccount.displayName());
}
@@ -107,7 +107,7 @@ public class DepositProductsApiResource {
"lastModifedOn", "currencyCode", "digitsAfterDecimal", "minimumBalance", "maximumBalance", "tenureInMonths",
"maturityDefaultInterestRate", "maturityMinInterestRate", "maturityMaxInterestRate", "interestCompoundedEvery",
"interestCompoundedEveryPeriodType", "renewalAllowed", "preClosureAllowed", "preClosureInterestRate",
"interestCompoundingAllowed", "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType"));
"interestCompoundingAllowed", "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType", "currency"));
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) {
@@ -131,7 +131,7 @@ public class DepositProductsApiResource {
"lastModifedOn", "currencyCode", "digitsAfterDecimal", "minimumBalance", "maximumBalance", "tenureInMonths",
"maturityDefaultInterestRate", "maturityMinInterestRate", "maturityMaxInterestRate", "interestCompoundedEvery",
"interestCompoundedEveryPeriodType", "renewalAllowed", "preClosureAllowed", "preClosureInterestRate",
"interestCompoundingAllowed", "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType"));
"interestCompoundingAllowed", "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType", "currency"));
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) {
@@ -162,7 +162,7 @@ public class DepositProductsApiResource {
"currencyCode", "digitsAfterDecimal", "minimumBalance", "maximumBalance", "tenureInMonths", "maturityDefaultInterestRate",
"maturityMinInterestRate", "maturityMaxInterestRate", "interestCompoundedEvery", "interestCompoundedEveryPeriodType",
"renewalAllowed", "preClosureAllowed", "preClosureInterestRate", "isLockinPeriodAllowed", "lockinPeriod",
"lockinPeriodType"));
"lockinPeriodType", "currency"));
Set<String> responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters());
if (responseParameters.isEmpty()) {
@@ -28,6 +28,7 @@ public class DepositProductData {
private final BigDecimal maturityMaxInterestRate;
private final Integer interestCompoundedEvery;
private final EnumOptionData interestCompoundedEveryPeriodType;
private final CurrencyData currency;
private final boolean renewalAllowed;
private final boolean preClosureAllowed;
@@ -51,7 +52,7 @@ public class DepositProductData {
final BigDecimal maturityMaxInterestRate, final Integer interestCompoundedEvery,
final EnumOptionData interestCompoundedEveryPeriodType, final boolean renewalAllowed, final boolean preClosureAllowed,
final BigDecimal preClosureInterestRate, final boolean interestCompoundingAllowed, final boolean isLockinPeriodAllowed,
final Integer lockinPeriod, final EnumOptionData lockinPeriodType) {
final Integer lockinPeriod, final EnumOptionData lockinPeriodType,final CurrencyData currencyData) {
this.createdOn = createdOn;
this.lastModifedOn = lastModifedOn;
@@ -78,7 +79,7 @@ public class DepositProductData {
this.lockinPeriod = lockinPeriod;
this.lockinPeriodType = lockinPeriodType;
this.isLockinPeriodAllowed = isLockinPeriodAllowed;
this.currency = currencyData;
this.currencyOptions = new ArrayList<CurrencyData>();
this.interestCompoundedEveryPeriodTypeOptions = new ArrayList<EnumOptionData>();
}
@@ -93,25 +94,27 @@ public class DepositProductData {
this.name = null;
this.description = null;
this.currencyCode = null;
this.digitsAfterDecimal = Integer.valueOf(0);
this.minimumBalance = BigDecimal.ZERO;
this.maximumBalance = BigDecimal.ZERO;
this.digitsAfterDecimal = null;
this.minimumBalance = null;
this.maximumBalance = null;
this.tenureInMonths = Integer.valueOf(0);
this.maturityDefaultInterestRate = BigDecimal.ZERO;
this.maturityMinInterestRate = BigDecimal.ZERO;
this.maturityMaxInterestRate = BigDecimal.ZERO;
this.interestCompoundedEvery = Integer.valueOf(1);
this.tenureInMonths = null;
this.maturityDefaultInterestRate = null;
this.maturityMinInterestRate = null;
this.maturityMaxInterestRate = null;
this.interestCompoundedEvery = null;
this.interestCompoundedEveryPeriodType = defaultInterestCompoundedEveryPeriodType;
this.renewalAllowed = true;
this.preClosureAllowed = true;
this.preClosureInterestRate = BigDecimal.ZERO;
this.interestCompoundingAllowed = true;
this.renewalAllowed = false;
this.preClosureAllowed = false;
this.preClosureInterestRate = null;
this.interestCompoundingAllowed = false;
this.isLockinPeriodAllowed = true;
this.lockinPeriod = Integer.valueOf(0);
this.isLockinPeriodAllowed = false;
this.lockinPeriod = null;
this.lockinPeriodType = defaultInterestCompoundedEveryPeriodType;
this.currency = null;
this.currencyOptions = currencyOptions;
this.interestCompoundedEveryPeriodTypeOptions = interestCompoundedEveryPeriodTypeOptions;
@@ -145,9 +148,15 @@ public class DepositProductData {
this.lockinPeriod = product.getLockinPeriod();
this.lockinPeriodType = product.getLockinPeriodType();
this.isLockinPeriodAllowed = product.isLockinPeriodAllowed();
this.currencyOptions = currencyOptions;
this.interestCompoundedEveryPeriodTypeOptions = interestCompoundedEveryPeriodTypeOptions;
if (this.currencyOptions != null && this.currencyOptions.size() == 1) {
this.currency = new ArrayList<CurrencyData>(this.currencyOptions).get(0);
} else {
this.currency = product.currency;
}
}
public Long getId() {
@@ -321,7 +321,7 @@ public class DepositProduct extends AbstractAuditableCustom<AppUser, Long> {
if (!inRange) {
final String actualValue = depositAmount.toPlainString();
final String minValue = (this.minimumBalance == null) ? "" : this.minimumBalance.toPlainString();
final String maxValue = (this.minimumBalance == null) ? "" : this.minimumBalance.toPlainString();
final String maxValue = (this.maximumBalance == null) ? "" : this.maximumBalance.toPlainString();
throw new DepositProductValueOutsideRangeException(actualValue, minValue, maxValue, "deposit.account.deposit.amount");
}
}
@@ -90,6 +90,10 @@ public class DepositProductReadPlatformServiceImpl implements DepositProductRead
String currencyCode = rs.getString("currencyCode");
Integer currencyDigits = JdbcSupport.getInteger(rs, "currencyDigits");
String currencyName = rs.getString("currencyName");
String currencyNameCode = rs.getString("currencyNameCode");
String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
CurrencyData currencyData = new CurrencyData(currencyCode, currencyName, currencyDigits, currencyDisplaySymbol, currencyNameCode);
DateTime createdOn = JdbcSupport.getDateTime(rs, "createdon");
DateTime lastModifedOn = JdbcSupport.getDateTime(rs, "modifiedon");
@@ -121,7 +125,7 @@ public class DepositProductReadPlatformServiceImpl implements DepositProductRead
return new DepositProductData(createdOn, lastModifedOn, id, exernalId, name, description, currencyCode, currencyDigits,
minimumBalance, maximumBalance, tenureMonths, maturityDefaultInterestRate, maturityMinInterestRate,
maturityMaxInterestRate, interestCompoundedEvery, interestCompoundedEveryPeriodType, canRenew, canPreClose,
preClosureInterestRate, interestCompoundingAllowed, isLockinPeriodAllowed, lockinPeriod, lockinPeriodType);
preClosureInterestRate, interestCompoundingAllowed, isLockinPeriodAllowed, lockinPeriod, lockinPeriodType, currencyData);
}
}