Mifosx 1523 - Loan Rescheduling modification

This commit is contained in:
unknown
2015-09-15 12:37:18 +05:30
parent 928dbccfc4
commit f094d13058
2 changed files with 144 additions and 137 deletions
@@ -72,16 +72,14 @@ public class RescheduleLoansApiResource {
@Path("template")
@Consumes({ 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);
final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters());
LoanRescheduleRequestData loanRescheduleReasons = null;
if (compareIgnoreCase(commandParam, "rescheduleReason")) {
loanRescheduleReasons = this.loanRescheduleRequestReadPlatformService
.retrieveAllRescheduleReasons(RescheduleLoansApiConstants.LOAN_RESCHEDULE_REASON);
}
return this.loanRescheduleRequestToApiJsonSerializer.serialize(settings, loanRescheduleReasons);
}
@@ -39,11 +39,11 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
private final CodeValueReadPlatformService codeValueReadPlatformService;
@Autowired
public LoanRescheduleRequestReadPlatformServiceImpl(final RoutingDataSource dataSource,
LoanRepository loanRepository, final CodeValueReadPlatformService codeValueReadPlatformService) {
public LoanRescheduleRequestReadPlatformServiceImpl(final RoutingDataSource dataSource, LoanRepository loanRepository,
final CodeValueReadPlatformService codeValueReadPlatformService) {
this.jdbcTemplate = new JdbcTemplate(dataSource);
this.loanRepository = loanRepository;
this.codeValueReadPlatformService = codeValueReadPlatformService ;
this.codeValueReadPlatformService = codeValueReadPlatformService;
}
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 loanId = rs.getLong("loanId");
final Integer statusEnumId = JdbcSupport.getInteger(rs, "statusEnum");
final LoanRescheduleRequestStatusEnumData statusEnum = LoanRescheduleRequestEnumerations
.status(statusEnumId);
final LoanRescheduleRequestStatusEnumData statusEnum = LoanRescheduleRequestEnumerations.status(statusEnumId);
final String clientName = rs.getString("clientName");
final String loanAccountNumber = rs.getString("loanAccountNumber");
final Long clientId = rs.getLong("clientId");
@@ -123,8 +122,7 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
final BigDecimal interestRate = rs.getBigDecimal("interestRate");
final Long rescheduleReasonCvId = JdbcSupport.getLong(rs, "rescheduleReasonCvId");
final String rescheduleReasonCvValue = rs.getString("rescheduleReasonCvValue");
final CodeValueData rescheduleReasonCodeValue = CodeValueData
.instance(rescheduleReasonCvId, rescheduleReasonCvValue);
final CodeValueData rescheduleReasonCodeValue = CodeValueData.instance(rescheduleReasonCvId, rescheduleReasonCvValue);
final String rescheduleReasonComment = rs.getString("rescheduleReasonComment");
final Boolean recalculateInterest = rs.getBoolean("recalculateInterest");
@@ -142,15 +140,14 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
final String rejectedByUsername = rs.getString("rejectedByUsername");
final String rejectedByFirstname = rs.getString("rejectedByFirstname");
final String rejectedByLastname = rs.getString("rejectedByLastname");
final Collection<CodeValueData> rescheduleReasons = null ;
final LoanRescheduleRequestTimelineData timeline = new LoanRescheduleRequestTimelineData(submittedOnDate,
submittedByUsername, submittedByFirstname, submittedByLastname, approvedOnDate, approvedByUsername,
approvedByFirstname, approvedByLastname, rejectedOnDate, rejectedByUsername, rejectedByFirstname,
rejectedByLastname);
final Collection<CodeValueData> rescheduleReasons = null;
final LoanRescheduleRequestTimelineData timeline = new LoanRescheduleRequestTimelineData(submittedOnDate, submittedByUsername,
submittedByFirstname, submittedByLastname, approvedOnDate, approvedByUsername, approvedByFirstname, approvedByLastname,
rejectedOnDate, rejectedByUsername, rejectedByFirstname, rejectedByLastname);
return LoanRescheduleRequestData.instance(id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal,
graceOnInterest, rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue,
rescheduleReasonComment, timeline, clientName, loanAccountNumber, clientId, recalculateInterest, rescheduleReasons);
return LoanRescheduleRequestData.instance(id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal, graceOnInterest,
rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue, rescheduleReasonComment,
timeline, clientName, loanAccountNumber, clientId, recalculateInterest, rescheduleReasons);
}
}
@@ -159,9 +156,7 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId) {
final Loan loan = this.loanRepository.findOne(loanId);
if(loan == null) {
throw new LoanNotFoundException(loanId);
}
if (loan == null) { throw new LoanNotFoundException(loanId); }
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 });
}
catch(final EmptyResultDataAccessException e) {
catch (final EmptyResultDataAccessException e) {
return null;
}
}
@@ -186,12 +181,9 @@ public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanResched
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId, Integer statusEnum) {
final Loan loan = this.loanRepository.findOne(loanId);
if(loan == null) {
throw new LoanNotFoundException(loanId);
}
if (loan == null) { throw new LoanNotFoundException(loanId); }
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.loan_id = ?"
+ " and lr.status_enum = ?";
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.loan_id = ?" + " and lr.status_enum = ?";
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) {
final List<CodeValueData> rescheduleReasons = new ArrayList<>(
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,
null, null, null, null, null, null,
null, null, null, null, null,rescheduleReasons);
return LoanRescheduleRequestData.instance(id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal, graceOnInterest,
rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue, rescheduleReasonComment,
timeline, clientName, loanAccountNumber, clientId, recalculateInterest, rescheduleReasons);
}
}