From 2e050d397f4be6d5707d17348d7bd65c8ece09ee Mon Sep 17 00:00:00 2001 From: Madhukar Date: Mon, 17 Dec 2012 11:54:00 +0530 Subject: [PATCH] Adding Saving account & product creation from UI Adding missing db patch for m_product_savings repopulating the existed values on view product --- ..._deposit_freq_col_for_m_saving_account.sql | 2 + ...dd_deposit_every_for_m_product_savings.sql | 2 + ...GsonPortfolioApiJsonSerializerService.java | 5 +- ...PortfolioApiDataConversionServiceImpl.java | 5 +- .../ClientAccountSummaryCollectionData.java | 33 +- .../ClientReadPlatformServiceImpl.java | 54 ++- .../api/SavingsAccountApiResource.java | 60 ++- .../data/SavingAccountData.java | 375 ++++++++++++++++-- .../savingsaccount/domain/SavingAccount.java | 20 +- .../service/SavingAccountAssembler.java | 11 +- .../SavingAccountReadPlatformService.java | 2 + .../SavingAccountReadPlatformServiceImpl.java | 55 ++- .../api/SavingProductsApiResource.java | 13 +- .../command/SavingProductCommand.java | 14 +- .../data/SavingProductData.java | 47 ++- .../data/SavingProductLookup.java | 15 +- .../domain/SavingProduct.java | 4 +- .../domain/SavingProductRelatedDetail.java | 16 +- .../service/SavingProductEnumerations.java | 2 +- .../SavingProductReadPlatformServiceImpl.java | 9 +- ...WritePlatformServiceJpaRepositoryImpl.java | 2 +- 21 files changed, 648 insertions(+), 98 deletions(-) create mode 100644 mifosng-db/patches/patch-10_add_deposit_freq_col_for_m_saving_account.sql create mode 100644 mifosng-db/patches/patch-15_add_deposit_every_for_m_product_savings.sql diff --git a/mifosng-db/patches/patch-10_add_deposit_freq_col_for_m_saving_account.sql b/mifosng-db/patches/patch-10_add_deposit_freq_col_for_m_saving_account.sql new file mode 100644 index 000000000..b9dfbb2d8 --- /dev/null +++ b/mifosng-db/patches/patch-10_add_deposit_freq_col_for_m_saving_account.sql @@ -0,0 +1,2 @@ +ALTER TABLE m_saving_account + ADD COLUMN `deposit_every` bigint(20) DEFAULT NULL AFTER `tenure_type`; \ No newline at end of file diff --git a/mifosng-db/patches/patch-15_add_deposit_every_for_m_product_savings.sql b/mifosng-db/patches/patch-15_add_deposit_every_for_m_product_savings.sql new file mode 100644 index 000000000..fa4bb714b --- /dev/null +++ b/mifosng-db/patches/patch-15_add_deposit_every_for_m_product_savings.sql @@ -0,0 +1,2 @@ +ALTER TABLE m_product_savings + ADD COLUMN `deposit_every` bigint(20) DEFAULT NULL AFTER `tenure_type`; \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonPortfolioApiJsonSerializerService.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonPortfolioApiJsonSerializerService.java index 9d199765f..da9554ceb 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonPortfolioApiJsonSerializerService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/GoogleGsonPortfolioApiJsonSerializerService.java @@ -43,7 +43,7 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi "createdOn", "lastModifedOn", "locale", "name", "description", "currencyCode", "digitsAfterDecimal", "interstRate", "minInterestRate", "maxInterestRate", "savingsDepositAmount", "savingProductType", "tenureType", "tenure", "frequency", "interestType", "interestCalculationMethod", "minimumBalanceForWithdrawal", "isPartialDepositAllowed", "isLockinPeriodAllowed", - "lockinPeriod", "lockinPeriodType", "currencyOptions", "savingsProductTypeOptions", "tenureTypeOptions", + "lockinPeriod", "lockinPeriodType", "currencyOptions", "savingsProductTypeOptions", "tenureTypeOptions","depositEvery", "savingFrequencyOptions", "savingsInterestTypeOptions", "lockinPeriodTypeOptions", "interestCalculationOptions")); private static final Set SAVINGS_DEPOSIT_PRODUCT_DATA_PARAMETERS = new HashSet(Arrays.asList("currencyOptions", @@ -96,7 +96,8 @@ public class GoogleGsonPortfolioApiJsonSerializerService implements PortfolioApi "interestCalculationMethod", "tenure", "tenureType", "projectedCommencementDate", "actualCommencementDate", "maturesOnDate", "projectedInterestAccuredOnMaturity", "actualInterestAccured", "projectedMaturityAmount", "actualMaturityAmount", "preClosureAllowed", "preClosureInterestRate", "withdrawnonDate", "rejectedonDate", "closedonDate", "isLockinPeriodAllowed", - "lockinPeriod", "lockinPeriodType")); + "lockinPeriod", "lockinPeriodType", "productOptions", "currencyOptions", "savingsProductTypeOptions", "tenureTypeOptions", + "savingFrequencyOptions", "savingsInterestTypeOptions", "lockinPeriodTypeOptions", "interestCalculationOptions")); // guarantors private static final Set GUARANTOR_DATA_PARAMETERS = new HashSet(Arrays.asList("externalGuarantor", "existingClientId", diff --git a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionServiceImpl.java index 3ee33aa4a..efd3d2c53 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/infrastructure/core/api/PortfolioApiDataConversionServiceImpl.java @@ -859,7 +859,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo Set supportedParams = new HashSet(Arrays.asList("locale", "name", "description", "currencyCode", "digitsAfterDecimal", "interestRate", "minInterestRate", "maxInterestRate", "savingsDepositAmount", "savingProductType", "tenureType", "tenure", "frequency", "interestType", "interestCalculationMethod", "minimumBalanceForWithdrawal", - "isPartialDepositAllowed", "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType")); + "isPartialDepositAllowed", "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType","depositEvery")); checkForUnsupportedParameters(requestMap, supportedParams); Set modifiedParameters = new HashSet(); @@ -871,6 +871,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo BigDecimal minInterestRate = extractBigDecimalParameter("minInterestRate", requestMap, modifiedParameters); BigDecimal maxInterestRate = extractBigDecimalParameter("maxInterestRate", requestMap, modifiedParameters); BigDecimal savingsDepositAmount = extractBigDecimalParameter("savingsDepositAmount", requestMap, modifiedParameters); + Integer depositEvery = extractIntegerParameter("depositEvery", requestMap, modifiedParameters); Integer savingProductType = extractIntegerParameter("savingProductType", requestMap, modifiedParameters); Integer tenureType = extractIntegerParameter("tenureType", requestMap, modifiedParameters); Integer tenure = extractIntegerParameter("tenure", requestMap, modifiedParameters); @@ -884,7 +885,7 @@ public class PortfolioApiDataConversionServiceImpl implements PortfolioApiDataCo Integer lockinPeriodType = extractIntegerParameter("lockinPeriodType", requestMap, modifiedParameters); return new SavingProductCommand(modifiedParameters, resourceIdentifier, name, description, currencyCode, digitsAfterDecimalValue, - interestRate, minInterestRate, maxInterestRate, savingsDepositAmount, savingProductType, tenureType, tenure, frequency, + interestRate, minInterestRate, maxInterestRate, savingsDepositAmount, depositEvery, savingProductType, tenureType, tenure, frequency, interestType, interestCalculationMethod, minimumBalanceForWithdrawal, isPartialDepositAllowed, isLockinPeriodAllowed, lockinPeriod, lockinPeriodType); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryCollectionData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryCollectionData.java index 88726dbd1..daa140f72 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryCollectionData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/data/ClientAccountSummaryCollectionData.java @@ -30,6 +30,16 @@ public class ClientAccountSummaryCollectionData { private final List preclosedDepositAccounts; private final int maturedDepositAccountsCount; private final List maturedDepositAccounts; + private final int pendingApprovalSavingAccountsCount; + private final List pendingApprovalSavingAccounts; + private final int approvedSavingAccountsCount; + private final List approvedSavingAccounts; + private final int withdrawnByClientSavingAccountsCount; + private final List withdrawnByClientSavingAccounts; + private final int rejectedSavingAccountsCount; + private final List rejectedSavingAccounts; + private final int closedSavingAccountsCount; + private final List closedSavingAccounts; public ClientAccountSummaryCollectionData( final List pendingApprovalLoans, @@ -42,7 +52,12 @@ public class ClientAccountSummaryCollectionData { final List rejectedDepositAccounts, final List closedDepositAccounts, final List preclosedDepositAccounts, - final List maturedDepositAccounts) { + final List maturedDepositAccounts, + final List pendingApprovalSavingAccounts, + final List approvedSavingAccounts, + final List withdrawnByClientSavingAccounts, + final List rejectedSavingAccounts, + final List closedSavingAccounts) { this.pendingApprovalLoans = pendingApprovalLoans; this.awaitingDisbursalLoans = awaitingDisbursalLoans; this.openLoans = openLoans; @@ -55,6 +70,13 @@ public class ClientAccountSummaryCollectionData { this.preclosedDepositAccounts = preclosedDepositAccounts; this.maturedDepositAccounts = maturedDepositAccounts; + // saving accounts + this.pendingApprovalSavingAccounts = pendingApprovalSavingAccounts; + this.approvedSavingAccounts = approvedSavingAccounts; + this.withdrawnByClientSavingAccounts = withdrawnByClientSavingAccounts; + this.rejectedSavingAccounts = rejectedSavingAccounts; + this.closedSavingAccounts = closedSavingAccounts; + this.pendingApprovalLoanCount = this.pendingApprovalLoans.size(); this.awaitingDisbursalLoanCount = this.awaitingDisbursalLoans.size(); this.activeLoanCount = this.openLoans.size(); @@ -67,10 +89,17 @@ public class ClientAccountSummaryCollectionData { this.rejectedDepositAccountsCount = this.rejectedDepositAccounts.size(); this.preclosedDepositAccountsCount = this.preclosedDepositAccounts.size(); this.maturedDepositAccountsCount = this.maturedDepositAccounts.size(); + this.pendingApprovalSavingAccountsCount = this.pendingApprovalSavingAccounts.size(); + this.approvedSavingAccountsCount = this.approvedSavingAccounts.size(); + this.withdrawnByClientSavingAccountsCount = this.withdrawnByClientSavingAccounts.size(); + this.rejectedSavingAccountsCount = this.rejectedSavingAccounts.size(); + this.closedSavingAccountsCount = this.closedSavingAccounts.size(); this.anyLoanCount = this.pendingApprovalLoanCount + this.awaitingDisbursalLoanCount + this.activeLoanCount + this.closedLoanCount +this.pendingApprovalDespositAccountsCount+this.approvedDespositAccountsCount+this.withdrawnByClientDespositAccountsCount+this.closedDepositAccountsCount - +this.rejectedDepositAccountsCount+this.preclosedDepositAccountsCount+this.maturedDepositAccountsCount; + +this.rejectedDepositAccountsCount+this.preclosedDepositAccountsCount+this.maturedDepositAccountsCount + +this.pendingApprovalSavingAccountsCount+this.approvedSavingAccountsCount+this.withdrawnByClientSavingAccountsCount + +this.rejectedSavingAccountsCount+this.closedSavingAccountsCount; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java index 747c99841..47b2ff6df 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/client/service/ClientReadPlatformServiceImpl.java @@ -248,10 +248,36 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService } } } + + List pendingApprovalSavingAccounts = new ArrayList(); + List approvedSavingAccounts = new ArrayList(); + List withdrawnByClientSavingAccounts = new ArrayList(); + List rejectedSavingAccounts = new ArrayList(); + List closedSavingAccounts = new ArrayList(); + + ClientSavingAccountSummaryDataMapper clientSavingAccountSummaryDataMapper = new ClientSavingAccountSummaryDataMapper(); + String savingAccountsSql = "select " + clientSavingAccountSummaryDataMapper.schema() + " where sa.client_id=? and sa.is_deleted=0"; + List savingAccountsResults = this.jdbcTemplate.query(savingAccountsSql, clientSavingAccountSummaryDataMapper, new Object[] {clientId}); + + if (savingAccountsResults != null) { + for (ClientAccountSummaryData account : savingAccountsResults){ + if (account.accountStatusId() == 100) + pendingApprovalSavingAccounts.add(account); + else if (account.accountStatusId() ==300) + approvedSavingAccounts.add(account); + else if (account.accountStatusId() == 400) + withdrawnByClientSavingAccounts.add(account); + else if (account.accountStatusId() == 500) + rejectedSavingAccounts.add(account); + else if (account.accountStatusId() == 600) + closedSavingAccounts.add(account); + } + } return new ClientAccountSummaryCollectionData(pendingApprovalLoans, awaitingDisbursalLoans, openLoans, closedLoans, pendingApprovalDepositAccounts, approvedDepositAccounts, withdrawnByClientDespositAccounts, rejectedDepositAccounts, - closedDepositAccounts, preclosedDepositAccounts, maturedDepositAccounts); + closedDepositAccounts, preclosedDepositAccounts, maturedDepositAccounts, + pendingApprovalSavingAccounts,approvedSavingAccounts,withdrawnByClientSavingAccounts,rejectedSavingAccounts,closedSavingAccounts); } catch (EmptyResultDataAccessException e) { throw new ClientNotFoundException(clientId); } @@ -516,4 +542,30 @@ public class ClientReadPlatformServiceImpl implements ClientReadPlatformService return ClientData.clientIdentifier(id, firstname, lastname, officeId, officeName); } } + + + private static final class ClientSavingAccountSummaryDataMapper implements RowMapper { + + public String schema() { + + StringBuilder accountsSummary = new StringBuilder("sa.id as id, sa.external_id as externalId,"); + accountsSummary.append("sa.product_id as productId, sp.name as productName,").append("sa.status_enum as statusId ") + .append("from m_saving_account sa ").append("LEFT JOIN m_product_savings AS sp ON sp.id = sa.product_id "); + + return accountsSummary.toString(); + } + + @Override + public ClientAccountSummaryData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException { + + Long id = JdbcSupport.getLong(rs, "id"); + String externalId = rs.getString("externalId"); + Long productId = JdbcSupport.getLong(rs, "productId"); + String productName = rs.getString("productName"); + Integer accountStatusId = JdbcSupport.getInteger(rs, "statusId"); + + return new ClientAccountSummaryData(id, externalId, productId, productName, accountStatusId); + } + } + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/api/SavingsAccountApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/api/SavingsAccountApiResource.java index 5cac746b1..ad4c64bbd 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/api/SavingsAccountApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/api/SavingsAccountApiResource.java @@ -3,6 +3,7 @@ package org.mifosplatform.portfolio.savingsaccount.api; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; +import java.util.List; import java.util.Set; import javax.ws.rs.Consumes; @@ -23,8 +24,11 @@ import org.mifosplatform.infrastructure.core.api.ApiParameterHelper; import org.mifosplatform.infrastructure.core.api.PortfolioApiDataConversionService; import org.mifosplatform.infrastructure.core.api.PortfolioApiJsonSerializerService; import org.mifosplatform.infrastructure.core.data.EntityIdentifier; +import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.infrastructure.core.serialization.ToApiJsonSerializer; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; +import org.mifosplatform.organisation.monetary.data.CurrencyData; +import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService; import org.mifosplatform.portfolio.savingsaccount.command.CalculateSavingScheduleCommand; import org.mifosplatform.portfolio.savingsaccount.command.SavingAccountCommand; import org.mifosplatform.portfolio.savingsaccount.data.SavingAccountData; @@ -32,6 +36,15 @@ import org.mifosplatform.portfolio.savingsaccount.data.SavingScheduleData; import org.mifosplatform.portfolio.savingsaccount.service.CalculateSavingSchedule; import org.mifosplatform.portfolio.savingsaccount.service.SavingAccountReadPlatformService; import org.mifosplatform.portfolio.savingsaccount.service.SavingAccountWritePlatformService; +import org.mifosplatform.portfolio.savingsaccountproduct.data.SavingProductLookup; +import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingFrequencyType; +import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingInterestCalculationMethod; +import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingProductType; +import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingsInterestType; +import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingsLockinPeriodEnum; +import org.mifosplatform.portfolio.savingsaccountproduct.service.SavingProductEnumerations; +import org.mifosplatform.portfolio.savingsaccountproduct.service.SavingProductReadPlatformService; +import org.mifosplatform.portfolio.savingsdepositproduct.domain.TenureTypeEnum; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -52,6 +65,12 @@ public class SavingsAccountApiResource { @Autowired private PortfolioApiJsonSerializerService apiJsonSerializerService; + + @Autowired + private SavingProductReadPlatformService savingProductReadPlatformService; + + @Autowired + private CurrencyReadPlatformService currencyReadPlatformService; private final String entityType = "SAVINGSACCOUNT"; @@ -152,7 +171,6 @@ public class SavingsAccountApiResource { return this.apiJsonSerializerService.serializeSavingAccountsDataToJson(prettyPrint, responseParameters, account); } - @SuppressWarnings("unused") @GET @Path("template") @Consumes({MediaType.APPLICATION_JSON}) @@ -170,13 +188,47 @@ public class SavingsAccountApiResource { } boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); - SavingAccountData account = null; -// this.savingAccountReadPlatformService.retrieveNewSavingsAccountDetails(clientId, productId); + SavingAccountData account = this.savingAccountReadPlatformService.retrieveNewSavingsAccountDetails(clientId, productId); + account = handleTemplateRelatedData(responseParameters,account); return this.apiJsonSerializerService.serializeSavingAccountsDataToJson(prettyPrint, responseParameters, account); } - private boolean is(final String commandParam, final String commandValue) { + private SavingAccountData handleTemplateRelatedData(Set responseParameters, SavingAccountData account) { + responseParameters.addAll(Arrays.asList("productOptions", "currencyOptions", "savingsProductTypeOptions", "tenureTypeOptions", + "savingFrequencyOptions", "savingsInterestTypeOptions", "lockinPeriodTypeOptions", "interestCalculationOptions")); + + Collection productOptions = savingProductReadPlatformService.retrieveAllSavingProductsForLookup(); + List currencyOptions = this.currencyReadPlatformService.retrieveAllowedCurrencies(); + + EnumOptionData reccuring = SavingProductEnumerations.savingProductType(SavingProductType.RECCURING); + EnumOptionData regular = SavingProductEnumerations.savingProductType(SavingProductType.REGULAR); + List savingsProductTypeOptions = Arrays.asList(reccuring, regular); + + EnumOptionData fixed = SavingProductEnumerations.tenureTypeEnum(TenureTypeEnum.FIXED_PERIOD); + EnumOptionData perpetual = SavingProductEnumerations.tenureTypeEnum(TenureTypeEnum.PERPETUAL); + List tenureTypeOptions = Arrays.asList(fixed, perpetual); + + EnumOptionData monthly = SavingProductEnumerations.interestFrequencyType(SavingFrequencyType.MONTHLY); + List savingFrequencyOptions = Arrays.asList(monthly); + + EnumOptionData simple = SavingProductEnumerations.savingInterestType(SavingsInterestType.SIMPLE); + EnumOptionData compounding = SavingProductEnumerations.savingInterestType(SavingsInterestType.COMPOUNDING); + List savingsInterestTypeOptions = Arrays.asList(simple, compounding); + + EnumOptionData months = SavingProductEnumerations.savingsLockinPeriod(SavingsLockinPeriodEnum.MONTHS); + List lockinPeriodTypeOptions = Arrays.asList(months); + + EnumOptionData averagebal = SavingProductEnumerations.savingInterestCalculationMethod(SavingInterestCalculationMethod.AVERAGEBAL); + EnumOptionData minbal = SavingProductEnumerations.savingInterestCalculationMethod(SavingInterestCalculationMethod.MINBAL); + EnumOptionData monthlyCollection = SavingProductEnumerations + .savingInterestCalculationMethod(SavingInterestCalculationMethod.MONTHLYCOLLECTION); + List interestCalculationOptions = Arrays.asList(averagebal, minbal, monthlyCollection); + return new SavingAccountData(account, productOptions, currencyOptions, savingsProductTypeOptions,tenureTypeOptions,savingFrequencyOptions, + savingsInterestTypeOptions,lockinPeriodTypeOptions,interestCalculationOptions); + } + + private boolean is(final String commandParam, final String commandValue) { return StringUtils.isNotBlank(commandParam) && commandParam.trim().equalsIgnoreCase(commandValue); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/data/SavingAccountData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/data/SavingAccountData.java index 85dcbc686..0506c2b68 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/data/SavingAccountData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/data/SavingAccountData.java @@ -1,82 +1,63 @@ package org.mifosplatform.portfolio.savingsaccount.data; import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import org.joda.time.LocalDate; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.organisation.monetary.data.CurrencyData; +import org.mifosplatform.portfolio.savingsaccountproduct.data.SavingProductLookup; /** * Immutable data object reprsenting a savings account. */ public class SavingAccountData { - @SuppressWarnings("unused") private final Long id; - @SuppressWarnings("unused") private final EnumOptionData status; - @SuppressWarnings("unused") private final String externalId; - @SuppressWarnings("unused") private final Long clientId; - @SuppressWarnings("unused") private final String clientName; - @SuppressWarnings("unused") private final Long productId; - @SuppressWarnings("unused") private final String productName; - @SuppressWarnings("unused") private final EnumOptionData productType; - @SuppressWarnings("unused") private final CurrencyData currencyData; - @SuppressWarnings("unused") private final BigDecimal savingsDepostiAmountPerPeriod; - @SuppressWarnings("unused") private final EnumOptionData savingsFrequencyType; - @SuppressWarnings("unused") private final BigDecimal totalDepositAmount; - @SuppressWarnings("unused") private final BigDecimal reccuringInterestRate; - @SuppressWarnings("unused") private final BigDecimal savingInterestRate; - @SuppressWarnings("unused") private final EnumOptionData interestType; - @SuppressWarnings("unused") private final EnumOptionData interestCalculationMethod; - @SuppressWarnings("unused") private final Integer tenure; - @SuppressWarnings("unused") private final EnumOptionData tenureType; - @SuppressWarnings("unused") private final LocalDate projectedCommencementDate; - @SuppressWarnings("unused") private final LocalDate actualCommencementDate; - @SuppressWarnings("unused") private final LocalDate maturesOnDate; - @SuppressWarnings("unused") private final BigDecimal projectedInterestAccuredOnMaturity; - @SuppressWarnings("unused") private final BigDecimal actualInterestAccured; - @SuppressWarnings("unused") private final BigDecimal projectedMaturityAmount; - @SuppressWarnings("unused") private final BigDecimal actualMaturityAmount; - @SuppressWarnings("unused") private final boolean preClosureAllowed; - @SuppressWarnings("unused") private final BigDecimal preClosureInterestRate; - @SuppressWarnings("unused") private final LocalDate withdrawnonDate; - @SuppressWarnings("unused") private final LocalDate rejectedonDate; - @SuppressWarnings("unused") private final LocalDate closedonDate; - @SuppressWarnings("unused") private final boolean isLockinPeriodAllowed; - @SuppressWarnings("unused") private final Integer lockinPeriod; - @SuppressWarnings("unused") private final EnumOptionData lockinPeriodType; + private final Integer depositEvery; + + private final List productOptions; + private final List currencyOptions; + private final List savingsProductTypeOptions; + private final List tenureTypeOptions; + private final List savingFrequencyOptions; + private final List savingsInterestTypeOptions; + private final List lockinPeriodTypeOptions; + private final List interestCalculationOptions; public SavingAccountData(Long id, EnumOptionData status, String externalId, Long clientId, String clientName, Long productId, String productName, EnumOptionData productType, CurrencyData currencyData, BigDecimal savingsDepostiAmountPerPeriod, @@ -86,7 +67,7 @@ public class SavingAccountData { BigDecimal projectedInterestAccuredOnMaturity, BigDecimal actualInterestAccured, BigDecimal projectedMaturityAmount, BigDecimal actualMaturityAmount, boolean preClosureAllowed, BigDecimal preClosureInterestRate, LocalDate withdrawnonDate, LocalDate rejectedonDate, LocalDate closedonDate, boolean isLockinPeriodAllowed, Integer lockinPeriod, - EnumOptionData lockinPeriodType) { + EnumOptionData lockinPeriodType,Integer depositEvery) { this.id = id; this.status = status; this.externalId = externalId; @@ -120,5 +101,331 @@ public class SavingAccountData { this.isLockinPeriodAllowed = isLockinPeriodAllowed; this.lockinPeriod = lockinPeriod; this.lockinPeriodType = lockinPeriodType; + this.depositEvery = depositEvery; + this.productOptions = new ArrayList(); + this.currencyOptions = null; + this.savingsProductTypeOptions = null; + this.tenureTypeOptions = null; + this.savingFrequencyOptions = null; + this.savingsInterestTypeOptions = null; + this.lockinPeriodTypeOptions = null; + this.interestCalculationOptions = null; + } + + public SavingAccountData(Long clientId, String clientName) { + this.id = null; + this.status = null; + this.externalId = null; + this.clientId = clientId; + this.clientName = clientName; + this.productId = null; + this.productName = null; + this.productType = null; + this.currencyData = new CurrencyData("USD", "US Dollar", 2, "$", "currency.USD");; + this.savingsDepostiAmountPerPeriod = null; + this.savingsFrequencyType = null; + this.totalDepositAmount = null; + this.reccuringInterestRate = null; + this.savingInterestRate = null; + this.interestType = null; + this.interestCalculationMethod = null; + this.tenure = null; + this.tenureType = null; + this.projectedCommencementDate = null; + this.actualCommencementDate = null; + this.maturesOnDate = null; + this.projectedInterestAccuredOnMaturity = null; + this.actualInterestAccured = null; + this.projectedMaturityAmount = null; + this.actualMaturityAmount = null; + this.preClosureAllowed = false; + this.preClosureInterestRate = null; + this.withdrawnonDate = null; + this.rejectedonDate = null; + this.closedonDate = null; + this.isLockinPeriodAllowed = false; + this.lockinPeriod = null; + this.lockinPeriodType = null; + this.depositEvery=null; + this.productOptions = new ArrayList(); + this.currencyOptions = null; + this.savingsProductTypeOptions = null; + this.tenureTypeOptions = null; + this.savingFrequencyOptions = null; + this.savingsInterestTypeOptions = null; + this.lockinPeriodTypeOptions = null; + this.interestCalculationOptions = null; + } + + public SavingAccountData(SavingAccountData account, Collection productOptions, List currencyOptions, + List savingsProductTypeOptions, List tenureTypeOptions, List savingFrequencyOptions, + List savingsInterestTypeOptions, List lockinPeriodTypeOptions, List interestCalculationOptions) { + this.id = account.getId(); + this.status = account.getStatus(); + this.externalId = account.getExternalId(); + this.clientId = account.getClientId(); + this.clientName = account.getClientName(); + this.productId = account.getProductId(); + this.productName = account.getProductName(); + this.productType = account.getProductType(); + this.currencyData = account.getCurrencyData(); + this.savingsDepostiAmountPerPeriod = account.getSavingsDepostiAmountPerPeriod(); + this.savingsFrequencyType = account.getSavingsFrequencyType(); + this.totalDepositAmount = account.getTotalDepositAmount(); + this.reccuringInterestRate = account.getReccuringInterestRate(); + this.savingInterestRate = account.getSavingInterestRate(); + this.interestType = account.getInterestType(); + this.interestCalculationMethod = account.getInterestCalculationMethod(); + this.tenure = account.getTenure(); + this.tenureType = account.getTenureType(); + this.projectedCommencementDate = account.getProjectedCommencementDate(); + this.actualCommencementDate = account.getActualCommencementDate(); + this.maturesOnDate = account.getMaturesOnDate(); + this.projectedInterestAccuredOnMaturity = account.getProjectedInterestAccuredOnMaturity(); + this.actualInterestAccured = account.getActualInterestAccured(); + this.projectedMaturityAmount = account.getProjectedMaturityAmount(); + this.actualMaturityAmount = account.getActualMaturityAmount(); + this.preClosureAllowed = account.isPreClosureAllowed(); + this.preClosureInterestRate = account.getPreClosureInterestRate(); + this.withdrawnonDate = account.getWithdrawnonDate(); + this.rejectedonDate = account.getRejectedonDate(); + this.closedonDate = account.getClosedonDate(); + this.isLockinPeriodAllowed = account.isLockinPeriodAllowed(); + this.lockinPeriod = account.getLockinPeriod(); + this.lockinPeriodType = account.getLockinPeriodType(); + this.depositEvery = account.getDepositEvery(); + + this.productOptions = (List) productOptions; + this.currencyOptions = currencyOptions; + this.savingsProductTypeOptions = savingsProductTypeOptions; + this.tenureTypeOptions = tenureTypeOptions; + this.savingFrequencyOptions = savingFrequencyOptions; + this.savingsInterestTypeOptions = savingsInterestTypeOptions; + this.lockinPeriodTypeOptions = lockinPeriodTypeOptions; + this.interestCalculationOptions = interestCalculationOptions; + } + + public SavingAccountData( Long clientId, String clientName, Long productId, String productName, CurrencyData currency, BigDecimal interestRate, + BigDecimal savingsDepostiAmountPerPeriod, EnumOptionData productType, EnumOptionData tenureType, Integer tenure, EnumOptionData savingsFrequencyType, + EnumOptionData interestType, EnumOptionData interestCalculationMethod, BigDecimal minimumBalanceForWithdrawal, boolean partialDepositAllowed, + boolean lockinPeriodAllowed, Integer lockinPeriod, EnumOptionData lockinPeriodType, Integer depositEvery) { + + this.id = null; + this.status = null; + this.externalId = null; + this.clientId = clientId; + this.clientName = clientName; + this.productId = productId; + this.productName = productName; + this.productType = productType; + this.currencyData = currency; + this.savingsDepostiAmountPerPeriod = savingsDepostiAmountPerPeriod; + this.savingsFrequencyType = savingsFrequencyType; + this.totalDepositAmount = null; + this.reccuringInterestRate = interestRate; + this.savingInterestRate = interestRate; + this.interestType = interestType; + this.interestCalculationMethod = interestCalculationMethod; + this.tenure = tenure; + this.tenureType = tenureType; + this.projectedCommencementDate = new LocalDate(); + this.actualCommencementDate = null; + this.maturesOnDate = null; + this.projectedInterestAccuredOnMaturity = null; + this.actualInterestAccured = null; + this.projectedMaturityAmount = null; + this.actualMaturityAmount = null; + this.preClosureAllowed = true; + this.preClosureInterestRate = null; + this.withdrawnonDate = null; + this.rejectedonDate = null; + this.closedonDate = null; + this.isLockinPeriodAllowed = false; + this.lockinPeriod = lockinPeriod; + this.lockinPeriodType = lockinPeriodType; + this.depositEvery=depositEvery; + this.productOptions = null; + this.currencyOptions = null; + this.savingsProductTypeOptions = null; + this.tenureTypeOptions = null; + this.savingFrequencyOptions = null; + this.savingsInterestTypeOptions = null; + this.lockinPeriodTypeOptions = null; + this.interestCalculationOptions = null; + + } + + public static SavingAccountData createFrom(final Long clientId, final String clientDisplayName) { + return new SavingAccountData(clientId,clientDisplayName); + } + + public Long getId() { + return this.id; + } + + public EnumOptionData getStatus() { + return this.status; + } + + public String getExternalId() { + return this.externalId; + } + + public Long getClientId() { + return this.clientId; + } + + public String getClientName() { + return this.clientName; + } + + public Long getProductId() { + return this.productId; + } + + public String getProductName() { + return this.productName; + } + + public EnumOptionData getProductType() { + return this.productType; + } + + public CurrencyData getCurrencyData() { + return this.currencyData; + } + + public BigDecimal getSavingsDepostiAmountPerPeriod() { + return this.savingsDepostiAmountPerPeriod; + } + + public EnumOptionData getSavingsFrequencyType() { + return this.savingsFrequencyType; + } + + public BigDecimal getTotalDepositAmount() { + return this.totalDepositAmount; + } + + public BigDecimal getReccuringInterestRate() { + return this.reccuringInterestRate; + } + + public BigDecimal getSavingInterestRate() { + return this.savingInterestRate; + } + + public EnumOptionData getInterestType() { + return this.interestType; + } + + public EnumOptionData getInterestCalculationMethod() { + return this.interestCalculationMethod; + } + + public Integer getTenure() { + return this.tenure; + } + + public EnumOptionData getTenureType() { + return this.tenureType; + } + + public LocalDate getProjectedCommencementDate() { + return this.projectedCommencementDate; + } + + public LocalDate getActualCommencementDate() { + return this.actualCommencementDate; + } + + public LocalDate getMaturesOnDate() { + return this.maturesOnDate; + } + + public BigDecimal getProjectedInterestAccuredOnMaturity() { + return this.projectedInterestAccuredOnMaturity; + } + + public BigDecimal getActualInterestAccured() { + return this.actualInterestAccured; + } + + public BigDecimal getProjectedMaturityAmount() { + return this.projectedMaturityAmount; + } + + public BigDecimal getActualMaturityAmount() { + return this.actualMaturityAmount; + } + + public boolean isPreClosureAllowed() { + return this.preClosureAllowed; + } + + public BigDecimal getPreClosureInterestRate() { + return this.preClosureInterestRate; + } + + public LocalDate getWithdrawnonDate() { + return this.withdrawnonDate; + } + + public LocalDate getRejectedonDate() { + return this.rejectedonDate; + } + + public LocalDate getClosedonDate() { + return this.closedonDate; + } + + public boolean isLockinPeriodAllowed() { + return this.isLockinPeriodAllowed; + } + + public Integer getLockinPeriod() { + return this.lockinPeriod; + } + + public EnumOptionData getLockinPeriodType() { + return this.lockinPeriodType; + } + + public Integer getDepositEvery() { + return this.depositEvery; + } + + public List getProductOptions() { + return this.productOptions; + } + + public List getCurrencyOptions() { + return this.currencyOptions; + } + + public List getSavingsProductTypeOptions() { + return this.savingsProductTypeOptions; + } + + public List getTenureTypeOptions() { + return this.tenureTypeOptions; + } + + public List getSavingFrequencyOptions() { + return this.savingFrequencyOptions; + } + + public List getSavingsInterestTypeOptions() { + return this.savingsInterestTypeOptions; + } + + public List getLockinPeriodTypeOptions() { + return this.lockinPeriodTypeOptions; + } + + public List getInterestCalculationOptions() { + return this.interestCalculationOptions; + } + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/domain/SavingAccount.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/domain/SavingAccount.java index ab02bf834..60c1cbe74 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/domain/SavingAccount.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/domain/SavingAccount.java @@ -158,6 +158,9 @@ public class SavingAccount extends AbstractAuditableCustom { @Column(name = "lock_in_period_type", nullable = false) private PeriodFrequencyType lockinPeriodType; + + @Column(name = "deposit_every", nullable = false) + private Integer payEvery; // see // http://stackoverflow.com/questions/4334970/hibernate-cannot-simultaneously-fetch-multiple-bags @@ -170,7 +173,8 @@ public class SavingAccount extends AbstractAuditableCustom { TenureTypeEnum tenureTypeEnum, SavingProductType savingProductType, SavingFrequencyType savingFrequencyType, SavingsInterestType interestType, SavingInterestCalculationMethod savingInterestCalculationMethod, boolean isLockinPeriodAllowed, Integer lockinPeriod, PeriodFrequencyType lockinPeriodType, - ReccuringDepositInterestCalculator reccuringDepositInterestCalculator, final DepositLifecycleStateMachine lifecycleStateMachine) { + ReccuringDepositInterestCalculator reccuringDepositInterestCalculator, final DepositLifecycleStateMachine lifecycleStateMachine, + Integer payEvery) { Money futureValueOnMaturity = null; if (savingProductType.isReccuring()) { @@ -183,14 +187,14 @@ public class SavingAccount extends AbstractAuditableCustom { return new SavingAccount(client, externalId, product, savingsDeposit, reccuringInterestRate, savingInterestRate, tenure, commencementDate, tenureTypeEnum, savingProductType, savingFrequencyType, interestType, savingInterestCalculationMethod, - isLockinPeriodAllowed, lockinPeriod, lockinPeriodType, futureValueOnMaturity, lifecycleStateMachine); + isLockinPeriodAllowed, lockinPeriod, lockinPeriodType, futureValueOnMaturity, lifecycleStateMachine,payEvery); } public SavingAccount(Client client, String externalId, SavingProduct product, Money savingsDeposit, BigDecimal reccuringInterestRate, BigDecimal savingInterestRate, Integer tenure, LocalDate commencementDate, TenureTypeEnum tenureTypeEnum, SavingProductType savingProductType, SavingFrequencyType savingFrequencyType, SavingsInterestType interestType, SavingInterestCalculationMethod savingInterestCalculationMethod, boolean isLockinPeriodAllowed, Integer lockinPeriod, - PeriodFrequencyType lockinPeriodType, Money futureValueOnMaturity, final DepositLifecycleStateMachine lifecycleStateMachine) { + PeriodFrequencyType lockinPeriodType, Money futureValueOnMaturity, final DepositLifecycleStateMachine lifecycleStateMachine,Integer payEvery) { DepositAccountStatus from = null; if (accountStatus != null) { @@ -225,13 +229,14 @@ public class SavingAccount extends AbstractAuditableCustom { this.projectedTotalOnMaturity = futureValueOnMaturity.getAmount(); this.projectedInterestAccruedOnMaturity = futureValueOnMaturity.getAmount().subtract( BigDecimal.valueOf(savingsDeposit.getAmount().doubleValue() * tenure.doubleValue())); + this.payEvery = payEvery; } public void modifyAccount(SavingProduct product, String externalId, Money savingsDeposit, BigDecimal reccuringInterestRate, BigDecimal savingInterestRate, Integer tenure, LocalDate commencementDate, TenureTypeEnum tenureTypeEnum, SavingProductType savingProductType, SavingFrequencyType savingFrequencyType, SavingInterestCalculationMethod savingInterestCalculationMethod, boolean isLockinPeriodAllowed, Integer lockinPeriod, - PeriodFrequencyType lockinPeriodType, ReccuringDepositInterestCalculator reccuringDepositInterestCalculator) { + PeriodFrequencyType lockinPeriodType, ReccuringDepositInterestCalculator reccuringDepositInterestCalculator,Integer payEvery) { Money futureValueOnMaturity = null; if (savingProductType.isReccuring()) { @@ -256,6 +261,7 @@ public class SavingAccount extends AbstractAuditableCustom { this.isLockinPeriodAllowed = isLockinPeriodAllowed; this.lockinPeriod = lockinPeriod; this.lockinPeriodType = lockinPeriodType; + this.payEvery = payEvery; // FIXME - MADHUKAR - futureValueOnMaturity is possibly null this.projectedTotalOnMaturity = futureValueOnMaturity.getAmount(); @@ -347,7 +353,11 @@ public class SavingAccount extends AbstractAuditableCustom { return lockinPeriodType; } - public void addSavingScheduleInstallment(final SavingScheduleInstallments installment) { + public Integer getPayEvery() { + return this.payEvery; + } + + public void addSavingScheduleInstallment(final SavingScheduleInstallments installment) { installment.updateAccount(this); this.savingScheduleInstallments.add(installment); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountAssembler.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountAssembler.java index 5b8ac2c38..50aeb2532 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountAssembler.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountAssembler.java @@ -114,11 +114,13 @@ public class SavingAccountAssembler { if (command.getLockinPeriodType() != null) { lockinPeriodType = PeriodFrequencyType.fromInt(command.getLockinPeriodType()); } + + Integer payEvery = command.getPayEvery(); SavingAccount account = SavingAccount.openNew(client, product, command.getExternalId(), savingsDeposit, reccuringInterestRate, savingInterestRate, tenure, command.getCommencementDate(), tenureTypeEnum, savingProductType, savingFrequencyType, interestType, savingInterestCalculationMethod, isLockinPeriodAllowed, lockinPeriod, lockinPeriodType, - this.reccuringDepositInterestCalculator, defaultDepositLifecycleStateMachine()); + this.reccuringDepositInterestCalculator, defaultDepositLifecycleStateMachine(),payEvery); SavingScheduleData savingScheduleData = this.calculateSavingSchedule.calculateSavingSchedule(command .toCalculateSavingScheduleCommand()); @@ -205,9 +207,14 @@ public class SavingAccountAssembler { if (command.isLockinPeriodTypeChanged()) { lockinPeriodType = PeriodFrequencyType.fromInt(command.getLockinPeriodType()); } + + Integer payEvery = account.getPayEvery(); + if(command.isPayEveryChanged()){ + payEvery = command.getPayEvery(); + } account.modifyAccount(product, externalId, savingsDeposit, reccuringInterestRate, savingInterestRate, tenure, commencementDate, tenureTypeEnum, savingProductType, savingFrequencyType, savingInterestCalculationMethod, isLockinPeriodAllowed, - lockinPeriod, lockinPeriodType, this.reccuringDepositInterestCalculator); + lockinPeriod, lockinPeriodType, this.reccuringDepositInterestCalculator,payEvery); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountReadPlatformService.java index 06ae7dd0b..951f9a3a2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountReadPlatformService.java @@ -9,4 +9,6 @@ public interface SavingAccountReadPlatformService { Collection retrieveAllSavingsAccounts(); SavingAccountData retrieveSavingsAccount(Long accountId); + + SavingAccountData retrieveNewSavingsAccountDetails(Long clientId, Long productId); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountReadPlatformServiceImpl.java index ff294a036..2903a6124 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccount/service/SavingAccountReadPlatformServiceImpl.java @@ -11,8 +11,13 @@ import org.mifosplatform.infrastructure.core.domain.JdbcSupport; import org.mifosplatform.infrastructure.core.service.TenantAwareRoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.organisation.monetary.data.CurrencyData; +import org.mifosplatform.portfolio.client.data.ClientData; +import org.mifosplatform.portfolio.client.service.ClientReadPlatformService; import org.mifosplatform.portfolio.savingsaccount.data.SavingAccountData; +import org.mifosplatform.portfolio.savingsaccountproduct.data.SavingProductData; +import org.mifosplatform.portfolio.savingsaccountproduct.data.SavingProductLookup; import org.mifosplatform.portfolio.savingsaccountproduct.service.SavingProductEnumerations; +import org.mifosplatform.portfolio.savingsaccountproduct.service.SavingProductReadPlatformService; import org.mifosplatform.portfolio.savingsdepositaccount.service.DepositAccountEnumerations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.jdbc.core.JdbcTemplate; @@ -24,11 +29,16 @@ public class SavingAccountReadPlatformServiceImpl implements SavingAccountReadPl private final PlatformSecurityContext context; private final JdbcTemplate jdbcTemplate; + private final ClientReadPlatformService clientReadPlatformService; + private final SavingProductReadPlatformService savingProductReadPlatformService; @Autowired - public SavingAccountReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource) { + public SavingAccountReadPlatformServiceImpl(final PlatformSecurityContext context, final TenantAwareRoutingDataSource dataSource, + ClientReadPlatformService clientReadPlatformService, SavingProductReadPlatformService savingProductReadPlatformService) { this.context = context; this.jdbcTemplate = new JdbcTemplate(dataSource); + this.clientReadPlatformService = clientReadPlatformService; + this.savingProductReadPlatformService=savingProductReadPlatformService; } @Override @@ -66,7 +76,7 @@ public class SavingAccountReadPlatformServiceImpl implements SavingAccountReadPl + " sa.actual_total_amount AS actualTotalAmount, sa.is_preclosure_allowed AS isPreclosureAllowed," + " sa.pre_closure_interest_rate AS preClosureInterestRate, sa.is_lock_in_period_allowed AS isLockinPeriodAllowed," + " sa.lock_in_period AS lockinPeriod, sa.lock_in_period_type AS lockinPeriodType, sa.withdrawnon_date AS withdrawnonDate," - + " sa.rejectedon_date AS rejectedonDate, sa.closedon_date AS closedonDate, ps.name AS productName," + + " sa.rejectedon_date AS rejectedonDate, sa.closedon_date AS closedonDate, ps.name AS productName, sa.deposit_every as depositEvery, " + " c.firstname AS firstname, c.lastname AS lastname, curr.name AS currencyName, " + " curr.internationalized_name_code AS currencyNameCode, curr.display_symbol AS currencyDisplaySymbol " + " FROM m_saving_account sa " + " JOIN m_client c ON c.id = sa.client_id" @@ -130,13 +140,52 @@ public class SavingAccountReadPlatformServiceImpl implements SavingAccountReadPl Integer lockinPeriod = JdbcSupport.getInteger(rs, "lockinPeriod"); Integer lockinPeriodTypeValue = JdbcSupport.getInteger(rs, "lockinPeriodType"); EnumOptionData lockinPeriodType = SavingProductEnumerations.savingsLockinPeriod(lockinPeriodTypeValue); + Integer depositEvery = JdbcSupport.getInteger(rs, "depositEvery"); return new SavingAccountData(id, status, externalId, clientId, clientName, productId, productName, productType, currencyData, savingsDepostiAmountPerPeriod, savingsFrequencyType, totalDepositAmount, reccuringInterestRate, savingInterestRate, interestType, interestCalculationMethod, tenure, tenureType, projectedCommencementDate, actualCommencementDate, maturesOnDate, projectedInterestAccuredOnMaturity, actualInterestAccured, projectedMaturityAmount, actualMaturityAmount, preClosureAllowed, preClosureInterestRate, withdrawnonDate, rejectedonDate, closedonDate, - isLockinPeriodAllowed, lockinPeriod, lockinPeriodType); + isLockinPeriodAllowed, lockinPeriod, lockinPeriodType,depositEvery); } } + + @Override + public SavingAccountData retrieveNewSavingsAccountDetails(Long clientId, Long productId) { + + context.authenticatedUser(); + ClientData clientAccount = this.clientReadPlatformService.retrieveIndividualClient(clientId); + SavingAccountData accountData = null; + Collection savingProducts = this.savingProductReadPlatformService.retrieveAllSavingProductsForLookup(); + + if (productId != null && productId != -1) { + SavingProductData selectedProduct = findSavingProductById(savingProducts, productId); + + CurrencyData currency = selectedProduct.getCurrency(); + + accountData = new SavingAccountData(clientAccount.id(), clientAccount.displayName(), selectedProduct.getId(), + selectedProduct.getName(), currency, selectedProduct.getInterestRate(), selectedProduct.getSavingsDepositAmount(), + selectedProduct.getSavingProductType(), selectedProduct.getTenureType(), selectedProduct.getTenure(), selectedProduct.getSavingFrequencyType(), + selectedProduct.getInterestType(), selectedProduct.getInterestCalculationMethod(),selectedProduct.getMinimumBalanceForWithdrawal(), + selectedProduct.isPartialDepositAllowed(), selectedProduct.isLockinPeriodAllowed(),selectedProduct.getLockinPeriod(), + selectedProduct.getLockinPeriodType(),selectedProduct.getDepositEvery()); + + } else { + accountData = SavingAccountData.createFrom(clientAccount.id(), clientAccount.displayName()); + } + return accountData; + } + + private SavingProductData findSavingProductById( Collection savingProducts, Long productId) { + SavingProductData match = this.savingProductReadPlatformService.retrieveNewSavingProductDetails(); + for (SavingProductLookup savingProductLookup : savingProducts) { + if (savingProductLookup.hasId(productId)) { + match = this.savingProductReadPlatformService.retrieveSavingProduct(savingProductLookup.getId()); + break; + } + } + return match; + } + } \ No newline at end of file diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/api/SavingProductsApiResource.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/api/SavingProductsApiResource.java index 055a2b3a7..ef099b29d 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/api/SavingProductsApiResource.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/api/SavingProductsApiResource.java @@ -100,7 +100,7 @@ public class SavingProductsApiResource { "description", "currencyCode", "digitsAfterDecimal", "interstRate", "minInterestRate", "maxInterestRate", "savingsDepositAmount", "savingProductType", "tenureType", "tenure", "frequency", "interestType", "interestCalculationMethod", "minimumBalanceForWithdrawal", "isPartialDepositAllowed", "isLockinPeriodAllowed", - "lockinPeriod", "lockinPeriodType")); + "lockinPeriod", "lockinPeriodType","depositEvery")); Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); if (responseParameters.isEmpty()) { @@ -125,20 +125,21 @@ public class SavingProductsApiResource { "description", "currencyCode", "digitsAfterDecimal", "interstRate", "minInterestRate", "maxInterestRate", "savingsDepositAmount", "savingProductType", "tenureType", "tenure", "frequency", "interestType", "interestCalculationMethod", "minimumBalanceForWithdrawal", "isPartialDepositAllowed", "isLockinPeriodAllowed", - "lockinPeriod", "lockinPeriodType")); + "lockinPeriod", "lockinPeriodType","depositEvery")); Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); if (responseParameters.isEmpty()) { responseParameters.addAll(typicalResponseParameters); } + + SavingProductData savingProduct = this.savingProductReadPlatformService.retrieveSavingProduct(productId); + boolean prettyPrint = ApiParameterHelper.prettyPrint(uriInfo.getQueryParameters()); boolean template = ApiParameterHelper.template(uriInfo.getQueryParameters()); if (template) { - responseParameters.addAll(Arrays.asList("currencyOptions")); + savingProduct = handleTemplateRelatedData(responseParameters, savingProduct); } - SavingProductData savingProduct = this.savingProductReadPlatformService.retrieveSavingProduct(productId); - return this.apiJsonSerializerService.serializeSavingProductDataToJson(prettyPrint, responseParameters, savingProduct); } @@ -153,7 +154,7 @@ public class SavingProductsApiResource { Set typicalResponseParameters = new HashSet(Arrays.asList("id", "createdOn", "lastModifedOn", "locale", "name", "description", "currencyCode", "digitsAfterDecimal", "interstRate", "savingsDepositAmount", "savingProductType", "tenureType", "tenure", "frequency", "interestType", "interestCalculationMethod", "minimumBalanceForWithdrawal", - "isPartialDepositAllowed", "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType", "currencyOptions")); + "isPartialDepositAllowed", "isLockinPeriodAllowed", "lockinPeriod", "lockinPeriodType", "currencyOptions","depositEvery")); Set responseParameters = ApiParameterHelper.extractFieldsForResponseIfProvided(uriInfo.getQueryParameters()); if (responseParameters.isEmpty()) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/command/SavingProductCommand.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/command/SavingProductCommand.java index 088189939..dbbbf14ff 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/command/SavingProductCommand.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/command/SavingProductCommand.java @@ -16,6 +16,7 @@ public class SavingProductCommand { private final BigDecimal maxInterestRate; private final BigDecimal savingsDepositAmount; + private final Integer depositEvery; private final Integer savingProductType; private final Integer tenureType; private final Integer tenure; @@ -32,7 +33,7 @@ public class SavingProductCommand { public SavingProductCommand(Set modifiedParameters, Long id, String name, String description, String currencyCode, Integer digitsAfterDecimal, BigDecimal interestRate, BigDecimal minInterestRate, BigDecimal maxInterestRate, - BigDecimal savingsDepositAmount, Integer savingProductType, Integer tenureType, Integer tenure, Integer frequency, + BigDecimal savingsDepositAmount, Integer depositEvery,Integer savingProductType, Integer tenureType, Integer tenure, Integer frequency, Integer interestType, Integer interestCalculationMethod, BigDecimal minimumBalanceForWithdrawal, boolean isPartialDepositAllowed, boolean isLockinPeriodAllowed, Integer lockinPeriod, Integer lockinPeriodType) { @@ -47,6 +48,7 @@ public class SavingProductCommand { this.maxInterestRate = maxInterestRate; this.savingsDepositAmount = savingsDepositAmount; + this.depositEvery = depositEvery; this.savingProductType = savingProductType; this.tenureType = tenureType; this.tenure = tenure; @@ -98,7 +100,11 @@ public class SavingProductCommand { return savingsDepositAmount; } - public Integer getSavingProductType() { + public Integer getDepositEvery() { + return this.depositEvery; + } + + public Integer getSavingProductType() { return savingProductType; } @@ -166,6 +172,10 @@ public class SavingProductCommand { return this.modifiedParameters.contains("savingsDepositAmount"); } + public boolean isDepositEveryChanged() { + return this.modifiedParameters.contains("depositEvery"); + } + public boolean isSavingProductTypeChanged() { return this.modifiedParameters.contains("savingProductType"); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/data/SavingProductData.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/data/SavingProductData.java index e5174dff4..26a6eebc8 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/data/SavingProductData.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/data/SavingProductData.java @@ -8,6 +8,13 @@ import java.util.List; import org.joda.time.DateTime; import org.mifosplatform.infrastructure.core.data.EnumOptionData; import org.mifosplatform.organisation.monetary.data.CurrencyData; +import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingFrequencyType; +import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingInterestCalculationMethod; +import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingProductType; +import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingsInterestType; +import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingsLockinPeriodEnum; +import org.mifosplatform.portfolio.savingsaccountproduct.service.SavingProductEnumerations; +import org.mifosplatform.portfolio.savingsdepositproduct.domain.TenureTypeEnum; public class SavingProductData implements Serializable { @@ -35,6 +42,7 @@ public class SavingProductData implements Serializable { private DateTime createdOn; private DateTime lastModifedOn; + private final Integer depositEvery; private List currencyOptions = new ArrayList(); List savingsProductTypeOptions = new ArrayList(); @@ -45,7 +53,7 @@ public class SavingProductData implements Serializable { List interestCalculationOptions = new ArrayList(); public SavingProductData() { - this.createdOn = new DateTime(); + this.createdOn = new DateTime(); this.lastModifedOn = new DateTime(); this.id = null; this.name = null; @@ -53,20 +61,21 @@ public class SavingProductData implements Serializable { this.interestRate = BigDecimal.ZERO; this.minInterestRate = BigDecimal.ZERO; this.maxInterestRate = BigDecimal.ZERO; - this.currency = null; - this.digitsAfterDecimal = null; - this.savingsDepositAmount = null; - this.savingProductType = null; - this.tenureType = null; - this.tenure = null; - this.savingFrequencyType = null; - this.interestType = null; - this.interestCalculationMethod = null; - this.minimumBalanceForWithdrawal = null; - this.isPartialDepositAllowed = true; - this.isLockinPeriodAllowed = true; - this.lockinPeriod = null; - this.lockinPeriodType = null; + this.currency = new CurrencyData("USD", "US Dollar", 2, "$", "currency.USD"); + this.digitsAfterDecimal = Integer.valueOf(2); + this.savingsDepositAmount = BigDecimal.ZERO; + this.savingProductType = SavingProductEnumerations.savingProductType(SavingProductType.RECCURING); + this.tenureType = SavingProductEnumerations.tenureTypeEnum(TenureTypeEnum.FIXED_PERIOD); + this.tenure = Integer.valueOf(12); + this.savingFrequencyType = SavingProductEnumerations.interestFrequencyType(SavingFrequencyType.MONTHLY); + this.interestType = SavingProductEnumerations.savingInterestType(SavingsInterestType.COMPOUNDING); + this.interestCalculationMethod = SavingProductEnumerations.savingInterestCalculationMethod(SavingInterestCalculationMethod.AVERAGEBAL); + this.minimumBalanceForWithdrawal = BigDecimal.valueOf(100); + this.isPartialDepositAllowed = false; + this.isLockinPeriodAllowed = false; + this.lockinPeriod = Integer.valueOf(0); + this.lockinPeriodType = SavingProductEnumerations.savingsLockinPeriod(SavingsLockinPeriodEnum.MONTHS); + this.depositEvery=Integer.valueOf(3); } public SavingProductData(DateTime createdOn, DateTime lastModifedOn, Long id, String name, String description, BigDecimal interestRate, @@ -74,7 +83,7 @@ public class SavingProductData implements Serializable { BigDecimal savingsDepositAmount, EnumOptionData savingProductType, EnumOptionData tenureType, Integer tenure, EnumOptionData savingFrequencyType, EnumOptionData savingInterestType, EnumOptionData interestCalculationMethod, BigDecimal minimumBalanceForWithdrawal, boolean isPartialDepositAllowed, boolean isLockinPeriodAllowed, Integer lockinPeriod, - EnumOptionData lockinPeriodType) { + EnumOptionData lockinPeriodType, Integer depositEvery) { this.createdOn = createdOn; this.lastModifedOn = lastModifedOn; this.id = id; @@ -97,6 +106,7 @@ public class SavingProductData implements Serializable { this.isLockinPeriodAllowed = isLockinPeriodAllowed; this.lockinPeriod = lockinPeriod; this.lockinPeriodType = lockinPeriodType; + this.depositEvery = depositEvery; } public SavingProductData(SavingProductData product, List currencyOptions, List savingsProductTypeOptions, @@ -126,6 +136,7 @@ public class SavingProductData implements Serializable { this.isLockinPeriodAllowed = product.isLockinPeriodAllowed(); this.lockinPeriod = product.getLockinPeriod(); this.lockinPeriodType = product.getLockinPeriodType(); + this.depositEvery = product.getDepositEvery(); this.currencyOptions = currencyOptions; this.savingsProductTypeOptions = savingsProductTypeOptions; @@ -257,4 +268,8 @@ public class SavingProductData implements Serializable { return interestCalculationOptions; } + public Integer getDepositEvery() { + return this.depositEvery; + } + } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/data/SavingProductLookup.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/data/SavingProductLookup.java index 63526e8af..b405a1fa2 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/data/SavingProductLookup.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/data/SavingProductLookup.java @@ -4,11 +4,12 @@ import java.io.Serializable; public class SavingProductLookup implements Serializable { - private Long id; - private String name; + private final Long id; + private final String name; public SavingProductLookup() { - // + this.id=null; + this.name=null; } public SavingProductLookup(Long id, String name) { @@ -20,16 +21,12 @@ public class SavingProductLookup implements Serializable { return id; } - public void setId(Long id) { - this.id = id; - } - public String getName() { return name; } - public void setName(String name) { - this.name = name; + public boolean hasId(final Long matchingId) { + return this.id.equals(matchingId); } } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/domain/SavingProduct.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/domain/SavingProduct.java index 425c2673c..063d99811 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/domain/SavingProduct.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/domain/SavingProduct.java @@ -38,7 +38,7 @@ public class SavingProduct extends AbstractAuditableCustom { } public SavingProduct(final String name, final String description, final MonetaryCurrency currency, final BigDecimal interestRate, - final BigDecimal minInterestRate, final BigDecimal maxInterestRate, final BigDecimal savingsDepositAmount, + final BigDecimal minInterestRate, final BigDecimal maxInterestRate, final BigDecimal savingsDepositAmount,Integer depositEvery, final SavingProductType savingProductType, final TenureTypeEnum tenureType, final Integer tenure, final SavingFrequencyType savingFrequencyType, final SavingsInterestType savingsInterestType, SavingInterestCalculationMethod savingInterestCalculationMethod, final BigDecimal minimumBalanceForWithdrawal, @@ -52,7 +52,7 @@ public class SavingProduct extends AbstractAuditableCustom { this.description = null; } this.savingProductRelatedDetail = new SavingProductRelatedDetail(currency, interestRate, minInterestRate, maxInterestRate, - savingsDepositAmount, savingProductType, tenureType, tenure, savingFrequencyType, savingsInterestType, + savingsDepositAmount, depositEvery, savingProductType, tenureType, tenure, savingFrequencyType, savingsInterestType, savingInterestCalculationMethod, minimumBalanceForWithdrawal, isPartialDepositAllowed, isLockinPeriodAllowed, lockinPeriod, lockinPeriodType); } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/domain/SavingProductRelatedDetail.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/domain/SavingProductRelatedDetail.java index 266a9b547..243775d84 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/domain/SavingProductRelatedDetail.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/domain/SavingProductRelatedDetail.java @@ -30,6 +30,9 @@ public class SavingProductRelatedDetail { @Column(name = "savings_deposit_amount", scale = 6, precision = 19, nullable = false) private BigDecimal savingsDepositAmount; + + @Column(name = "deposit_every") + private Integer depositEvery; @Column(name = "savings_product_type", nullable = false) private SavingProductType savingProductType; @@ -70,7 +73,7 @@ public class SavingProductRelatedDetail { } public SavingProductRelatedDetail(final MonetaryCurrency currency, final BigDecimal interestRate, final BigDecimal minInterestRate, - final BigDecimal maxInterestRate, final BigDecimal savingsDepositAmount, final SavingProductType savingProductType, + final BigDecimal maxInterestRate, final BigDecimal savingsDepositAmount,final Integer depositEvery, final SavingProductType savingProductType, final TenureTypeEnum tenureType, final Integer tenure, final SavingFrequencyType frequency, final SavingsInterestType interestType, final SavingInterestCalculationMethod interestCalculationMethod, final BigDecimal minimumBalanceForWithdrawal, final boolean isPartialDepositAllowed, final boolean isLockinPeriodAllowed, @@ -80,6 +83,7 @@ public class SavingProductRelatedDetail { this.minInterestRate = minInterestRate; this.maxInterestRate = maxInterestRate; this.savingsDepositAmount = savingsDepositAmount; + this.depositEvery=depositEvery; this.savingProductType = savingProductType; this.tenureType = tenureType; this.tenure = tenure; @@ -127,6 +131,10 @@ public class SavingProductRelatedDetail { if (command.isSavingsDepositAmountChanged()) { this.savingsDepositAmount = command.getSavingsDepositAmount(); } + + if (command.isDepositEveryChanged()) { + this.depositEvery=command.getDepositEvery(); + } if (command.isSavingProductTypeChanged()) { this.savingProductType = SavingProductType.fromInt(command.getSavingProductType()); @@ -177,7 +185,11 @@ public class SavingProductRelatedDetail { return savingsDepositAmount; } - public SavingProductType getSavingProductType() { + public Integer getDepositEvery() { + return this.depositEvery; + } + + public SavingProductType getSavingProductType() { return savingProductType; } diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductEnumerations.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductEnumerations.java index 08cfe6528..4b622d2d9 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductEnumerations.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductEnumerations.java @@ -120,7 +120,7 @@ public class SavingProductEnumerations { break; case MONTHLY: optionData = new EnumOptionData(SavingFrequencyType.MONTHLY.getValue().longValue(), codePrefix - + SavingFrequencyType.MONTHLY.getCode(), "Weeks"); + + SavingFrequencyType.MONTHLY.getCode(), "Months"); break; case QUATERLY: optionData = new EnumOptionData(SavingFrequencyType.QUATERLY.getValue().longValue(), codePrefix diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductReadPlatformServiceImpl.java index 275e523b3..aa2c53cae 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductReadPlatformServiceImpl.java @@ -60,7 +60,7 @@ public class SavingProductReadPlatformServiceImpl implements SavingProductReadPl SavingProductLookupMapper savingProductLookupMapper = new SavingProductLookupMapper(); - String sql = "select" + savingProductLookupMapper.savingProductLookupSchema(); + String sql = "select " + savingProductLookupMapper.savingProductLookupSchema() + " where sp.is_deleted=0"; return this.jdbcTemplate.query(sql, savingProductLookupMapper, new Object[] {}); } @@ -95,7 +95,7 @@ public class SavingProductReadPlatformServiceImpl implements SavingProductReadPl public String savingProductSchema() { return "sp.id as id,sp.name as name, sp.description as description,sp.currency_code as currencyCode, sp.currency_digits as currencyDigits,sp.interest_rate as interestRate, " - + "sp.min_interest_rate as minInterestRate, sp.max_interest_rate as maxInterstRate, " + + "sp.min_interest_rate as minInterestRate, sp.max_interest_rate as maxInterstRate, sp.deposit_every as depositEvery, " + " sp.savings_deposit_amount as savingsDepositAmount, sp.savings_product_type as savingProductType, sp.tenure_type as tenureType, sp.tenure as tenure, sp.frequency as frequency, " + " sp.interest_type as interestType, sp.interest_calculation_method as interestCalculationMethod, sp.min_bal_for_withdrawal as minimumBalanceForWithdrawal, " + " sp.is_partial_deposit_allowed as isPartialDepositAllowed, sp.is_lock_in_period_allowed as isLockinPeriodAllowed, sp.lock_in_period as lockinPeriod, sp.lock_in_period_type as lockinPeriodType, " @@ -126,6 +126,7 @@ public class SavingProductReadPlatformServiceImpl implements SavingProductReadPl DateTime createdOn = JdbcSupport.getDateTime(rs, "createdon"); DateTime lastModifedOn = JdbcSupport.getDateTime(rs, "modifiedon"); + Integer depositEvery = JdbcSupport.getInteger(rs, "depositEvery"); BigDecimal savingsDepositAmount = rs.getBigDecimal("savingsDepositAmount"); EnumOptionData savingProductTypeEnum = SavingProductEnumerations.savingProductType(SavingProductType.fromInt(JdbcSupport .getInteger(rs, "savingProductType"))); @@ -145,14 +146,14 @@ public class SavingProductReadPlatformServiceImpl implements SavingProductReadPl return new SavingProductData(createdOn, lastModifedOn, id, name, description, interestRate, minInterestRate, maxInterestRate, currencyData, currencyDigits, savingsDepositAmount, savingProductTypeEnum, tenureTypeEnum, tenure, savingFrequencyType, savingInterestType, interestCalculationMethodEnum, minimumBalanceForWithdrawal, isPartialDepositAllowed, - isLockinPeriodAllowed, lockinPeriod, lockinPeriodType); + isLockinPeriodAllowed, lockinPeriod, lockinPeriodType,depositEvery); } } private static final class SavingProductLookupMapper implements RowMapper { public String savingProductLookupSchema() { - return "sp.id as id, sp.name as name from m_product_savings sp"; + return " sp.id as id, sp.name as name from m_product_savings sp"; } @Override diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductWritePlatformServiceJpaRepositoryImpl.java index 8f611b497..ae5466864 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savingsaccountproduct/service/SavingProductWritePlatformServiceJpaRepositoryImpl.java @@ -49,7 +49,7 @@ public class SavingProductWritePlatformServiceJpaRepositoryImpl implements Savin MonetaryCurrency currency = new MonetaryCurrency(command.getCurrencyCode(), command.getDigitsAfterDecimal()); SavingProduct product = new SavingProduct(command.getName(), command.getDescription(), currency, command.getInterestRate(), - command.getMinInterestRate(), command.getMaxInterestRate(), command.getSavingsDepositAmount(), savingProductType, + command.getMinInterestRate(), command.getMaxInterestRate(), command.getSavingsDepositAmount(),command.getDepositEvery(), savingProductType, tenureType, command.getTenure(), savingFrequencyType, interestType, savingInterestCalculationMethod, command.getMinimumBalanceForWithdrawal(), command.isPartialDepositAllowed(), command.isLockinPeriodAllowed(), command.getLockinPeriod(), lockinPeriodType);