Throwing account specific exceptions for saving product
This commit is contained in:
-16
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
package org.mifosplatform.portfolio.savingsaccountproduct.exception;
|
||||
|
||||
import org.mifosplatform.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
||||
|
||||
public class SavingsProductNotFoundException extends AbstractPlatformResourceNotFoundException {
|
||||
|
||||
public SavingsProductNotFoundException(final Long id) {
|
||||
super("error.msg.product.id.invalid", "Product with identifier " + id + " does not exist", id);
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -18,10 +18,10 @@ 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.loanproduct.domain.PeriodFrequencyType;
|
||||
import org.mifosplatform.portfolio.loanproduct.exception.LoanProductNotFoundException;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.data.SavingProductData;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.data.SavingProductLookup;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingProductType;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.exception.SavingProductNotFoundException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -81,7 +81,7 @@ public class SavingProductReadPlatformServiceImpl implements SavingProductReadPl
|
||||
|
||||
return productData;
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
throw new LoanProductNotFoundException(savingProductId);
|
||||
throw new SavingProductNotFoundException(savingProductId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-4
@@ -21,7 +21,6 @@ import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingProductRep
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingProductType;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.domain.SavingsInterestType;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.exception.SavingProductNotFoundException;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.exception.SavingsProductNotFoundException;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.serialization.SavingProductCommandFromApiJsonDeserializer;
|
||||
import org.mifosplatform.portfolio.savingsdepositproduct.domain.TenureTypeEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -70,8 +69,8 @@ public class SavingProductWritePlatformServiceJpaRepositoryImpl implements Savin
|
||||
if (savingProductType.equals(SavingProductType.INVALID) || tenureType.equals(TenureTypeEnum.INVALID)
|
||||
|| savingFrequencyType.equals(SavingFrequencyType.INVALID) || interestType.equals(SavingsInterestType.INVALID)
|
||||
|| lockinPeriodType.equals(PeriodFrequencyType.INVALID)
|
||||
|| savingInterestCalculationMethod.equals(SavingInterestCalculationMethod.INVALID)) { throw new NoAuthorizationException(
|
||||
"Please select a valid types"); }
|
||||
|| savingInterestCalculationMethod.equals(SavingInterestCalculationMethod.INVALID)) {
|
||||
throw new NoAuthorizationException("Please select a valid types"); }
|
||||
|
||||
SavingProduct product = SavingProduct.assembleFromJson(command, currency, savingProductType, tenureType, savingFrequencyType,
|
||||
interestType, savingInterestCalculationMethod, lockinPeriodType);
|
||||
@@ -108,7 +107,7 @@ public class SavingProductWritePlatformServiceJpaRepositoryImpl implements Savin
|
||||
|
||||
this.context.authenticatedUser();
|
||||
SavingProduct product = this.savingProductRepository.findOne(productId);
|
||||
if (product == null || product.isDeleted()) { throw new SavingsProductNotFoundException(productId); }
|
||||
if (product == null || product.isDeleted()) { throw new SavingProductNotFoundException(productId); }
|
||||
product.delete();
|
||||
this.savingProductRepository.save(product);
|
||||
return new CommandProcessingResultBuilder() //
|
||||
|
||||
+1
-2
@@ -23,7 +23,6 @@ import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext
|
||||
import org.mifosplatform.organisation.monetary.domain.Money;
|
||||
import org.mifosplatform.portfolio.client.domain.Note;
|
||||
import org.mifosplatform.portfolio.client.domain.NoteRepository;
|
||||
import org.mifosplatform.portfolio.savingsaccountproduct.exception.SavingsProductNotFoundException;
|
||||
import org.mifosplatform.portfolio.savingsdepositaccount.data.DepositAccountsForLookup;
|
||||
import org.mifosplatform.portfolio.savingsdepositaccount.domain.DepositAccount;
|
||||
import org.mifosplatform.portfolio.savingsdepositaccount.domain.DepositAccountRepository;
|
||||
@@ -116,7 +115,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
this.context.authenticatedUser();
|
||||
|
||||
DepositAccount account = this.depositAccountRepository.findOne(accountId);
|
||||
if (account == null || account.isDeleted()) { throw new SavingsProductNotFoundException(accountId); }
|
||||
if (account == null || account.isDeleted()) { throw new DepositAccountNotFoundException(accountId); }
|
||||
|
||||
account.delete();
|
||||
this.depositAccountRepository.save(account);
|
||||
|
||||
+7
-2
@@ -72,9 +72,14 @@ public class DepositProductWritePlatformServiceJpaRepositoryImpl implements Depo
|
||||
this.context.authenticatedUser();
|
||||
this.fromApiJsonDeserializer.validateForCreate(command.json());
|
||||
|
||||
PeriodFrequencyType lockinPeriodType = null;
|
||||
//By default months
|
||||
PeriodFrequencyType interestCompoundingPeriodType =PeriodFrequencyType.MONTHS;
|
||||
PeriodFrequencyType lockinPeriodType = PeriodFrequencyType.MONTHS;
|
||||
|
||||
final Integer interestCompoundingPeriodTypeIntValue = command.integerValueOfParameterNamed("interestCompoundedEveryPeriodType");
|
||||
PeriodFrequencyType interestCompoundingPeriodType = PeriodFrequencyType.fromInt(interestCompoundingPeriodTypeIntValue);
|
||||
if (interestCompoundingPeriodTypeIntValue != null) {
|
||||
interestCompoundingPeriodType = PeriodFrequencyType.fromInt(interestCompoundingPeriodTypeIntValue);
|
||||
}
|
||||
|
||||
final Integer lockinPeriodTypeIntValue = command.integerValueOfParameterNamed("lockinPeriodType");
|
||||
if (lockinPeriodTypeIntValue != null) {
|
||||
|
||||
Reference in New Issue
Block a user