diff --git a/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java index 54eb12f51..ae0e12252 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/organisation/monetary/service/CurrencyWritePlatformServiceJpaRepositoryImpl.java @@ -44,10 +44,8 @@ public class CurrencyWritePlatformServiceJpaRepositoryImpl implements CurrencyWr public CurrencyWritePlatformServiceJpaRepositoryImpl(final PlatformSecurityContext context, final CurrencyCommandFromApiJsonDeserializer fromApiJsonDeserializer, final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepository, - final OrganisationCurrencyRepository organisationCurrencyRepository, - final LoanProductReadPlatformService loanProductService, - final SavingsProductReadPlatformService savingsProductService, - final ChargeReadPlatformService chargeService) { + final OrganisationCurrencyRepository organisationCurrencyRepository, final LoanProductReadPlatformService loanProductService, + final SavingsProductReadPlatformService savingsProductService, final ChargeReadPlatformService chargeService) { this.context = context; this.fromApiJsonDeserializer = fromApiJsonDeserializer; this.applicationCurrencyRepository = applicationCurrencyRepository; @@ -81,16 +79,15 @@ public class CurrencyWritePlatformServiceJpaRepositoryImpl implements CurrencyWr } for (OrganisationCurrency priorCurrency : this.organisationCurrencyRepository.findAll()) { - if (!allowedCurrencyCodes.contains(priorCurrency.getCode())) { - // Check if it's safe to remove this currency. - if (!loanProductService.retrieveAllLoanProductsForCurrency(priorCurrency).isEmpty() || - !savingsProductService.retrieveAllForCurrency(priorCurrency).isEmpty() || - !chargeService.retrieveAllChargesForCurrency(priorCurrency).isEmpty()) { - throw new CurrencyInUseException(priorCurrency.getCode()); - } - } + if (!allowedCurrencyCodes.contains(priorCurrency.getCode())) { + // Check if it's safe to remove this currency. + if (!loanProductService.retrieveAllLoanProductsForCurrency(priorCurrency.getCode()).isEmpty() + || !savingsProductService.retrieveAllForCurrency(priorCurrency.getCode()).isEmpty() + || !chargeService.retrieveAllChargesForCurrency(priorCurrency.getCode()).isEmpty()) { throw new CurrencyInUseException( + priorCurrency.getCode()); } + } } - + changes.put("currencies", allowedCurrencyCodes.toArray(new String[allowedCurrencyCodes.size()])); this.organisationCurrencyRepository.deleteAll(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformService.java index a14084bdd..af2322bde 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformService.java @@ -7,14 +7,13 @@ package org.mifosplatform.portfolio.charge.service; import java.util.Collection; -import org.mifosplatform.organisation.office.domain.OrganisationCurrency; import org.mifosplatform.portfolio.charge.data.ChargeData; public interface ChargeReadPlatformService { Collection retrieveAllCharges(); - Collection retrieveAllChargesForCurrency(OrganisationCurrency currency); + Collection retrieveAllChargesForCurrency(String currencyCode); ChargeData retrieveCharge(Long chargeId); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java index a218fd525..c43c762e1 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/charge/service/ChargeReadPlatformServiceImpl.java @@ -18,7 +18,6 @@ import org.mifosplatform.infrastructure.core.service.RoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.organisation.monetary.data.CurrencyData; import org.mifosplatform.organisation.monetary.service.CurrencyReadPlatformService; -import org.mifosplatform.organisation.office.domain.OrganisationCurrency; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.charge.domain.ChargeAppliesTo; import org.mifosplatform.portfolio.charge.exception.ChargeNotFoundException; @@ -64,20 +63,17 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService return this.jdbcTemplate.query(sql, rm, new Object[] {}); } - @Override - @Cacheable(value = "charges", key = "T(org.mifosplatform.infrastructure.core.service.ThreadLocalContextUtil).getTenant().getTenantIdentifier().concat('ch')") - public Collection retrieveAllChargesForCurrency( - OrganisationCurrency currency) { - this.context.authenticatedUser(); + @Override + public Collection retrieveAllChargesForCurrency(String currencyCode) { + this.context.authenticatedUser(); - final ChargeMapper rm = new ChargeMapper(); + final ChargeMapper rm = new ChargeMapper(); - final String sql = "select " + rm.chargeSchema() - + " where c.is_deleted=0 and c.currency_code='" + currency.getCode() - + "' order by c.name "; + final String sql = "select " + rm.chargeSchema() + " where c.is_deleted=0 and c.currency_code='" + currencyCode + + "' order by c.name "; - return this.jdbcTemplate.query(sql, rm, new Object[] {}); - } + return this.jdbcTemplate.query(sql, rm, new Object[] {}); + } @Override public ChargeData retrieveCharge(final Long chargeId) { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformService.java index b6615ce33..7ae1d8cc6 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformService.java @@ -7,7 +7,6 @@ package org.mifosplatform.portfolio.loanproduct.service; import java.util.Collection; -import org.mifosplatform.organisation.office.domain.OrganisationCurrency; import org.mifosplatform.portfolio.loanproduct.data.LoanProductBorrowerCycleVariationData; import org.mifosplatform.portfolio.loanproduct.data.LoanProductData; @@ -20,8 +19,8 @@ public interface LoanProductReadPlatformService { LoanProductData retrieveLoanProduct(Long productId); LoanProductData retrieveNewLoanProductDetails(); - - Collection retrieveAllLoanProductsForCurrency(OrganisationCurrency currency); + + Collection retrieveAllLoanProductsForCurrency(String currencyCode); Collection retrieveAvailableLoanProductsForMix(); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java index 8bbb23e6d..cd29ed3e4 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/loanproduct/service/LoanProductReadPlatformServiceImpl.java @@ -19,7 +19,6 @@ import org.mifosplatform.infrastructure.core.service.DateUtils; import org.mifosplatform.infrastructure.core.service.RoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.organisation.monetary.data.CurrencyData; -import org.mifosplatform.organisation.office.domain.OrganisationCurrency; import org.mifosplatform.portfolio.charge.data.ChargeData; import org.mifosplatform.portfolio.charge.service.ChargeReadPlatformService; import org.mifosplatform.portfolio.loanproduct.data.LoanProductBorrowerCycleVariationData; @@ -291,19 +290,17 @@ public class LoanProductReadPlatformServiceImpl implements LoanProductReadPlatfo } } - - @Override - public Collection retrieveAllLoanProductsForCurrency( - OrganisationCurrency currency) { - this.context.authenticatedUser(); - final LoanProductMapper rm = new LoanProductMapper(null, null); + @Override + public Collection retrieveAllLoanProductsForCurrency(String currencyCode) { + this.context.authenticatedUser(); - final String sql = "select " + rm.loanProductSchema() - + " where lp.currency_code='" + currency.getCode() + "'"; + final LoanProductMapper rm = new LoanProductMapper(null, null); - return this.jdbcTemplate.query(sql, rm, new Object[] {}); - } + final String sql = "select " + rm.loanProductSchema() + " where lp.currency_code='" + currencyCode + "'"; + + return this.jdbcTemplate.query(sql, rm, new Object[] {}); + } @Override public Collection retrieveAvailableLoanProductsForMix() { diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/DepositAccountInterestIncentives.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/DepositAccountInterestIncentives.java index 274dc26b3..89340ce95 100755 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/DepositAccountInterestIncentives.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/domain/DepositAccountInterestIncentives.java @@ -13,7 +13,6 @@ import org.springframework.data.jpa.domain.AbstractPersistable; @Table(name = "m_savings_interest_incentives") public class DepositAccountInterestIncentives extends AbstractPersistable { - @SuppressWarnings("unused") @ManyToOne @JoinColumn(name = "deposit_account_interest_rate_slab_id", nullable = false) private DepositAccountInterestRateChartSlabs depositAccountInterestRateChartSlabs; diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformService.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformService.java index 9f1c93ef8..024979274 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformService.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformService.java @@ -7,7 +7,6 @@ package org.mifosplatform.portfolio.savings.service; import java.util.Collection; -import org.mifosplatform.organisation.office.domain.OrganisationCurrency; import org.mifosplatform.portfolio.savings.data.SavingsProductData; public interface SavingsProductReadPlatformService { @@ -18,7 +17,7 @@ public interface SavingsProductReadPlatformService { Collection retrieveAllForLookupByType(Boolean isOverdraftType); - Collection retrieveAllForCurrency(OrganisationCurrency currency); + Collection retrieveAllForCurrency(String currencyCode); SavingsProductData retrieveOne(Long productId); diff --git a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformServiceImpl.java b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformServiceImpl.java index 3a82a94fd..b89ed4d8b 100644 --- a/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformServiceImpl.java +++ b/mifosng-provider/src/main/java/org/mifosplatform/portfolio/savings/service/SavingsProductReadPlatformServiceImpl.java @@ -16,7 +16,6 @@ import org.mifosplatform.infrastructure.core.domain.JdbcSupport; import org.mifosplatform.infrastructure.core.service.RoutingDataSource; import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext; import org.mifosplatform.organisation.monetary.data.CurrencyData; -import org.mifosplatform.organisation.office.domain.OrganisationCurrency; import org.mifosplatform.portfolio.savings.DepositAccountType; import org.mifosplatform.portfolio.savings.data.SavingsProductData; import org.mifosplatform.portfolio.savings.exception.SavingsProductNotFoundException; @@ -179,25 +178,23 @@ public class SavingsProductReadPlatformServiceImpl implements SavingsProductRead @Override public Collection retrieveAllForLookupByType(Boolean isOverdraftType) { - String sql = "select " + this.savingsProductLookupsRowMapper.schema(); - if(isOverdraftType != null){ - sql += " where sp.allow_overdraft=?"; - return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper, isOverdraftType); - } + String sql = "select " + this.savingsProductLookupsRowMapper.schema(); + if (isOverdraftType != null) { + sql += " where sp.allow_overdraft=?"; + return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper, isOverdraftType); + } return this.jdbcTemplate.query(sql, this.savingsProductLookupsRowMapper); } - - @Override - public Collection retrieveAllForCurrency( - OrganisationCurrency currency) { - - this.context.authenticatedUser(); - final String sql = "select " + this.savingsProductRowMapper.schema() - + " where sp.currency_code='" + currency.getCode() + "'"; + @Override + public Collection retrieveAllForCurrency(String currencyCode) { + + this.context.authenticatedUser(); + + final String sql = "select " + this.savingsProductRowMapper.schema() + " where sp.currency_code='" + currencyCode + "'"; return this.jdbcTemplate.query(sql, this.savingsProductRowMapper, new Object[] { DepositAccountType.SAVINGS_DEPOSIT.getValue() }); - } + } } \ No newline at end of file