Mifosx 1523 - Loan Rescheduling modification
This commit is contained in:
+1
-3
@@ -72,16 +72,14 @@ public class RescheduleLoansApiResource {
|
|||||||
@Path("template")
|
@Path("template")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveTemplate(@Context final UriInfo uriInfo, @QueryParam("commandParam") final String commandParam) {
|
public String retrieveTemplate(@Context final UriInfo uriInfo) {
|
||||||
|
|
||||||
this.platformSecurityContext.authenticatedUser().validateHasReadPermission(RescheduleLoansApiConstants.ENTITY_NAME);
|
this.platformSecurityContext.authenticatedUser().validateHasReadPermission(RescheduleLoansApiConstants.ENTITY_NAME);
|
||||||
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
|
||||||
|
|
||||||
LoanRescheduleRequestData loanRescheduleReasons = null;
|
LoanRescheduleRequestData loanRescheduleReasons = null;
|
||||||
if (compareIgnoreCase(commandParam, "rescheduleReason")) {
|
|
||||||
loanRescheduleReasons = this.loanRescheduleRequestReadPlatformService
|
loanRescheduleReasons = this.loanRescheduleRequestReadPlatformService
|
||||||
.retrieveAllRescheduleReasons(RescheduleLoansApiConstants.LOAN_RESCHEDULE_REASON);
|
.retrieveAllRescheduleReasons(RescheduleLoansApiConstants.LOAN_RESCHEDULE_REASON);
|
||||||
}
|
|
||||||
|
|
||||||
return this.loanRescheduleRequestToApiJsonSerializer.serialize(settings, loanRescheduleReasons);
|
return this.loanRescheduleRequestToApiJsonSerializer.serialize(settings, loanRescheduleReasons);
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-27
@@ -39,11 +39,11 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
|||||||
private final CodeValueReadPlatformService codeValueReadPlatformService;
|
private final CodeValueReadPlatformService codeValueReadPlatformService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public LoanRescheduleRequestReadPlatformServiceImpl(final RoutingDataSource dataSource,
|
public LoanRescheduleRequestReadPlatformServiceImpl(final RoutingDataSource dataSource, LoanRepository loanRepository,
|
||||||
LoanRepository loanRepository, final CodeValueReadPlatformService codeValueReadPlatformService) {
|
final CodeValueReadPlatformService codeValueReadPlatformService) {
|
||||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
this.loanRepository = loanRepository;
|
this.loanRepository = loanRepository;
|
||||||
this.codeValueReadPlatformService = codeValueReadPlatformService ;
|
this.codeValueReadPlatformService = codeValueReadPlatformService;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class LoanRescheduleRequestRowMapper implements RowMapper<LoanRescheduleRequestData> {
|
private static final class LoanRescheduleRequestRowMapper implements RowMapper<LoanRescheduleRequestData> {
|
||||||
@@ -109,8 +109,7 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
|||||||
final Long id = rs.getLong("id");
|
final Long id = rs.getLong("id");
|
||||||
final Long loanId = rs.getLong("loanId");
|
final Long loanId = rs.getLong("loanId");
|
||||||
final Integer statusEnumId = JdbcSupport.getInteger(rs, "statusEnum");
|
final Integer statusEnumId = JdbcSupport.getInteger(rs, "statusEnum");
|
||||||
final LoanRescheduleRequestStatusEnumData statusEnum = LoanRescheduleRequestEnumerations
|
final LoanRescheduleRequestStatusEnumData statusEnum = LoanRescheduleRequestEnumerations.status(statusEnumId);
|
||||||
.status(statusEnumId);
|
|
||||||
final String clientName = rs.getString("clientName");
|
final String clientName = rs.getString("clientName");
|
||||||
final String loanAccountNumber = rs.getString("loanAccountNumber");
|
final String loanAccountNumber = rs.getString("loanAccountNumber");
|
||||||
final Long clientId = rs.getLong("clientId");
|
final Long clientId = rs.getLong("clientId");
|
||||||
@@ -123,8 +122,7 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
|||||||
final BigDecimal interestRate = rs.getBigDecimal("interestRate");
|
final BigDecimal interestRate = rs.getBigDecimal("interestRate");
|
||||||
final Long rescheduleReasonCvId = JdbcSupport.getLong(rs, "rescheduleReasonCvId");
|
final Long rescheduleReasonCvId = JdbcSupport.getLong(rs, "rescheduleReasonCvId");
|
||||||
final String rescheduleReasonCvValue = rs.getString("rescheduleReasonCvValue");
|
final String rescheduleReasonCvValue = rs.getString("rescheduleReasonCvValue");
|
||||||
final CodeValueData rescheduleReasonCodeValue = CodeValueData
|
final CodeValueData rescheduleReasonCodeValue = CodeValueData.instance(rescheduleReasonCvId, rescheduleReasonCvValue);
|
||||||
.instance(rescheduleReasonCvId, rescheduleReasonCvValue);
|
|
||||||
final String rescheduleReasonComment = rs.getString("rescheduleReasonComment");
|
final String rescheduleReasonComment = rs.getString("rescheduleReasonComment");
|
||||||
final Boolean recalculateInterest = rs.getBoolean("recalculateInterest");
|
final Boolean recalculateInterest = rs.getBoolean("recalculateInterest");
|
||||||
|
|
||||||
@@ -142,15 +140,14 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
|||||||
final String rejectedByUsername = rs.getString("rejectedByUsername");
|
final String rejectedByUsername = rs.getString("rejectedByUsername");
|
||||||
final String rejectedByFirstname = rs.getString("rejectedByFirstname");
|
final String rejectedByFirstname = rs.getString("rejectedByFirstname");
|
||||||
final String rejectedByLastname = rs.getString("rejectedByLastname");
|
final String rejectedByLastname = rs.getString("rejectedByLastname");
|
||||||
final Collection<CodeValueData> rescheduleReasons = null ;
|
final Collection<CodeValueData> rescheduleReasons = null;
|
||||||
final LoanRescheduleRequestTimelineData timeline = new LoanRescheduleRequestTimelineData(submittedOnDate,
|
final LoanRescheduleRequestTimelineData timeline = new LoanRescheduleRequestTimelineData(submittedOnDate, submittedByUsername,
|
||||||
submittedByUsername, submittedByFirstname, submittedByLastname, approvedOnDate, approvedByUsername,
|
submittedByFirstname, submittedByLastname, approvedOnDate, approvedByUsername, approvedByFirstname, approvedByLastname,
|
||||||
approvedByFirstname, approvedByLastname, rejectedOnDate, rejectedByUsername, rejectedByFirstname,
|
rejectedOnDate, rejectedByUsername, rejectedByFirstname, rejectedByLastname);
|
||||||
rejectedByLastname);
|
|
||||||
|
|
||||||
return LoanRescheduleRequestData.instance(id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal,
|
return LoanRescheduleRequestData.instance(id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal, graceOnInterest,
|
||||||
graceOnInterest, rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue,
|
rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue, rescheduleReasonComment,
|
||||||
rescheduleReasonComment, timeline, clientName, loanAccountNumber, clientId, recalculateInterest, rescheduleReasons);
|
timeline, clientName, loanAccountNumber, clientId, recalculateInterest, rescheduleReasons);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -159,9 +156,7 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
|||||||
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId) {
|
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId) {
|
||||||
final Loan loan = this.loanRepository.findOne(loanId);
|
final Loan loan = this.loanRepository.findOne(loanId);
|
||||||
|
|
||||||
if(loan == null) {
|
if (loan == null) { throw new LoanNotFoundException(loanId); }
|
||||||
throw new LoanNotFoundException(loanId);
|
|
||||||
}
|
|
||||||
|
|
||||||
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.loan_id = ?";
|
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.loan_id = ?";
|
||||||
|
|
||||||
@@ -177,7 +172,7 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
|||||||
return this.jdbcTemplate.queryForObject(sql, this.loanRescheduleRequestRowMapper, new Object[] { requestId });
|
return this.jdbcTemplate.queryForObject(sql, this.loanRescheduleRequestRowMapper, new Object[] { requestId });
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(final EmptyResultDataAccessException e) {
|
catch (final EmptyResultDataAccessException e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,12 +181,9 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
|||||||
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId, Integer statusEnum) {
|
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId, Integer statusEnum) {
|
||||||
final Loan loan = this.loanRepository.findOne(loanId);
|
final Loan loan = this.loanRepository.findOne(loanId);
|
||||||
|
|
||||||
if(loan == null) {
|
if (loan == null) { throw new LoanNotFoundException(loanId); }
|
||||||
throw new LoanNotFoundException(loanId);
|
|
||||||
}
|
|
||||||
|
|
||||||
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.loan_id = ?"
|
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.loan_id = ?" + " and lr.status_enum = ?";
|
||||||
+ " and lr.status_enum = ?";
|
|
||||||
|
|
||||||
return this.jdbcTemplate.query(sql, this.loanRescheduleRequestRowMapper, new Object[] { loanId, statusEnum });
|
return this.jdbcTemplate.query(sql, this.loanRescheduleRequestRowMapper, new Object[] { loanId, statusEnum });
|
||||||
}
|
}
|
||||||
@@ -200,9 +192,26 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
|
|||||||
public LoanRescheduleRequestData retrieveAllRescheduleReasons(String loanRescheduleReason) {
|
public LoanRescheduleRequestData retrieveAllRescheduleReasons(String loanRescheduleReason) {
|
||||||
final List<CodeValueData> rescheduleReasons = new ArrayList<>(
|
final List<CodeValueData> rescheduleReasons = new ArrayList<>(
|
||||||
this.codeValueReadPlatformService.retrieveCodeValuesByCode(loanRescheduleReason));
|
this.codeValueReadPlatformService.retrieveCodeValuesByCode(loanRescheduleReason));
|
||||||
|
final Long id = null;
|
||||||
|
final Long loanId = null;
|
||||||
|
final LoanRescheduleRequestStatusEnumData statusEnum = null;
|
||||||
|
final Integer rescheduleFromInstallment = null;
|
||||||
|
final Integer graceOnPrincipal = null;
|
||||||
|
final Integer graceOnInterest = null;
|
||||||
|
final LocalDate rescheduleFromDate = null;
|
||||||
|
final LocalDate adjustedDueDate = null;
|
||||||
|
final Integer extraTerms = null;
|
||||||
|
final BigDecimal interestRate = null;
|
||||||
|
final CodeValueData rescheduleReasonCodeValue = null;
|
||||||
|
final String rescheduleReasonComment = null;
|
||||||
|
final LoanRescheduleRequestTimelineData timeline = null;
|
||||||
|
final String clientName = null;
|
||||||
|
final String loanAccountNumber = null;
|
||||||
|
final Long clientId = null;
|
||||||
|
final Boolean recalculateInterest = null;
|
||||||
|
|
||||||
return LoanRescheduleRequestData.instance(null, null, null, null, null, null,
|
return LoanRescheduleRequestData.instance(id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal, graceOnInterest,
|
||||||
null, null, null, null, null, null,
|
rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue, rescheduleReasonComment,
|
||||||
null, null, null, null, null,rescheduleReasons);
|
timeline, clientName, loanAccountNumber, clientId, recalculateInterest, rescheduleReasons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user