fixed bugs from pull #32

This commit is contained in:
Madhukar
2012-09-06 19:22:14 +05:30
parent 1e8d4b8c9d
commit a06ed0d33b
4 changed files with 24 additions and 41 deletions
@@ -27,8 +27,7 @@ public class DepositAccountData {
private final Integer tenureInMonths; private final Integer tenureInMonths;
private final LocalDate projectedCommencementDate; private final LocalDate projectedCommencementDate;
private final LocalDate actualCommencementDate; private final LocalDate actualCommencementDate;
private final LocalDate projectedMaturityDate; private final LocalDate maturedOn;
private final LocalDate actualMaturityDate;
private final LocalDate withdrawnonDate; private final LocalDate withdrawnonDate;
private final LocalDate rejectedonDate; private final LocalDate rejectedonDate;
private final LocalDate closedonDate; private final LocalDate closedonDate;
@@ -71,8 +70,7 @@ public class DepositAccountData {
this.tenureInMonths = null; this.tenureInMonths = null;
this.projectedCommencementDate = null; this.projectedCommencementDate = null;
this.actualCommencementDate = null; this.actualCommencementDate = null;
this.projectedMaturityDate = null; this.maturedOn = null;
this.actualMaturityDate = null;
this.projectedInterestAccrued = null; this.projectedInterestAccrued = null;
this.actualInterestAccrued = null; this.actualInterestAccrued = null;
this.projectedMaturityAmount = null; this.projectedMaturityAmount = null;
@@ -110,8 +108,7 @@ public class DepositAccountData {
this.tenureInMonths = account.getTenureInMonths(); this.tenureInMonths = account.getTenureInMonths();
this.projectedCommencementDate = account.getProjectedCommencementDate(); this.projectedCommencementDate = account.getProjectedCommencementDate();
this.actualCommencementDate = account.getActualCommencementDate(); this.actualCommencementDate = account.getActualCommencementDate();
this.projectedMaturityDate = account.getProjectedMaturityDate(); this.maturedOn = account.getMaturedOn();
this.actualMaturityDate = account.getActualMaturityDate();
this.projectedInterestAccrued = account.getProjectedInterestAccrued(); this.projectedInterestAccrued = account.getProjectedInterestAccrued();
this.actualInterestAccrued = account.getActualInterestAccrued(); this.actualInterestAccrued = account.getActualInterestAccrued();
this.projectedMaturityAmount = account.getProjectedMaturityAmount(); this.projectedMaturityAmount = account.getProjectedMaturityAmount();
@@ -145,8 +142,7 @@ public class DepositAccountData {
final Integer tenureInMonths, final Integer tenureInMonths,
final LocalDate projectedCommencementDate, final LocalDate projectedCommencementDate,
final LocalDate actualCommencementDate, final LocalDate actualCommencementDate,
final LocalDate projectedMaturityDate, final LocalDate maturedOn,
final LocalDate actualMaturityDate,
final BigDecimal projectedInterestAccrued, final BigDecimal projectedInterestAccrued,
final BigDecimal actualInterestAccrued, final BigDecimal actualInterestAccrued,
final BigDecimal projectedMaturityAmount, final BigDecimal projectedMaturityAmount,
@@ -172,8 +168,7 @@ public class DepositAccountData {
this.tenureInMonths = tenureInMonths; this.tenureInMonths = tenureInMonths;
this.projectedCommencementDate = projectedCommencementDate; this.projectedCommencementDate = projectedCommencementDate;
this.actualCommencementDate = actualCommencementDate; this.actualCommencementDate = actualCommencementDate;
this.projectedMaturityDate = projectedMaturityDate; this.maturedOn = maturedOn;
this.actualMaturityDate = actualMaturityDate;
this.projectedInterestAccrued = projectedInterestAccrued; this.projectedInterestAccrued = projectedInterestAccrued;
this.actualInterestAccrued = actualInterestAccrued; this.actualInterestAccrued = actualInterestAccrued;
this.projectedMaturityAmount = projectedMaturityAmount; this.projectedMaturityAmount = projectedMaturityAmount;
@@ -220,8 +215,7 @@ public class DepositAccountData {
this.tenureInMonths = tenureInMonths; this.tenureInMonths = tenureInMonths;
this.projectedCommencementDate = null; this.projectedCommencementDate = null;
this.actualCommencementDate = null; this.actualCommencementDate = null;
this.projectedMaturityDate = null; this.maturedOn = null;
this.actualMaturityDate = null;
this.projectedInterestAccrued = null; this.projectedInterestAccrued = null;
this.actualInterestAccrued = null; this.actualInterestAccrued = null;
this.projectedMaturityAmount = null; this.projectedMaturityAmount = null;
@@ -294,12 +288,8 @@ public class DepositAccountData {
return actualCommencementDate; return actualCommencementDate;
} }
public LocalDate getProjectedMaturityDate() { public LocalDate getMaturedOn() {
return projectedMaturityDate; return maturedOn;
}
public LocalDate getActualMaturityDate() {
return actualMaturityDate;
} }
public BigDecimal getProjectedInterestAccrued() { public BigDecimal getProjectedInterestAccrued() {
@@ -1016,7 +1016,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
// preClosureInterestRate // preClosureInterestRate
Set<String> supportedParams = new HashSet<String>( Set<String> supportedParams = new HashSet<String>(
Arrays.asList("clientId", "productId", "externalId", "depositAmount", "maturityInterestRate", Arrays.asList("clientId", "productId", "externalId", "deposit", "maturityInterestRate",
"tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType", "commencementDate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType", "commencementDate",
"renewalAllowed", "preClosureAllowed", "renewalAllowed", "preClosureAllowed",
"locale", "dateFormat") "locale", "dateFormat")
@@ -1027,7 +1027,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
Long clientId = extractLongParameter("clientId", requestMap, modifiedParameters); Long clientId = extractLongParameter("clientId", requestMap, modifiedParameters);
Long productId = extractLongParameter("productId", requestMap, modifiedParameters); Long productId = extractLongParameter("productId", requestMap, modifiedParameters);
String externalId = extractStringParameter("externalId", requestMap,modifiedParameters); String externalId = extractStringParameter("externalId", requestMap,modifiedParameters);
BigDecimal depositAmount=extractBigDecimalParameter("depositAmount", requestMap, modifiedParameters); BigDecimal deposit=extractBigDecimalParameter("deposit", requestMap, modifiedParameters);
BigDecimal interestRate = extractBigDecimalParameter("maturityInterestRate", requestMap, modifiedParameters); BigDecimal interestRate = extractBigDecimalParameter("maturityInterestRate", requestMap, modifiedParameters);
Integer tenureInMonths = extractIntegerParameter("tenureInMonths", requestMap, modifiedParameters); Integer tenureInMonths = extractIntegerParameter("tenureInMonths", requestMap, modifiedParameters);
@@ -1039,7 +1039,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
boolean preClosureAllowed = extractBooleanParameter("preClosureAllowed", requestMap, modifiedParameters); boolean preClosureAllowed = extractBooleanParameter("preClosureAllowed", requestMap, modifiedParameters);
return new DepositAccountCommand(modifiedParameters, resourceIdentifier, clientId, productId, return new DepositAccountCommand(modifiedParameters, resourceIdentifier, clientId, productId,
externalId, depositAmount, interestRate, tenureInMonths, externalId, deposit, interestRate, tenureInMonths,
interestCompoundedEvery, interestCompoundedEveryPeriodType, commencementDate, renewalAllowed, preClosureAllowed); interestCompoundedEvery, interestCompoundedEveryPeriodType, commencementDate, renewalAllowed, preClosureAllowed);
} }
@@ -1122,19 +1122,19 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService {
Type typeOfMap = new TypeToken<Map<String, String>>(){}.getType(); Type typeOfMap = new TypeToken<Map<String, String>>(){}.getType();
Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap); Map<String, String> requestMap = gsonConverter.fromJson(json, typeOfMap);
Set<String> supportedParams = new HashSet<String>(Arrays.asList("locale","eventDate", "dateFormat", "tenureInMonths", "depositAmount", "interestCompoundedEveryPeriodType", "productId","interestCompoundedEvery")); Set<String> supportedParams = new HashSet<String>(Arrays.asList("locale","commencementDate", "dateFormat", "tenureInMonths", "deposit", "interestCompoundedEveryPeriodType", "productId","interestCompoundedEvery"));
checkForUnsupportedParameters(requestMap, supportedParams); checkForUnsupportedParameters(requestMap, supportedParams);
Set<String> modifiedParameters = new HashSet<String>(); Set<String> modifiedParameters = new HashSet<String>();
LocalDate eventDate = extractLocalDateParameter("eventDate", requestMap, modifiedParameters); LocalDate commencementDate = extractLocalDateParameter("commencementDate", requestMap, modifiedParameters);
BigDecimal depositAmount=extractBigDecimalParameter("depositAmount", requestMap, modifiedParameters); BigDecimal deposit=extractBigDecimalParameter("deposit", requestMap, modifiedParameters);
Integer tenureInMonths = extractIntegerParameter("tenureInMonths", requestMap, modifiedParameters); Integer tenureInMonths = extractIntegerParameter("tenureInMonths", requestMap, modifiedParameters);
Integer interestCompoundedEveryPeriodType = extractIntegerParameter("interestCompoundedEveryPeriodType", requestMap, modifiedParameters); Integer interestCompoundedEveryPeriodType = extractIntegerParameter("interestCompoundedEveryPeriodType", requestMap, modifiedParameters);
Integer interestCompoundedEvery = extractIntegerParameter("interestCompoundedEvery", requestMap, modifiedParameters); Integer interestCompoundedEvery = extractIntegerParameter("interestCompoundedEvery", requestMap, modifiedParameters);
Long productId = extractLongParameter("productId", requestMap, modifiedParameters); Long productId = extractLongParameter("productId", requestMap, modifiedParameters);
return new DepositStateTransitionApprovalCommand(resourceIdentifier, productId, eventDate, tenureInMonths, depositAmount, interestCompoundedEveryPeriodType,interestCompoundedEvery); return new DepositStateTransitionApprovalCommand(resourceIdentifier, productId, commencementDate, tenureInMonths, deposit, interestCompoundedEveryPeriodType,interestCompoundedEvery);
} }
} }
@@ -76,13 +76,8 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Temporal(TemporalType.DATE) @Temporal(TemporalType.DATE)
@Column(name = "projected_maturity_date") @Column(name = "matured_on")
private Date projectedMaturityDate; private Date maturedOn;
@SuppressWarnings("unused")
@Temporal(TemporalType.DATE)
@Column(name = "actual_maturity_date")
private Date actualMaturityDate;
@SuppressWarnings("unused") @SuppressWarnings("unused")
@Column(name = "projected_interest_accrued_on_maturity", scale = 6, precision = 19, nullable = false) @Column(name = "projected_interest_accrued_on_maturity", scale = 6, precision = 19, nullable = false)
@@ -196,7 +191,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
this.interestCompoundedFrequencyType = interestCompoundedFrequencyPeriodType.getValue(); this.interestCompoundedFrequencyType = interestCompoundedFrequencyPeriodType.getValue();
if (commencementDate != null) { if (commencementDate != null) {
this.projectedCommencementDate = commencementDate.toDate(); this.projectedCommencementDate = commencementDate.toDate();
this.projectedMaturityDate = commencementDate.plusMonths(this.tenureInMonths).toDate(); this.maturedOn = commencementDate.plusMonths(this.tenureInMonths).toDate();
} }
this.renewalAllowed = renewalAllowed; this.renewalAllowed = renewalAllowed;
@@ -248,8 +243,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
this.actualCommencementDate = actualCommencementDate.toDate(); this.actualCommencementDate = actualCommencementDate.toDate();
// TODO - KW - there was probably no need for 'projected' and 'actual' maturity dates - a single 'matures_on' attribute is sufficient // TODO - KW - there was probably no need for 'projected' and 'actual' maturity dates - a single 'matures_on' attribute is sufficient
this.projectedMaturityDate = getActualCommencementDate().plusMonths(this.tenureInMonths).toDate(); this.maturedOn = getActualCommencementDate().plusMonths(this.tenureInMonths).toDate();
this.actualMaturityDate = getActualCommencementDate().plusMonths(this.tenureInMonths).toDate();
Money futureValueOnMaturity = calculator.calculateInterestOnMaturityFor(getDeposit(), this.tenureInMonths, Money futureValueOnMaturity = calculator.calculateInterestOnMaturityFor(getDeposit(), this.tenureInMonths,
this.interestRate, this.interestCompoundedEvery, getInterestCompoundedFrequencyType()); this.interestRate, this.interestCompoundedEvery, getInterestCompoundedFrequencyType());
@@ -257,7 +251,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
this.interestAccrued = futureValueOnMaturity.minus(getDeposit()).getAmount(); this.interestAccrued = futureValueOnMaturity.minus(getDeposit()).getAmount();
this.total = futureValueOnMaturity.getAmount(); this.total = futureValueOnMaturity.getAmount();
DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(futureValueOnMaturity, getActualCommencementDate()); DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(getDeposit(), getActualCommencementDate());
depositaccountTransaction.updateAccount(this); depositaccountTransaction.updateAccount(this);
this.depositaccountTransactions.add(depositaccountTransaction); this.depositaccountTransactions.add(depositaccountTransaction);
@@ -355,7 +349,7 @@ public class DepositAccount extends AbstractAuditableCustom<AppUser, Long> {
this.depositStatus = statusEnum.getValue(); this.depositStatus = statusEnum.getValue();
this.actualCommencementDate = null; this.actualCommencementDate = null;
this.actualMaturityDate = null; this.maturedOn = getProjectedCommencementDate().plusMonths(this.tenureInMonths).toDate();
this.total=null; this.total=null;
this.interestAccrued=null; this.interestAccrued=null;
this.depositaccountTransactions.clear(); this.depositaccountTransactions.clear();
@@ -152,7 +152,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
+ " da.currency_code as currencyCode, da.currency_digits as currencyDigits, " + " da.currency_code as currencyCode, da.currency_digits as currencyDigits, "
+ " da.deposit_amount as depositAmount, da.status_enum as statusId, " + " da.deposit_amount as depositAmount, da.status_enum as statusId, "
+ " da.maturity_nominal_interest_rate as interestRate, da.tenure_months as termInMonths, da.projected_commencement_date as projectedCommencementDate," + " da.maturity_nominal_interest_rate as interestRate, da.tenure_months as termInMonths, da.projected_commencement_date as projectedCommencementDate,"
+ " da.actual_commencement_date as actualCommencementDate, da.projected_maturity_date as projectedMaturityDate, da.actual_maturity_date as actualMaturityDate," + " da.actual_commencement_date as actualCommencementDate, da.matured_on as maturedOn,"
+ " da.projected_interest_accrued_on_maturity as projectedInterestAccrued, da.actual_interest_accrued as actualInterestAccrued, " + " da.projected_interest_accrued_on_maturity as projectedInterestAccrued, da.actual_interest_accrued as actualInterestAccrued, "
+ " da.projected_total_maturity_amount as projectedMaturityAmount, da.actual_total_amount as actualMaturityAmount, " + " da.projected_total_maturity_amount as projectedMaturityAmount, da.actual_total_amount as actualMaturityAmount, "
+ " da.interest_compounded_every as interestCompoundedEvery, da.interest_compounded_every_period_enum as interestCompoundedEveryPeriodType, " + " da.interest_compounded_every as interestCompoundedEvery, da.interest_compounded_every_period_enum as interestCompoundedEveryPeriodType, "
@@ -194,8 +194,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
LocalDate projectedCommencementDate = JdbcSupport.getLocalDate(rs, "projectedCommencementDate"); LocalDate projectedCommencementDate = JdbcSupport.getLocalDate(rs, "projectedCommencementDate");
LocalDate actualCommencementDate = JdbcSupport.getLocalDate(rs, "actualCommencementDate"); LocalDate actualCommencementDate = JdbcSupport.getLocalDate(rs, "actualCommencementDate");
LocalDate projectedMaturityDate = JdbcSupport.getLocalDate(rs, "projectedMaturityDate"); LocalDate maturedOn = JdbcSupport.getLocalDate(rs, "maturedOn");
LocalDate actualMaturityDate = JdbcSupport.getLocalDate(rs, "actualMaturityDate");
BigDecimal projectedInterestAccrued = rs.getBigDecimal("projectedInterestAccrued"); BigDecimal projectedInterestAccrued = rs.getBigDecimal("projectedInterestAccrued");
BigDecimal actualInterestAccrued = rs.getBigDecimal("actualInterestAccrued"); BigDecimal actualInterestAccrued = rs.getBigDecimal("actualInterestAccrued");
@@ -216,7 +215,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead
LocalDate closedonDate = JdbcSupport.getLocalDate(rs, "closedonDate"); LocalDate closedonDate = JdbcSupport.getLocalDate(rs, "closedonDate");
return new DepositAccountData(id, externalId, status, clientId, clientName, productId, productName, currencyData, depositAmount, return new DepositAccountData(id, externalId, status, clientId, clientName, productId, productName, currencyData, depositAmount,
interestRate, termInMonths, projectedCommencementDate, actualCommencementDate, projectedMaturityDate, actualMaturityDate, interestRate, termInMonths, projectedCommencementDate, actualCommencementDate, maturedOn,
projectedInterestAccrued, actualInterestAccrued, projectedMaturityAmount, actualMaturityAmount, projectedInterestAccrued, actualInterestAccrued, projectedMaturityAmount, actualMaturityAmount,
interestCompoundedEvery, interestCompoundedEveryPeriodType, interestCompoundedEvery, interestCompoundedEveryPeriodType,
renewalAllowed, preClosureAllowed, preClosureInterestRate, renewalAllowed, preClosureAllowed, preClosureInterestRate,