MIFOSX-90: detect in active charges on product during loan creation.
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package org.mifosng.platform.charge.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.mifosng.platform.api.data.EnumOptionData;
|
||||||
|
|
||||||
|
public interface ChargeDropdownReadPlatformService {
|
||||||
|
|
||||||
|
List<EnumOptionData> retrieveCalculationTypes();
|
||||||
|
|
||||||
|
List<EnumOptionData> retrieveApplicableToTypes();
|
||||||
|
|
||||||
|
List<EnumOptionData> retrieveCollectionTimeTypes();
|
||||||
|
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package org.mifosng.platform.charge.service;
|
||||||
|
|
||||||
|
import static org.mifosng.platform.charge.service.ChargeEnumerations.chargeAppliesTo;
|
||||||
|
import static org.mifosng.platform.charge.service.ChargeEnumerations.chargeCalculationType;
|
||||||
|
import static org.mifosng.platform.charge.service.ChargeEnumerations.chargeTimeType;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.mifosng.platform.api.data.EnumOptionData;
|
||||||
|
import org.mifosng.platform.charge.domain.ChargeAppliesTo;
|
||||||
|
import org.mifosng.platform.charge.domain.ChargeCalculationType;
|
||||||
|
import org.mifosng.platform.charge.domain.ChargeTimeType;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ChargeDropdownReadPlatformServiceImpl implements ChargeDropdownReadPlatformService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EnumOptionData> retrieveCalculationTypes() {
|
||||||
|
|
||||||
|
return Arrays.asList(chargeCalculationType(ChargeCalculationType.FLAT),
|
||||||
|
chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT)
|
||||||
|
// chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST),
|
||||||
|
// chargeCalculationType(ChargeCalculationType.PERCENT_OF_INTEREST)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EnumOptionData> retrieveApplicableToTypes() {
|
||||||
|
return Arrays.asList(chargeAppliesTo(ChargeAppliesTo.LOAN));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EnumOptionData> retrieveCollectionTimeTypes() {
|
||||||
|
return Arrays.asList(chargeTimeType(ChargeTimeType.DISBURSEMENT));
|
||||||
|
}
|
||||||
|
}
|
||||||
+54
-76
@@ -1,12 +1,16 @@
|
|||||||
package org.mifosng.platform.charge.service;
|
package org.mifosng.platform.charge.service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.mifosng.platform.api.data.ChargeData;
|
import org.mifosng.platform.api.data.ChargeData;
|
||||||
import org.mifosng.platform.api.data.CurrencyData;
|
import org.mifosng.platform.api.data.CurrencyData;
|
||||||
import org.mifosng.platform.api.data.EnumOptionData;
|
import org.mifosng.platform.api.data.EnumOptionData;
|
||||||
import org.mifosng.platform.api.data.LoanChargeData;
|
import org.mifosng.platform.api.data.LoanChargeData;
|
||||||
import org.mifosng.platform.charge.domain.ChargeAppliesTo;
|
import org.mifosng.platform.charge.domain.ChargeAppliesTo;
|
||||||
import org.mifosng.platform.charge.domain.ChargeCalculationType;
|
|
||||||
import org.mifosng.platform.charge.domain.ChargeTimeType;
|
|
||||||
import org.mifosng.platform.currency.service.CurrencyReadPlatformService;
|
import org.mifosng.platform.currency.service.CurrencyReadPlatformService;
|
||||||
import org.mifosng.platform.exceptions.ChargeNotFoundException;
|
import org.mifosng.platform.exceptions.ChargeNotFoundException;
|
||||||
import org.mifosng.platform.infrastructure.JdbcSupport;
|
import org.mifosng.platform.infrastructure.JdbcSupport;
|
||||||
@@ -18,55 +22,47 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|||||||
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.jdbc.core.RowMapper;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static org.mifosng.platform.charge.service.ChargeEnumerations.chargeAppliesTo;
|
|
||||||
import static org.mifosng.platform.charge.service.ChargeEnumerations.chargeCalculationType;
|
|
||||||
import static org.mifosng.platform.charge.service.ChargeEnumerations.chargeTimeType;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService {
|
public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService {
|
||||||
|
|
||||||
private final JdbcTemplate jdbcTemplate;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
private final PlatformSecurityContext context;
|
private final PlatformSecurityContext context;
|
||||||
private final CurrencyReadPlatformService currencyReadPlatformService;
|
private final CurrencyReadPlatformService currencyReadPlatformService;
|
||||||
|
private final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public ChargeReadPlatformServiceImpl(PlatformSecurityContext context,
|
public ChargeReadPlatformServiceImpl(
|
||||||
final CurrencyReadPlatformService currencyReadPlatformService,
|
final PlatformSecurityContext context,
|
||||||
final TenantAwareRoutingDataSource dataSource) {
|
final CurrencyReadPlatformService currencyReadPlatformService,
|
||||||
this.context = context;
|
final ChargeDropdownReadPlatformService chargeDropdownReadPlatformService,
|
||||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
final TenantAwareRoutingDataSource dataSource) {
|
||||||
this.currencyReadPlatformService = currencyReadPlatformService;
|
this.context = context;
|
||||||
}
|
this.chargeDropdownReadPlatformService = chargeDropdownReadPlatformService;
|
||||||
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
|
this.currencyReadPlatformService = currencyReadPlatformService;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<ChargeData> retrieveAllCharges() {
|
public Collection<ChargeData> retrieveAllCharges() {
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
ChargeMapper rm = new ChargeMapper();
|
final ChargeMapper rm = new ChargeMapper();
|
||||||
|
|
||||||
String sql = "select " + rm.chargeSchema() + " where c.is_deleted=0 order by c.name ";
|
final String sql = "select " + rm.chargeSchema() + " where c.is_deleted=0 order by c.name ";
|
||||||
|
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
return this.jdbcTemplate.query(sql, rm, new Object[] {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChargeData retrieveCharge(Long chargeId) {
|
public ChargeData retrieveCharge(final Long chargeId) {
|
||||||
try {
|
try {
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
ChargeMapper rm = new ChargeMapper();
|
final ChargeMapper rm = new ChargeMapper();
|
||||||
|
|
||||||
String sql = "select " + rm.chargeSchema() + " where c.id = ? and c.is_deleted=0 ";
|
final String sql = "select " + rm.chargeSchema() + " where c.id = ? and c.is_deleted=0 ";
|
||||||
|
|
||||||
ChargeData chargeData = this.jdbcTemplate.queryForObject(sql, rm, new Object[] {chargeId});
|
return this.jdbcTemplate.queryForObject(sql, rm, new Object[] {chargeId});
|
||||||
return chargeData;
|
|
||||||
} catch (EmptyResultDataAccessException e){
|
} catch (EmptyResultDataAccessException e){
|
||||||
throw new ChargeNotFoundException(chargeId);
|
throw new ChargeNotFoundException(chargeId);
|
||||||
}
|
}
|
||||||
@@ -77,18 +73,10 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
|
|||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
|
final List<CurrencyData> currencyOptions = currencyReadPlatformService.retrieveAllowedCurrencies();
|
||||||
|
final List<EnumOptionData> allowedChargeCalculationTypeOptions = this.chargeDropdownReadPlatformService.retrieveCalculationTypes();
|
||||||
List<EnumOptionData> allowedChargeCalculationTypeOptions = Arrays.asList(
|
final List<EnumOptionData> allowedChargeAppliesToOptions = this.chargeDropdownReadPlatformService.retrieveApplicableToTypes();
|
||||||
chargeCalculationType(ChargeCalculationType.FLAT),
|
final List<EnumOptionData> allowedChargeTimeOptions = this.chargeDropdownReadPlatformService.retrieveCollectionTimeTypes();
|
||||||
chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT),
|
|
||||||
chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST),
|
|
||||||
chargeCalculationType(ChargeCalculationType.PERCENT_OF_INTEREST)
|
|
||||||
);
|
|
||||||
|
|
||||||
List<EnumOptionData> allowedChargeAppliesToOptions = Arrays.asList(chargeAppliesTo(ChargeAppliesTo.LOAN));
|
|
||||||
|
|
||||||
List<EnumOptionData> allowedChargeTimeOptions = Arrays.asList(chargeTimeType(ChargeTimeType.DISBURSEMENT));
|
|
||||||
|
|
||||||
return ChargeData.template(currencyOptions, allowedChargeCalculationTypeOptions,
|
return ChargeData.template(currencyOptions, allowedChargeCalculationTypeOptions,
|
||||||
allowedChargeAppliesToOptions, allowedChargeTimeOptions);
|
allowedChargeAppliesToOptions, allowedChargeTimeOptions);
|
||||||
@@ -99,9 +87,9 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
|
|||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
ChargeMapper rm = new ChargeMapper();
|
final ChargeMapper rm = new ChargeMapper();
|
||||||
|
|
||||||
String sql = "select " + rm.loanProductChargeSchema() + " where c.is_deleted=0 and plc.product_loan_id=?";
|
final String sql = "select " + rm.loanProductChargeSchema() + " where c.is_deleted=0 and plc.product_loan_id=?";
|
||||||
|
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] {loanProductId});
|
return this.jdbcTemplate.query(sql, rm, new Object[] {loanProductId});
|
||||||
}
|
}
|
||||||
@@ -110,9 +98,9 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
|
|||||||
public Collection<LoanChargeData> retrieveLoanCharges(Long loanId) {
|
public Collection<LoanChargeData> retrieveLoanCharges(Long loanId) {
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
LoanChargeMapper rm = new LoanChargeMapper();
|
final LoanChargeMapper rm = new LoanChargeMapper();
|
||||||
|
|
||||||
String sql = "select " + rm.loanChargeSchema() + " where c.is_deleted=0 and lc.loan_id=?";
|
final String sql = "select " + rm.loanChargeSchema() + " where c.is_deleted=0 and lc.loan_id=?";
|
||||||
|
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] {loanId});
|
return this.jdbcTemplate.query(sql, rm, new Object[] {loanId});
|
||||||
}
|
}
|
||||||
@@ -121,9 +109,9 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
|
|||||||
public Collection<ChargeData> retrieveLoanApplicableCharges() {
|
public Collection<ChargeData> retrieveLoanApplicableCharges() {
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
ChargeMapper rm = new ChargeMapper();
|
final ChargeMapper rm = new ChargeMapper();
|
||||||
|
|
||||||
String sql = "select " + rm.chargeSchema() + " where c.is_deleted=0 and c.is_active=1 and c.charge_applies_to_enum=? order by c.name ";
|
final String sql = "select " + rm.chargeSchema() + " where c.is_deleted=0 and c.is_active=1 and c.charge_applies_to_enum=? order by c.name ";
|
||||||
|
|
||||||
return this.jdbcTemplate.query(sql, rm, new Object[] {ChargeAppliesTo.LOAN.getValue()});
|
return this.jdbcTemplate.query(sql, rm, new Object[] {ChargeAppliesTo.LOAN.getValue()});
|
||||||
}
|
}
|
||||||
@@ -132,17 +120,10 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
|
|||||||
public ChargeData retrieveLoanChargeTemplate() {
|
public ChargeData retrieveLoanChargeTemplate() {
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
List<EnumOptionData> allowedChargeCalculationTypeOptions = Arrays.asList(
|
final List<EnumOptionData> allowedChargeCalculationTypeOptions = this.chargeDropdownReadPlatformService.retrieveCalculationTypes();
|
||||||
chargeCalculationType(ChargeCalculationType.FLAT),
|
final List<EnumOptionData> allowedChargeTimeOptions = this.chargeDropdownReadPlatformService.retrieveCollectionTimeTypes();
|
||||||
chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT),
|
|
||||||
chargeCalculationType(ChargeCalculationType.PERCENT_OF_AMOUNT_AND_INTEREST),
|
|
||||||
chargeCalculationType(ChargeCalculationType.PERCENT_OF_INTEREST)
|
|
||||||
);
|
|
||||||
|
|
||||||
List<EnumOptionData> allowedChargeTimeOptions = Arrays.asList(chargeTimeType(ChargeTimeType.DISBURSEMENT));
|
return ChargeData.template(null, allowedChargeCalculationTypeOptions, null, allowedChargeTimeOptions);
|
||||||
|
|
||||||
return ChargeData.template(null, allowedChargeCalculationTypeOptions,
|
|
||||||
null, allowedChargeTimeOptions);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class ChargeMapper implements RowMapper<ChargeData> {
|
private static final class ChargeMapper implements RowMapper<ChargeData> {
|
||||||
@@ -160,33 +141,30 @@ public class ChargeReadPlatformServiceImpl implements ChargeReadPlatformService
|
|||||||
return chargeSchema() + " join m_product_loan_charge plc on plc.charge_id = c.id";
|
return chargeSchema() + " join m_product_loan_charge plc on plc.charge_id = c.id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChargeData mapRow(ResultSet rs, @SuppressWarnings("unused") int rowNum) throws SQLException {
|
public ChargeData mapRow(final ResultSet rs, @SuppressWarnings("unused") final int rowNum) throws SQLException {
|
||||||
Long id = rs.getLong("id");
|
final Long id = rs.getLong("id");
|
||||||
String name = rs.getString("name");
|
final String name = rs.getString("name");
|
||||||
BigDecimal amount = rs.getBigDecimal("amount");
|
final BigDecimal amount = rs.getBigDecimal("amount");
|
||||||
|
|
||||||
String currencyCode = rs.getString("currencyCode");
|
final String currencyCode = rs.getString("currencyCode");
|
||||||
String currencyName = rs.getString("currencyName");
|
final String currencyName = rs.getString("currencyName");
|
||||||
String currencyNameCode = rs.getString("currencyNameCode");
|
final String currencyNameCode = rs.getString("currencyNameCode");
|
||||||
String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
|
final String currencyDisplaySymbol = rs.getString("currencyDisplaySymbol");
|
||||||
Integer currencyDecimalPlaces = JdbcSupport.getInteger(rs, "currencyDecimalPlaces");
|
final Integer currencyDecimalPlaces = JdbcSupport.getInteger(rs, "currencyDecimalPlaces");
|
||||||
|
|
||||||
CurrencyData currency = new CurrencyData(currencyCode, currencyName, currencyDecimalPlaces,
|
final CurrencyData currency = new CurrencyData(currencyCode, currencyName, currencyDecimalPlaces,
|
||||||
currencyDisplaySymbol, currencyNameCode);
|
currencyDisplaySymbol, currencyNameCode);
|
||||||
|
|
||||||
int chargeAppliesTo = rs.getInt("chargeAppliesTo");
|
final int chargeAppliesTo = rs.getInt("chargeAppliesTo");
|
||||||
EnumOptionData chargeAppliesToType = ChargeEnumerations.chargeAppliesTo(chargeAppliesTo);
|
final EnumOptionData chargeAppliesToType = ChargeEnumerations.chargeAppliesTo(chargeAppliesTo);
|
||||||
|
|
||||||
int chargeTime = rs.getInt("chargeTime");
|
final int chargeTime = rs.getInt("chargeTime");
|
||||||
EnumOptionData chargeTimeType = ChargeEnumerations.chargeTimeType(chargeTime);
|
final EnumOptionData chargeTimeType = ChargeEnumerations.chargeTimeType(chargeTime);
|
||||||
|
|
||||||
int chargeCalculation = rs.getInt("chargeCalculation");
|
final int chargeCalculation = rs.getInt("chargeCalculation");
|
||||||
EnumOptionData chargeCalculationType = ChargeEnumerations.chargeCalculationType(chargeCalculation);
|
final EnumOptionData chargeCalculationType = ChargeEnumerations.chargeCalculationType(chargeCalculation);
|
||||||
|
final boolean active = rs.getBoolean("active");
|
||||||
boolean active = rs.getBoolean("active");
|
|
||||||
|
|
||||||
return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesToType, chargeCalculationType, active);
|
return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesToType, chargeCalculationType, active);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-6
@@ -1,12 +1,11 @@
|
|||||||
package org.mifosng.platform.exceptions;
|
package org.mifosng.platform.exceptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link AbstractPlatformDomainRuleException} thrown when charge is not active
|
* {@link AbstractPlatformDomainRuleException} thrown when charge is not active.
|
||||||
*/
|
*/
|
||||||
public class ChargeIsNotActiveException extends AbstractPlatformDomainRuleException{
|
public class ChargeIsNotActiveException extends AbstractPlatformDomainRuleException {
|
||||||
|
|
||||||
public ChargeIsNotActiveException(final Long id) {
|
|
||||||
super("error.msg.charge.is.not.active", "Charge with identifier " + id + " is not active", id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public ChargeIsNotActiveException(final Long id, final String name) {
|
||||||
|
super("error.msg.charge.is.not.active", "Charge '" + name + "' with identifier " + id + " is not active", name, id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -97,18 +97,18 @@ public class LoanAssembler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MonetaryCurrency currency = loanProduct.getCurrency();
|
final MonetaryCurrency currency = loanProduct.getCurrency();
|
||||||
final Integer loanTermFrequency = command.getLoanTermFrequency();
|
final Integer loanTermFrequency = command.getLoanTermFrequency();
|
||||||
final PeriodFrequencyType loanTermFrequencyType = PeriodFrequencyType.fromInt(command.getLoanTermFrequencyType());
|
final PeriodFrequencyType loanTermFrequencyType = PeriodFrequencyType.fromInt(command.getLoanTermFrequencyType());
|
||||||
|
|
||||||
LoanProductRelatedDetail loanRepaymentScheduleDetail = assembleLoanProductRelatedDetailFrom(command, currency);
|
final LoanProductRelatedDetail loanRepaymentScheduleDetail = assembleLoanProductRelatedDetailFrom(command, currency);
|
||||||
|
|
||||||
// associating fund with loan product at creation is optional for now.
|
// associating fund with loan product at creation is optional for now.
|
||||||
Fund fund = findFundByIdIfProvided(command.getFundId());
|
final Fund fund = findFundByIdIfProvided(command.getFundId());
|
||||||
LoanTransactionProcessingStrategy loanTransactionProcessingStrategy = findStrategyByIdIfProvided(command.getTransactionProcessingStrategyId());
|
final LoanTransactionProcessingStrategy loanTransactionProcessingStrategy = findStrategyByIdIfProvided(command.getTransactionProcessingStrategyId());
|
||||||
|
|
||||||
//optionally associate a loan officer to the loan
|
//optionally associate a loan officer to the loan
|
||||||
Staff loanOfficer= findLoanOfficerByIdIfProvided(command.getLoanOfficerId());
|
final Staff loanOfficer= findLoanOfficerByIdIfProvided(command.getLoanOfficerId());
|
||||||
|
|
||||||
// optionally, see if charges are associated with loan on creation (through loan product or by being directly added)
|
// optionally, see if charges are associated with loan on creation (through loan product or by being directly added)
|
||||||
final Set<LoanCharge> loanCharges = this.loanChargeAssembler.assembleFrom(command.getCharges(), loanProduct.getCharges(), command.getPrincipal());
|
final Set<LoanCharge> loanCharges = this.loanChargeAssembler.assembleFrom(command.getCharges(), loanProduct.getCharges(), command.getPrincipal());
|
||||||
|
|||||||
+5
@@ -7,6 +7,7 @@ import java.util.Set;
|
|||||||
import org.mifosng.platform.api.commands.LoanChargeCommand;
|
import org.mifosng.platform.api.commands.LoanChargeCommand;
|
||||||
import org.mifosng.platform.charge.domain.Charge;
|
import org.mifosng.platform.charge.domain.Charge;
|
||||||
import org.mifosng.platform.charge.domain.ChargeRepository;
|
import org.mifosng.platform.charge.domain.ChargeRepository;
|
||||||
|
import org.mifosng.platform.exceptions.ChargeIsNotActiveException;
|
||||||
import org.mifosng.platform.exceptions.ChargeNotFoundException;
|
import org.mifosng.platform.exceptions.ChargeNotFoundException;
|
||||||
import org.mifosng.platform.loan.domain.LoanCharge;
|
import org.mifosng.platform.loan.domain.LoanCharge;
|
||||||
import org.mifosng.platform.loan.domain.LoanChargeRepository;
|
import org.mifosng.platform.loan.domain.LoanChargeRepository;
|
||||||
@@ -37,6 +38,10 @@ public class LoanChargeAssembler {
|
|||||||
if (chargeDefinition == null || chargeDefinition.isDeleted()) {
|
if (chargeDefinition == null || chargeDefinition.isDeleted()) {
|
||||||
throw new ChargeNotFoundException(chargeDefinitionId);
|
throw new ChargeNotFoundException(chargeDefinitionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!chargeDefinition.isActive()) {
|
||||||
|
throw new ChargeIsNotActiveException(chargeDefinitionId, chargeDefinition.getName());
|
||||||
|
}
|
||||||
final LoanCharge loanCharge = LoanCharge.createNewWithoutLoan(chargeDefinition, loanChargeCommand, loanPrincipal);
|
final LoanCharge loanCharge = LoanCharge.createNewWithoutLoan(chargeDefinition, loanChargeCommand, loanPrincipal);
|
||||||
loanCharges.add(loanCharge);
|
loanCharges.add(loanCharge);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+4
-3
@@ -643,12 +643,12 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
throw new ChargeNotFoundException(command.getChargeId());
|
throw new ChargeNotFoundException(command.getChargeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
LoanCharge loanCharge = LoanCharge.createNew(loan, chargeDefinition, command);
|
|
||||||
|
|
||||||
if (!chargeDefinition.isActive()) {
|
if (!chargeDefinition.isActive()) {
|
||||||
throw new ChargeIsNotActiveException(chargeDefinition.getId());
|
throw new ChargeIsNotActiveException(chargeDefinition.getId(), chargeDefinition.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final LoanCharge loanCharge = LoanCharge.createNew(loan, chargeDefinition, command);
|
||||||
|
|
||||||
if (!loan.hasCurrencyCodeOf(chargeDefinition.getCurrencyCode())){
|
if (!loan.hasCurrencyCodeOf(chargeDefinition.getCurrencyCode())){
|
||||||
String errorMessage = "Charge and Loan must have the same currency.";
|
String errorMessage = "Charge and Loan must have the same currency.";
|
||||||
throw new InvalidCurrencyException("charge", "attach.to.loan", errorMessage);
|
throw new InvalidCurrencyException("charge", "attach.to.loan", errorMessage);
|
||||||
@@ -656,6 +656,7 @@ public class LoanWritePlatformServiceJpaRepositoryImpl implements LoanWritePlatf
|
|||||||
|
|
||||||
this.loanChargeRepository.saveAndFlush(loanCharge);
|
this.loanChargeRepository.saveAndFlush(loanCharge);
|
||||||
|
|
||||||
|
// FIXME - KW -
|
||||||
loan.getCharges().add(loanCharge);
|
loan.getCharges().add(loanCharge);
|
||||||
loan.updateTotalChargesDueAtDisbursement();
|
loan.updateTotalChargesDueAtDisbursement();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -171,7 +171,7 @@ public class LoanProductWritePlatformServiceJpaRepositoryImpl implements LoanPro
|
|||||||
throw new ChargeNotFoundException(id);
|
throw new ChargeNotFoundException(id);
|
||||||
}
|
}
|
||||||
if (!charge.isActive()){
|
if (!charge.isActive()){
|
||||||
throw new ChargeIsNotActiveException(id);
|
throw new ChargeIsNotActiveException(id, charge.getName());
|
||||||
}
|
}
|
||||||
if (!loanProductCurrencyCode.equals(charge.getCurrencyCode())){
|
if (!loanProductCurrencyCode.equals(charge.getCurrencyCode())){
|
||||||
String errorMessage = "Charge and Loan Product must have the same currency.";
|
String errorMessage = "Charge and Loan Product must have the same currency.";
|
||||||
|
|||||||
Reference in New Issue
Block a user