From a06ed0d33bd996871bd60857aea79ac5152d42a9 Mon Sep 17 00:00:00 2001 From: Madhukar Date: Thu, 6 Sep 2012 19:19:39 +0530 Subject: [PATCH] fixed bugs from pull #32 --- .../platform/api/data/DepositAccountData.java | 26 ++++++------------- .../ApiDataConversionServiceImpl.java | 14 +++++----- .../saving/domain/DepositAccount.java | 18 +++++-------- ...DepositAccountReadPlatformServiceImpl.java | 7 +++-- 4 files changed, 24 insertions(+), 41 deletions(-) diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java index 7cfbaa5eb..596e05bf2 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/data/DepositAccountData.java @@ -27,8 +27,7 @@ public class DepositAccountData { private final Integer tenureInMonths; private final LocalDate projectedCommencementDate; private final LocalDate actualCommencementDate; - private final LocalDate projectedMaturityDate; - private final LocalDate actualMaturityDate; + private final LocalDate maturedOn; private final LocalDate withdrawnonDate; private final LocalDate rejectedonDate; private final LocalDate closedonDate; @@ -71,8 +70,7 @@ public class DepositAccountData { this.tenureInMonths = null; this.projectedCommencementDate = null; this.actualCommencementDate = null; - this.projectedMaturityDate = null; - this.actualMaturityDate = null; + this.maturedOn = null; this.projectedInterestAccrued = null; this.actualInterestAccrued = null; this.projectedMaturityAmount = null; @@ -110,8 +108,7 @@ public class DepositAccountData { this.tenureInMonths = account.getTenureInMonths(); this.projectedCommencementDate = account.getProjectedCommencementDate(); this.actualCommencementDate = account.getActualCommencementDate(); - this.projectedMaturityDate = account.getProjectedMaturityDate(); - this.actualMaturityDate = account.getActualMaturityDate(); + this.maturedOn = account.getMaturedOn(); this.projectedInterestAccrued = account.getProjectedInterestAccrued(); this.actualInterestAccrued = account.getActualInterestAccrued(); this.projectedMaturityAmount = account.getProjectedMaturityAmount(); @@ -145,8 +142,7 @@ public class DepositAccountData { final Integer tenureInMonths, final LocalDate projectedCommencementDate, final LocalDate actualCommencementDate, - final LocalDate projectedMaturityDate, - final LocalDate actualMaturityDate, + final LocalDate maturedOn, final BigDecimal projectedInterestAccrued, final BigDecimal actualInterestAccrued, final BigDecimal projectedMaturityAmount, @@ -172,8 +168,7 @@ public class DepositAccountData { this.tenureInMonths = tenureInMonths; this.projectedCommencementDate = projectedCommencementDate; this.actualCommencementDate = actualCommencementDate; - this.projectedMaturityDate = projectedMaturityDate; - this.actualMaturityDate = actualMaturityDate; + this.maturedOn = maturedOn; this.projectedInterestAccrued = projectedInterestAccrued; this.actualInterestAccrued = actualInterestAccrued; this.projectedMaturityAmount = projectedMaturityAmount; @@ -220,8 +215,7 @@ public class DepositAccountData { this.tenureInMonths = tenureInMonths; this.projectedCommencementDate = null; this.actualCommencementDate = null; - this.projectedMaturityDate = null; - this.actualMaturityDate = null; + this.maturedOn = null; this.projectedInterestAccrued = null; this.actualInterestAccrued = null; this.projectedMaturityAmount = null; @@ -294,12 +288,8 @@ public class DepositAccountData { return actualCommencementDate; } - public LocalDate getProjectedMaturityDate() { - return projectedMaturityDate; - } - - public LocalDate getActualMaturityDate() { - return actualMaturityDate; + public LocalDate getMaturedOn() { + return maturedOn; } public BigDecimal getProjectedInterestAccrued() { diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java index 44fbcc2af..8342959fd 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/api/infrastructure/ApiDataConversionServiceImpl.java @@ -1016,7 +1016,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService { // preClosureInterestRate Set supportedParams = new HashSet( - Arrays.asList("clientId", "productId", "externalId", "depositAmount", "maturityInterestRate", + Arrays.asList("clientId", "productId", "externalId", "deposit", "maturityInterestRate", "tenureInMonths", "interestCompoundedEvery", "interestCompoundedEveryPeriodType", "commencementDate", "renewalAllowed", "preClosureAllowed", "locale", "dateFormat") @@ -1027,7 +1027,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService { Long clientId = extractLongParameter("clientId", requestMap, modifiedParameters); Long productId = extractLongParameter("productId", 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); Integer tenureInMonths = extractIntegerParameter("tenureInMonths", requestMap, modifiedParameters); @@ -1039,7 +1039,7 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService { boolean preClosureAllowed = extractBooleanParameter("preClosureAllowed", requestMap, modifiedParameters); return new DepositAccountCommand(modifiedParameters, resourceIdentifier, clientId, productId, - externalId, depositAmount, interestRate, tenureInMonths, + externalId, deposit, interestRate, tenureInMonths, interestCompoundedEvery, interestCompoundedEveryPeriodType, commencementDate, renewalAllowed, preClosureAllowed); } @@ -1122,19 +1122,19 @@ public class ApiDataConversionServiceImpl implements ApiDataConversionService { Type typeOfMap = new TypeToken>(){}.getType(); Map requestMap = gsonConverter.fromJson(json, typeOfMap); - Set supportedParams = new HashSet(Arrays.asList("locale","eventDate", "dateFormat", "tenureInMonths", "depositAmount", "interestCompoundedEveryPeriodType", "productId","interestCompoundedEvery")); + Set supportedParams = new HashSet(Arrays.asList("locale","commencementDate", "dateFormat", "tenureInMonths", "deposit", "interestCompoundedEveryPeriodType", "productId","interestCompoundedEvery")); checkForUnsupportedParameters(requestMap, supportedParams); Set modifiedParameters = new HashSet(); - LocalDate eventDate = extractLocalDateParameter("eventDate", requestMap, modifiedParameters); - BigDecimal depositAmount=extractBigDecimalParameter("depositAmount", requestMap, modifiedParameters); + LocalDate commencementDate = extractLocalDateParameter("commencementDate", requestMap, modifiedParameters); + BigDecimal deposit=extractBigDecimalParameter("deposit", requestMap, modifiedParameters); Integer tenureInMonths = extractIntegerParameter("tenureInMonths", requestMap, modifiedParameters); Integer interestCompoundedEveryPeriodType = extractIntegerParameter("interestCompoundedEveryPeriodType", requestMap, modifiedParameters); Integer interestCompoundedEvery = extractIntegerParameter("interestCompoundedEvery", 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); } } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java index 0d76da470..f45c916de 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/domain/DepositAccount.java @@ -76,13 +76,8 @@ public class DepositAccount extends AbstractAuditableCustom { @SuppressWarnings("unused") @Temporal(TemporalType.DATE) - @Column(name = "projected_maturity_date") - private Date projectedMaturityDate; - - @SuppressWarnings("unused") - @Temporal(TemporalType.DATE) - @Column(name = "actual_maturity_date") - private Date actualMaturityDate; + @Column(name = "matured_on") + private Date maturedOn; @SuppressWarnings("unused") @Column(name = "projected_interest_accrued_on_maturity", scale = 6, precision = 19, nullable = false) @@ -196,7 +191,7 @@ public class DepositAccount extends AbstractAuditableCustom { this.interestCompoundedFrequencyType = interestCompoundedFrequencyPeriodType.getValue(); if (commencementDate != null) { this.projectedCommencementDate = commencementDate.toDate(); - this.projectedMaturityDate = commencementDate.plusMonths(this.tenureInMonths).toDate(); + this.maturedOn = commencementDate.plusMonths(this.tenureInMonths).toDate(); } this.renewalAllowed = renewalAllowed; @@ -248,8 +243,7 @@ public class DepositAccount extends AbstractAuditableCustom { this.actualCommencementDate = actualCommencementDate.toDate(); // 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.actualMaturityDate = getActualCommencementDate().plusMonths(this.tenureInMonths).toDate(); + this.maturedOn = getActualCommencementDate().plusMonths(this.tenureInMonths).toDate(); Money futureValueOnMaturity = calculator.calculateInterestOnMaturityFor(getDeposit(), this.tenureInMonths, this.interestRate, this.interestCompoundedEvery, getInterestCompoundedFrequencyType()); @@ -257,7 +251,7 @@ public class DepositAccount extends AbstractAuditableCustom { this.interestAccrued = futureValueOnMaturity.minus(getDeposit()).getAmount(); this.total = futureValueOnMaturity.getAmount(); - DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(futureValueOnMaturity, getActualCommencementDate()); + DepositAccountTransaction depositaccountTransaction = DepositAccountTransaction.deposit(getDeposit(), getActualCommencementDate()); depositaccountTransaction.updateAccount(this); this.depositaccountTransactions.add(depositaccountTransaction); @@ -355,7 +349,7 @@ public class DepositAccount extends AbstractAuditableCustom { this.depositStatus = statusEnum.getValue(); this.actualCommencementDate = null; - this.actualMaturityDate = null; + this.maturedOn = getProjectedCommencementDate().plusMonths(this.tenureInMonths).toDate(); this.total=null; this.interestAccrued=null; this.depositaccountTransactions.clear(); diff --git a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountReadPlatformServiceImpl.java index d355c0fe1..d55774a56 100644 --- a/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosng/platform/saving/service/DepositAccountReadPlatformServiceImpl.java @@ -152,7 +152,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead + " da.currency_code as currencyCode, da.currency_digits as currencyDigits, " + " 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.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_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, " @@ -194,8 +194,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead LocalDate projectedCommencementDate = JdbcSupport.getLocalDate(rs, "projectedCommencementDate"); LocalDate actualCommencementDate = JdbcSupport.getLocalDate(rs, "actualCommencementDate"); - LocalDate projectedMaturityDate = JdbcSupport.getLocalDate(rs, "projectedMaturityDate"); - LocalDate actualMaturityDate = JdbcSupport.getLocalDate(rs, "actualMaturityDate"); + LocalDate maturedOn = JdbcSupport.getLocalDate(rs, "maturedOn"); BigDecimal projectedInterestAccrued = rs.getBigDecimal("projectedInterestAccrued"); BigDecimal actualInterestAccrued = rs.getBigDecimal("actualInterestAccrued"); @@ -216,7 +215,7 @@ public class DepositAccountReadPlatformServiceImpl implements DepositAccountRead LocalDate closedonDate = JdbcSupport.getLocalDate(rs, "closedonDate"); 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, interestCompoundedEvery, interestCompoundedEveryPeriodType, renewalAllowed, preClosureAllowed, preClosureInterestRate,