FINERACT-1760: Fix error handling for loan charge details
This commit is contained in:
committed by
Arnold Gálovics
parent
de0910f337
commit
0162ffe1ea
+6
@@ -22,6 +22,7 @@ import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.fineract.infrastructure.core.domain.ExternalId;
|
||||
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException;
|
||||
import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
|
||||
/**
|
||||
* {@link AbstractPlatformDomainRuleException} thrown when loan charge does not exist.
|
||||
@@ -41,6 +42,11 @@ public class LoanChargeNotFoundException extends AbstractPlatformResourceNotFoun
|
||||
id, loanId);
|
||||
}
|
||||
|
||||
public LoanChargeNotFoundException(final Long id, final Long loanId, final EmptyResultDataAccessException e) {
|
||||
super("error.msg.loanCharge.id.invalid.for.given.loan", "Loan charge with identifier " + id + " does not exist for loan " + loanId,
|
||||
id, loanId, e);
|
||||
}
|
||||
|
||||
public LoanChargeNotFoundException(ExternalId externalId) {
|
||||
super("error.msg.loanCharge.external.id.invalid", "Loan Charge with external identifier "
|
||||
+ ObjectUtils.defaultIfNull(externalId, ExternalId.empty()).getValue() + " does not exist", externalId);
|
||||
|
||||
+9
-7
@@ -36,6 +36,7 @@ import org.apache.fineract.infrastructure.core.service.ExternalIdFactory;
|
||||
import org.apache.fineract.organisation.monetary.data.CurrencyData;
|
||||
import org.apache.fineract.portfolio.charge.data.ChargeData;
|
||||
import org.apache.fineract.portfolio.charge.domain.Charge;
|
||||
import org.apache.fineract.portfolio.charge.exception.LoanChargeNotFoundException;
|
||||
import org.apache.fineract.portfolio.charge.service.ChargeDropdownReadPlatformService;
|
||||
import org.apache.fineract.portfolio.charge.service.ChargeEnumerations;
|
||||
import org.apache.fineract.portfolio.common.service.DropdownReadPlatformService;
|
||||
@@ -47,6 +48,7 @@ import org.apache.fineract.portfolio.loanaccount.domain.LoanCharge;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanChargeRepository;
|
||||
import org.apache.fineract.portfolio.loanaccount.domain.LoanTransactionType;
|
||||
import org.apache.fineract.portfolio.tax.data.TaxGroupData;
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -169,20 +171,20 @@ public class LoanChargeReadPlatformServiceImpl implements LoanChargeReadPlatform
|
||||
|
||||
@Override
|
||||
public LoanChargeData retrieveLoanChargeDetails(final Long id, final Long loanId) {
|
||||
final LoanChargeMapper rm = new LoanChargeMapper();
|
||||
|
||||
final String sql = "select " + rm.schema() + " where lc.id=? and lc.loan_id=?";
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, id, loanId); // NOSONAR
|
||||
try {
|
||||
final LoanChargeMapper rm = new LoanChargeMapper();
|
||||
final String sql = "select " + rm.schema() + " where lc.id=? and lc.loan_id=?";
|
||||
return this.jdbcTemplate.queryForObject(sql, rm, id, loanId); // NOSONAR
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new LoanChargeNotFoundException(id, loanId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<LoanChargeData> retrieveLoanCharges(final Long loanId) {
|
||||
final LoanChargeMapper rm = new LoanChargeMapper();
|
||||
|
||||
final String sql = "select " + rm.schema() + " where lc.loan_id=? AND lc.is_active = true"
|
||||
+ " order by coalesce(lc.due_for_collection_as_of_date,date(coalesce(dd.disbursedon_date,dd.expected_disburse_date))),lc.charge_time_enum ASC, lc.due_for_collection_as_of_date ASC, lc.is_penalty ASC";
|
||||
|
||||
return this.jdbcTemplate.query(sql, rm, loanId); // NOSONAR
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user