minor cleanups
This commit is contained in:
+10
-13
@@ -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();
|
||||
|
||||
+1
-2
@@ -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<ChargeData> retrieveAllCharges();
|
||||
|
||||
Collection<ChargeData> retrieveAllChargesForCurrency(OrganisationCurrency currency);
|
||||
Collection<ChargeData> retrieveAllChargesForCurrency(String currencyCode);
|
||||
|
||||
ChargeData retrieveCharge(Long chargeId);
|
||||
|
||||
|
||||
+8
-12
@@ -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<ChargeData> retrieveAllChargesForCurrency(
|
||||
OrganisationCurrency currency) {
|
||||
this.context.authenticatedUser();
|
||||
@Override
|
||||
public Collection<ChargeData> 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) {
|
||||
|
||||
+2
-3
@@ -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<LoanProductData> retrieveAllLoanProductsForCurrency(OrganisationCurrency currency);
|
||||
|
||||
Collection<LoanProductData> retrieveAllLoanProductsForCurrency(String currencyCode);
|
||||
|
||||
Collection<LoanProductData> retrieveAvailableLoanProductsForMix();
|
||||
|
||||
|
||||
+8
-11
@@ -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<LoanProductData> retrieveAllLoanProductsForCurrency(
|
||||
OrganisationCurrency currency) {
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final LoanProductMapper rm = new LoanProductMapper(null, null);
|
||||
@Override
|
||||
public Collection<LoanProductData> 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<LoanProductData> retrieveAvailableLoanProductsForMix() {
|
||||
|
||||
-1
@@ -13,7 +13,6 @@ import org.springframework.data.jpa.domain.AbstractPersistable;
|
||||
@Table(name = "m_savings_interest_incentives")
|
||||
public class DepositAccountInterestIncentives extends AbstractPersistable<Long> {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "deposit_account_interest_rate_slab_id", nullable = false)
|
||||
private DepositAccountInterestRateChartSlabs depositAccountInterestRateChartSlabs;
|
||||
|
||||
+1
-2
@@ -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<SavingsProductData> retrieveAllForLookupByType(Boolean isOverdraftType);
|
||||
|
||||
Collection<SavingsProductData> retrieveAllForCurrency(OrganisationCurrency currency);
|
||||
Collection<SavingsProductData> retrieveAllForCurrency(String currencyCode);
|
||||
|
||||
SavingsProductData retrieveOne(Long productId);
|
||||
|
||||
|
||||
+12
-15
@@ -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<SavingsProductData> 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<SavingsProductData> retrieveAllForCurrency(
|
||||
OrganisationCurrency currency) {
|
||||
|
||||
this.context.authenticatedUser();
|
||||
|
||||
final String sql = "select " + this.savingsProductRowMapper.schema()
|
||||
+ " where sp.currency_code='" + currency.getCode() + "'";
|
||||
@Override
|
||||
public Collection<SavingsProductData> 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() });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user