Merge pull request #1502 from nazeer1100126/Mifosx_1523_-_Loan_Rescheduling
Mifosx 1523 loan rescheduling
This commit is contained in:
@@ -306,5 +306,4 @@ public class CommandWrapper {
|
|||||||
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL")
|
return this.actionName.equalsIgnoreCase("UPDATE") && this.entityName.equalsIgnoreCase("DISBURSEMENTDETAIL")
|
||||||
&& this.entityId == null;
|
&& this.entityId == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
-1
@@ -2457,5 +2457,4 @@ public class CommandWrapperBuilder {
|
|||||||
this.href = "/clients/" + clientId + "/transactions/" + transactionId + "?command=undo";
|
this.href = "/clients/" + clientId + "/transactions/" + transactionId + "?command=undo";
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+2
@@ -13,6 +13,8 @@ public class RescheduleLoansApiConstants {
|
|||||||
|
|
||||||
public final static String ENTITY_NAME = "RESCHEDULELOAN";
|
public final static String ENTITY_NAME = "RESCHEDULELOAN";
|
||||||
|
|
||||||
|
public static final String LOAN_RESCHEDULE_REASON = "LoanRescheduleReason";
|
||||||
|
|
||||||
// general
|
// general
|
||||||
public static final String localeParamName = "locale";
|
public static final String localeParamName = "locale";
|
||||||
public static final String dateFormatParamName = "dateFormat";
|
public static final String dateFormatParamName = "dateFormat";
|
||||||
|
|||||||
+24
-8
@@ -69,23 +69,39 @@ public class RescheduleLoansApiResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("{requestId}")
|
@Path("template")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String readLoanRescheduleRequest(@Context final UriInfo uriInfo, @PathParam("requestId") final Long requestId,
|
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;
|
||||||
|
loanRescheduleReasons = this.loanRescheduleRequestReadPlatformService
|
||||||
|
.retrieveAllRescheduleReasons(RescheduleLoansApiConstants.LOAN_RESCHEDULE_REASON);
|
||||||
|
|
||||||
|
return this.loanRescheduleRequestToApiJsonSerializer.serialize(settings, loanRescheduleReasons);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("{scheduleId}")
|
||||||
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
|
public String readLoanRescheduleRequest(@Context final UriInfo uriInfo, @PathParam("scheduleId") final Long scheduleId,
|
||||||
@QueryParam("command") final String command) {
|
@QueryParam("command") final String command) {
|
||||||
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());
|
||||||
|
|
||||||
if (compareIgnoreCase(command, "previewLoanReschedule")) {
|
if (compareIgnoreCase(command, "previewLoanReschedule")) {
|
||||||
final LoanRescheduleModel loanRescheduleModel = this.loanReschedulePreviewPlatformService.previewLoanReschedule(requestId);
|
final LoanRescheduleModel loanRescheduleModel = this.loanReschedulePreviewPlatformService.previewLoanReschedule(scheduleId);
|
||||||
|
|
||||||
return this.loanRescheduleToApiJsonSerializer.serialize(settings, loanRescheduleModel.toData(), new HashSet<String>());
|
return this.loanRescheduleToApiJsonSerializer.serialize(settings, loanRescheduleModel.toData(), new HashSet<String>());
|
||||||
}
|
}
|
||||||
|
|
||||||
final LoanRescheduleRequestData loanRescheduleRequestData = this.loanRescheduleRequestReadPlatformService
|
final LoanRescheduleRequestData loanRescheduleRequestData = this.loanRescheduleRequestReadPlatformService
|
||||||
.readLoanRescheduleRequest(requestId);
|
.readLoanRescheduleRequest(scheduleId);
|
||||||
|
|
||||||
return this.loanRescheduleRequestToApiJsonSerializer.serialize(settings, loanRescheduleRequestData);
|
return this.loanRescheduleRequestToApiJsonSerializer.serialize(settings, loanRescheduleRequestData);
|
||||||
}
|
}
|
||||||
@@ -103,20 +119,20 @@ public class RescheduleLoansApiResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{requestId}")
|
@Path("{scheduleId}")
|
||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String updateLoanRescheduleRequest(@PathParam("requestId") final Long requestId, @QueryParam("command") final String command,
|
public String updateLoanRescheduleRequest(@PathParam("scheduleId") final Long scheduleId, @QueryParam("command") final String command,
|
||||||
final String apiRequestBodyAsJson) {
|
final String apiRequestBodyAsJson) {
|
||||||
CommandWrapper commandWrapper = null;
|
CommandWrapper commandWrapper = null;
|
||||||
|
|
||||||
if (compareIgnoreCase(command, "approve")) {
|
if (compareIgnoreCase(command, "approve")) {
|
||||||
commandWrapper = new CommandWrapperBuilder().approveLoanRescheduleRequest(RescheduleLoansApiConstants.ENTITY_NAME, requestId)
|
commandWrapper = new CommandWrapperBuilder().approveLoanRescheduleRequest(RescheduleLoansApiConstants.ENTITY_NAME, scheduleId)
|
||||||
.withJson(apiRequestBodyAsJson).build();
|
.withJson(apiRequestBodyAsJson).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (compareIgnoreCase(command, "reject")) {
|
else if (compareIgnoreCase(command, "reject")) {
|
||||||
commandWrapper = new CommandWrapperBuilder().rejectLoanRescheduleRequest(RescheduleLoansApiConstants.ENTITY_NAME, requestId)
|
commandWrapper = new CommandWrapperBuilder().rejectLoanRescheduleRequest(RescheduleLoansApiConstants.ENTITY_NAME, scheduleId)
|
||||||
.withJson(apiRequestBodyAsJson).build();
|
.withJson(apiRequestBodyAsJson).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+164
-161
@@ -6,6 +6,7 @@
|
|||||||
package org.mifosplatform.portfolio.loanaccount.rescheduleloan.data;
|
package org.mifosplatform.portfolio.loanaccount.rescheduleloan.data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||||
@@ -15,188 +16,190 @@ import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
|||||||
**/
|
**/
|
||||||
public class LoanRescheduleRequestData {
|
public class LoanRescheduleRequestData {
|
||||||
|
|
||||||
private final Long id;
|
private final Long id;
|
||||||
private final Long loanId;
|
private final Long loanId;
|
||||||
private final Long clientId;
|
private final Long clientId;
|
||||||
private final String clientName;
|
private final String clientName;
|
||||||
private final String loanAccountNumber;
|
private final String loanAccountNumber;
|
||||||
private final LoanRescheduleRequestStatusEnumData statusEnum;
|
private final LoanRescheduleRequestStatusEnumData statusEnum;
|
||||||
private final Integer rescheduleFromInstallment;
|
private final Integer rescheduleFromInstallment;
|
||||||
private final Integer graceOnPrincipal;
|
private final Integer graceOnPrincipal;
|
||||||
private final Integer graceOnInterest;
|
private final Integer graceOnInterest;
|
||||||
private final LocalDate rescheduleFromDate;
|
private final LocalDate rescheduleFromDate;
|
||||||
private final Integer extraTerms;
|
private final Integer extraTerms;
|
||||||
private final BigDecimal interestRate;
|
private final BigDecimal interestRate;
|
||||||
private final Boolean recalculateInterest;
|
private final Boolean recalculateInterest;
|
||||||
private final CodeValueData rescheduleReasonCodeValue;
|
private final CodeValueData rescheduleReasonCodeValue;
|
||||||
private final LoanRescheduleRequestTimelineData timeline;
|
private final LoanRescheduleRequestTimelineData timeline;
|
||||||
private final String rescheduleReasonComment;
|
private final String rescheduleReasonComment;
|
||||||
private final LocalDate adjustedDueDate;
|
private final LocalDate adjustedDueDate;
|
||||||
|
private final Collection<CodeValueData> rescheduleReasons;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LoanRescheduleRequestData constructor
|
* LoanRescheduleRequestData constructor
|
||||||
**/
|
**/
|
||||||
private LoanRescheduleRequestData(Long id, Long loanId, LoanRescheduleRequestStatusEnumData statusEnum,
|
private LoanRescheduleRequestData(Long id, Long loanId, LoanRescheduleRequestStatusEnumData statusEnum,
|
||||||
Integer rescheduleFromInstallment, Integer graceOnPrincipal, Integer graceOnInterest,
|
Integer rescheduleFromInstallment, Integer graceOnPrincipal, Integer graceOnInterest, LocalDate rescheduleFromDate,
|
||||||
LocalDate rescheduleFromDate, LocalDate adjustedDueDate, Integer extraTerms, BigDecimal interestRate,
|
LocalDate adjustedDueDate, Integer extraTerms, BigDecimal interestRate, CodeValueData rescheduleReasonCodeValue,
|
||||||
CodeValueData rescheduleReasonCodeValue, String rescheduleReasonComment, LoanRescheduleRequestTimelineData timeline,
|
String rescheduleReasonComment, LoanRescheduleRequestTimelineData timeline, final String clientName,
|
||||||
final String clientName, final String loanAccountNumber, final Long clientId, final Boolean recalculateInterest) {
|
final String loanAccountNumber, final Long clientId, final Boolean recalculateInterest, Collection<CodeValueData> rescheduleReasons) {
|
||||||
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.loanId = loanId;
|
this.loanId = loanId;
|
||||||
this.statusEnum = statusEnum;
|
this.statusEnum = statusEnum;
|
||||||
this.rescheduleFromInstallment = rescheduleFromInstallment;
|
this.rescheduleFromInstallment = rescheduleFromInstallment;
|
||||||
this.graceOnPrincipal = graceOnPrincipal;
|
this.graceOnPrincipal = graceOnPrincipal;
|
||||||
this.graceOnInterest = graceOnInterest;
|
this.graceOnInterest = graceOnInterest;
|
||||||
this.rescheduleFromDate = rescheduleFromDate;
|
this.rescheduleFromDate = rescheduleFromDate;
|
||||||
this.extraTerms = extraTerms;
|
this.extraTerms = extraTerms;
|
||||||
this.interestRate = interestRate;
|
this.interestRate = interestRate;
|
||||||
this.rescheduleReasonCodeValue = rescheduleReasonCodeValue;
|
this.rescheduleReasonCodeValue = rescheduleReasonCodeValue;
|
||||||
this.rescheduleReasonComment = rescheduleReasonComment;
|
this.rescheduleReasonComment = rescheduleReasonComment;
|
||||||
this.adjustedDueDate = adjustedDueDate;
|
this.adjustedDueDate = adjustedDueDate;
|
||||||
this.timeline = timeline;
|
this.timeline = timeline;
|
||||||
this.clientName = clientName;
|
this.clientName = clientName;
|
||||||
this.loanAccountNumber = loanAccountNumber;
|
this.loanAccountNumber = loanAccountNumber;
|
||||||
this.clientId = clientId;
|
this.clientId = clientId;
|
||||||
this.recalculateInterest = recalculateInterest;
|
this.recalculateInterest = recalculateInterest;
|
||||||
}
|
this.rescheduleReasons = rescheduleReasons ;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return an instance of the LoanRescheduleRequestData class
|
* @return an instance of the LoanRescheduleRequestData class
|
||||||
**/
|
**/
|
||||||
public static LoanRescheduleRequestData instance(Long id, Long loanId, LoanRescheduleRequestStatusEnumData statusEnum,
|
public static LoanRescheduleRequestData instance(Long id, Long loanId, LoanRescheduleRequestStatusEnumData statusEnum,
|
||||||
Integer rescheduleFromInstallment, Integer graceOnPrincipal, Integer graceOnInterest,
|
Integer rescheduleFromInstallment, Integer graceOnPrincipal, Integer graceOnInterest, LocalDate rescheduleFromDate,
|
||||||
LocalDate rescheduleFromDate, LocalDate adjustedDueDate, Integer extraTerms, BigDecimal interestRate,
|
LocalDate adjustedDueDate, Integer extraTerms, BigDecimal interestRate, CodeValueData rescheduleReasonCodeValue,
|
||||||
CodeValueData rescheduleReasonCodeValue, String rescheduleReasonComment, LoanRescheduleRequestTimelineData timeline,
|
String rescheduleReasonComment, LoanRescheduleRequestTimelineData timeline, final String clientName,
|
||||||
final String clientName, final String loanAccountNumber, final Long clientId, final Boolean recalculateInterest) {
|
final String loanAccountNumber, final Long clientId, final Boolean recalculateInterest, Collection<CodeValueData> rescheduleReasons) {
|
||||||
|
|
||||||
return new LoanRescheduleRequestData(id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal, graceOnInterest,
|
return new LoanRescheduleRequestData(id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal, graceOnInterest,
|
||||||
rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue, rescheduleReasonComment,
|
rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue, rescheduleReasonComment,
|
||||||
timeline, clientName, loanAccountNumber, clientId, recalculateInterest);
|
timeline, clientName, loanAccountNumber, clientId, recalculateInterest, rescheduleReasons);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the id
|
* @return the id
|
||||||
*/
|
*/
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the loanId
|
* @return the loanId
|
||||||
*/
|
*/
|
||||||
public Long getLoanId() {
|
public Long getLoanId() {
|
||||||
return loanId;
|
return loanId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the statusEnum
|
* @return the statusEnum
|
||||||
*/
|
*/
|
||||||
public LoanRescheduleRequestStatusEnumData getStatusEnum() {
|
public LoanRescheduleRequestStatusEnumData getStatusEnum() {
|
||||||
return statusEnum;
|
return statusEnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the reschedule from installment number
|
* @return the reschedule from installment number
|
||||||
*/
|
*/
|
||||||
public Integer getRescheduleFromInstallment() {
|
public Integer getRescheduleFromInstallment() {
|
||||||
return rescheduleFromInstallment;
|
return rescheduleFromInstallment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the graceOnPrincipal
|
* @return the graceOnPrincipal
|
||||||
*/
|
*/
|
||||||
public Integer getGraceOnPrincipal() {
|
public Integer getGraceOnPrincipal() {
|
||||||
return graceOnPrincipal;
|
return graceOnPrincipal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the graceOnInterest
|
* @return the graceOnInterest
|
||||||
*/
|
*/
|
||||||
public Integer getGraceOnInterest() {
|
public Integer getGraceOnInterest() {
|
||||||
return graceOnInterest;
|
return graceOnInterest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the reschedule from date
|
* @return the reschedule from date
|
||||||
*/
|
*/
|
||||||
public LocalDate getRescheduleFromDate() {
|
public LocalDate getRescheduleFromDate() {
|
||||||
return rescheduleFromDate;
|
return rescheduleFromDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the extraTerms
|
* @return the extraTerms
|
||||||
*/
|
*/
|
||||||
public Integer getExtraTerms() {
|
public Integer getExtraTerms() {
|
||||||
return extraTerms;
|
return extraTerms;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the interestRate
|
* @return the interestRate
|
||||||
*/
|
*/
|
||||||
public BigDecimal getInterestRate() {
|
public BigDecimal getInterestRate() {
|
||||||
return interestRate;
|
return interestRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the rescheduleReasonCodeValueId
|
* @return the rescheduleReasonCodeValueId
|
||||||
*/
|
*/
|
||||||
public CodeValueData getRescheduleReasonCodeValueId() {
|
public CodeValueData getRescheduleReasonCodeValueId() {
|
||||||
return rescheduleReasonCodeValue;
|
return rescheduleReasonCodeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the rescheduleReasonText
|
* @return the rescheduleReasonText
|
||||||
*/
|
*/
|
||||||
public String getRescheduleReasonComment() {
|
public String getRescheduleReasonComment() {
|
||||||
return rescheduleReasonComment;
|
return rescheduleReasonComment;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the timeline
|
* @return the timeline
|
||||||
**/
|
**/
|
||||||
public LoanRescheduleRequestTimelineData getTimeline() {
|
public LoanRescheduleRequestTimelineData getTimeline() {
|
||||||
return this.timeline;
|
return this.timeline;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the adjustedDueDate
|
* @return the adjustedDueDate
|
||||||
*/
|
*/
|
||||||
public LocalDate getAdjustedDueDate() {
|
public LocalDate getAdjustedDueDate() {
|
||||||
return adjustedDueDate;
|
return adjustedDueDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the clientName
|
* @return the clientName
|
||||||
*/
|
*/
|
||||||
public String getClientName() {
|
public String getClientName() {
|
||||||
return clientName;
|
return clientName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the loanAccountNumber
|
* @return the loanAccountNumber
|
||||||
*/
|
*/
|
||||||
public String getLoanAccountNumber() {
|
public String getLoanAccountNumber() {
|
||||||
return loanAccountNumber;
|
return loanAccountNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the clientId
|
* @return the clientId
|
||||||
*/
|
*/
|
||||||
public Long getClientId() {
|
public Long getClientId() {
|
||||||
return clientId;
|
return clientId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the recalculateInterest
|
* @return the recalculateInterest
|
||||||
*/
|
*/
|
||||||
public Boolean getRecalculateInterest() {
|
public Boolean getRecalculateInterest() {
|
||||||
boolean value = false;
|
boolean value = false;
|
||||||
|
|
||||||
if(recalculateInterest != null) {
|
if (recalculateInterest != null) {
|
||||||
value = recalculateInterest;
|
value = recalculateInterest;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+33
-21
@@ -11,27 +11,39 @@ import org.mifosplatform.portfolio.loanaccount.rescheduleloan.data.LoanReschedul
|
|||||||
|
|
||||||
public interface LoanRescheduleRequestReadPlatformService {
|
public interface LoanRescheduleRequestReadPlatformService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all loan reschedule requests by loan ID
|
* get all loan reschedule requests by loan ID
|
||||||
*
|
*
|
||||||
* @param loanId the loan identifier
|
* @param loanId
|
||||||
* @return list of LoanRescheduleRequestData objects
|
* the loan identifier
|
||||||
**/
|
* @return list of LoanRescheduleRequestData objects
|
||||||
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId);
|
**/
|
||||||
|
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get a single loan reschedule request by ID (primary key)
|
* get a single loan reschedule request by ID (primary key)
|
||||||
*
|
*
|
||||||
* @param requestId the loan reschedule request identifier
|
* @param requestId
|
||||||
* @return a LoanRescheduleRequestData object
|
* the loan reschedule request identifier
|
||||||
**/
|
* @return a LoanRescheduleRequestData object
|
||||||
public LoanRescheduleRequestData readLoanRescheduleRequest(Long requestId);
|
**/
|
||||||
|
public LoanRescheduleRequestData readLoanRescheduleRequest(Long requestId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get all loan reschedule requests filter by loan ID and status enum
|
* get all loan reschedule requests filter by loan ID and status enum
|
||||||
*
|
*
|
||||||
* @param loanId the loan identifier
|
* @param loanId
|
||||||
* @return list of LoanRescheduleRequestData objects
|
* the loan identifier
|
||||||
**/
|
* @return list of LoanRescheduleRequestData objects
|
||||||
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId, Integer statusEnum);
|
**/
|
||||||
|
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId, Integer statusEnum);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get all loan reschedule reasons
|
||||||
|
*
|
||||||
|
* @param loanRescheduleReason
|
||||||
|
* the loan reschedule reason
|
||||||
|
* @return list of LoanRescheduleRequestData objects
|
||||||
|
**/
|
||||||
|
public LoanRescheduleRequestData retrieveAllRescheduleReasons(String loanRescheduleReason);
|
||||||
}
|
}
|
||||||
|
|||||||
+125
-101
@@ -8,10 +8,13 @@ package org.mifosplatform.portfolio.loanaccount.rescheduleloan.service;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.joda.time.LocalDate;
|
import org.joda.time.LocalDate;
|
||||||
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
import org.mifosplatform.infrastructure.codes.data.CodeValueData;
|
||||||
|
import org.mifosplatform.infrastructure.codes.service.CodeValueReadPlatformService;
|
||||||
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
import org.mifosplatform.infrastructure.core.domain.JdbcSupport;
|
||||||
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
import org.mifosplatform.infrastructure.core.service.RoutingDataSource;
|
||||||
import org.mifosplatform.portfolio.loanaccount.domain.Loan;
|
import org.mifosplatform.portfolio.loanaccount.domain.Loan;
|
||||||
@@ -30,82 +33,83 @@ import org.springframework.stereotype.Service;
|
|||||||
@Service
|
@Service
|
||||||
public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanRescheduleRequestReadPlatformService {
|
public class LoanRescheduleRequestReadPlatformServiceImpl implements LoanRescheduleRequestReadPlatformService {
|
||||||
|
|
||||||
private final JdbcTemplate jdbcTemplate;
|
private final JdbcTemplate jdbcTemplate;
|
||||||
private final LoanRepository loanRepository;
|
private final LoanRepository loanRepository;
|
||||||
private final LoanRescheduleRequestRowMapper loanRescheduleRequestRowMapper = new LoanRescheduleRequestRowMapper();
|
private final LoanRescheduleRequestRowMapper loanRescheduleRequestRowMapper = new LoanRescheduleRequestRowMapper();
|
||||||
|
private final CodeValueReadPlatformService codeValueReadPlatformService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public LoanRescheduleRequestReadPlatformServiceImpl(final RoutingDataSource dataSource,
|
public LoanRescheduleRequestReadPlatformServiceImpl(final RoutingDataSource dataSource, LoanRepository loanRepository,
|
||||||
LoanRepository loanRepository) {
|
final CodeValueReadPlatformService codeValueReadPlatformService) {
|
||||||
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
this.jdbcTemplate = new JdbcTemplate(dataSource);
|
||||||
this.loanRepository = loanRepository;
|
this.loanRepository = loanRepository;
|
||||||
}
|
this.codeValueReadPlatformService = codeValueReadPlatformService;
|
||||||
|
}
|
||||||
|
|
||||||
private static final class LoanRescheduleRequestRowMapper implements RowMapper<LoanRescheduleRequestData> {
|
private static final class LoanRescheduleRequestRowMapper implements RowMapper<LoanRescheduleRequestData> {
|
||||||
|
|
||||||
private final String schema;
|
private final String schema;
|
||||||
|
|
||||||
public LoanRescheduleRequestRowMapper() {
|
public LoanRescheduleRequestRowMapper() {
|
||||||
final StringBuilder sqlBuilder = new StringBuilder(200);
|
final StringBuilder sqlBuilder = new StringBuilder(200);
|
||||||
|
|
||||||
sqlBuilder.append("lr.id as id, lr.loan_id as loanId, lr.status_enum as statusEnum, ");
|
sqlBuilder.append("lr.id as id, lr.loan_id as loanId, lr.status_enum as statusEnum, ");
|
||||||
sqlBuilder.append("mc.display_name as clientName, ");
|
sqlBuilder.append("mc.display_name as clientName, ");
|
||||||
sqlBuilder.append("mc.id as clientId, ");
|
sqlBuilder.append("mc.id as clientId, ");
|
||||||
sqlBuilder.append("ml.account_no as loanAccountNumber, ");
|
sqlBuilder.append("ml.account_no as loanAccountNumber, ");
|
||||||
sqlBuilder.append("lr.reschedule_from_installment as rescheduleFromInstallment, ");
|
sqlBuilder.append("lr.reschedule_from_installment as rescheduleFromInstallment, ");
|
||||||
sqlBuilder.append("lr.grace_on_principal as graceOnPrincipal, ");
|
sqlBuilder.append("lr.grace_on_principal as graceOnPrincipal, ");
|
||||||
sqlBuilder.append("lr.grace_on_interest as graceOnInterest, ");
|
sqlBuilder.append("lr.grace_on_interest as graceOnInterest, ");
|
||||||
sqlBuilder.append("lr.reschedule_from_date as rescheduleFromDate, ");
|
sqlBuilder.append("lr.reschedule_from_date as rescheduleFromDate, ");
|
||||||
sqlBuilder.append("lr.adjusted_due_date as adjustedDueDate, ");
|
sqlBuilder.append("lr.adjusted_due_date as adjustedDueDate, ");
|
||||||
sqlBuilder.append("lr.extra_terms as extraTerms, ");
|
sqlBuilder.append("lr.extra_terms as extraTerms, ");
|
||||||
sqlBuilder.append("lr.recalculate_interest as recalculateInterest, ");
|
sqlBuilder.append("lr.recalculate_interest as recalculateInterest, ");
|
||||||
sqlBuilder.append("lr.interest_rate as interestRate, ");
|
sqlBuilder.append("lr.interest_rate as interestRate, ");
|
||||||
sqlBuilder.append("lr.reschedule_reason_cv_id as rescheduleReasonCvId, ");
|
sqlBuilder.append("lr.reschedule_reason_cv_id as rescheduleReasonCvId, ");
|
||||||
sqlBuilder.append("cv.code_value as rescheduleReasonCvValue, ");
|
sqlBuilder.append("cv.code_value as rescheduleReasonCvValue, ");
|
||||||
sqlBuilder.append("lr.reschedule_reason_comment as rescheduleReasonComment, ");
|
sqlBuilder.append("lr.reschedule_reason_comment as rescheduleReasonComment, ");
|
||||||
|
|
||||||
sqlBuilder.append("lr.submitted_on_date as submittedOnDate, ");
|
sqlBuilder.append("lr.submitted_on_date as submittedOnDate, ");
|
||||||
sqlBuilder.append("sbu.username as submittedByUsername, ");
|
sqlBuilder.append("sbu.username as submittedByUsername, ");
|
||||||
sqlBuilder.append("sbu.firstname as submittedByFirstname, ");
|
sqlBuilder.append("sbu.firstname as submittedByFirstname, ");
|
||||||
sqlBuilder.append("sbu.lastname as submittedByLastname, ");
|
sqlBuilder.append("sbu.lastname as submittedByLastname, ");
|
||||||
|
|
||||||
sqlBuilder.append("lr.approved_on_date as approvedOnDate, ");
|
sqlBuilder.append("lr.approved_on_date as approvedOnDate, ");
|
||||||
sqlBuilder.append("abu.username as approvedByUsername, ");
|
sqlBuilder.append("abu.username as approvedByUsername, ");
|
||||||
sqlBuilder.append("abu.firstname as approvedByFirstname, ");
|
sqlBuilder.append("abu.firstname as approvedByFirstname, ");
|
||||||
sqlBuilder.append("abu.lastname as approvedByLastname, ");
|
sqlBuilder.append("abu.lastname as approvedByLastname, ");
|
||||||
|
|
||||||
sqlBuilder.append("lr.rejected_on_date as rejectedOnDate, ");
|
sqlBuilder.append("lr.rejected_on_date as rejectedOnDate, ");
|
||||||
sqlBuilder.append("rbu.username as rejectedByUsername, ");
|
sqlBuilder.append("rbu.username as rejectedByUsername, ");
|
||||||
sqlBuilder.append("rbu.firstname as rejectedByFirstname, ");
|
sqlBuilder.append("rbu.firstname as rejectedByFirstname, ");
|
||||||
sqlBuilder.append("rbu.lastname as rejectedByLastname ");
|
sqlBuilder.append("rbu.lastname as rejectedByLastname ");
|
||||||
|
|
||||||
sqlBuilder.append("from " + loanRescheduleRequestTableName() + " lr ");
|
sqlBuilder.append("from " + loanRescheduleRequestTableName() + " lr ");
|
||||||
sqlBuilder.append("left join m_code_value cv on cv.id = lr.reschedule_reason_cv_id ");
|
sqlBuilder.append("left join m_code_value cv on cv.id = lr.reschedule_reason_cv_id ");
|
||||||
sqlBuilder.append("left join m_appuser sbu on sbu.id = lr.submitted_by_user_id ");
|
sqlBuilder.append("left join m_appuser sbu on sbu.id = lr.submitted_by_user_id ");
|
||||||
sqlBuilder.append("left join m_appuser abu on abu.id = lr.approved_by_user_id ");
|
sqlBuilder.append("left join m_appuser abu on abu.id = lr.approved_by_user_id ");
|
||||||
sqlBuilder.append("left join m_appuser rbu on rbu.id = lr.rejected_by_user_id ");
|
sqlBuilder.append("left join m_appuser rbu on rbu.id = lr.rejected_by_user_id ");
|
||||||
sqlBuilder.append("left join m_loan ml on ml.id = lr.loan_id ");
|
sqlBuilder.append("left join m_loan ml on ml.id = lr.loan_id ");
|
||||||
sqlBuilder.append("left join m_client mc on mc.id = ml.client_id ");
|
sqlBuilder.append("left join m_client mc on mc.id = ml.client_id ");
|
||||||
|
|
||||||
this.schema = sqlBuilder.toString();
|
this.schema = sqlBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String schema() {
|
public String schema() {
|
||||||
return this.schema;
|
return this.schema;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String loanRescheduleRequestTableName() {
|
public String loanRescheduleRequestTableName() {
|
||||||
return "m_loan_reschedule_request";
|
return "m_loan_reschedule_request";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public LoanRescheduleRequestData mapRow(final ResultSet rs, final int rowNum) throws SQLException {
|
public LoanRescheduleRequestData mapRow(final ResultSet rs, final int rowNum) throws SQLException {
|
||||||
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");
|
||||||
@@ -118,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");
|
||||||
|
|
||||||
@@ -137,57 +140,78 @@ 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 LoanRescheduleRequestTimelineData timeline = new LoanRescheduleRequestTimelineData(submittedOnDate, submittedByUsername,
|
||||||
|
submittedByFirstname, submittedByLastname, approvedOnDate, approvedByUsername, approvedByFirstname, approvedByLastname,
|
||||||
|
rejectedOnDate, rejectedByUsername, rejectedByFirstname, rejectedByLastname);
|
||||||
|
|
||||||
final LoanRescheduleRequestTimelineData timeline = new LoanRescheduleRequestTimelineData(submittedOnDate,
|
return LoanRescheduleRequestData.instance(id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal, graceOnInterest,
|
||||||
submittedByUsername, submittedByFirstname, submittedByLastname, approvedOnDate, approvedByUsername,
|
rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue, rescheduleReasonComment,
|
||||||
approvedByFirstname, approvedByLastname, rejectedOnDate, rejectedByUsername, rejectedByFirstname,
|
timeline, clientName, loanAccountNumber, clientId, recalculateInterest, rescheduleReasons);
|
||||||
rejectedByLastname);
|
|
||||||
|
|
||||||
return LoanRescheduleRequestData.instance(id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal,
|
|
||||||
graceOnInterest, rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue,
|
|
||||||
rescheduleReasonComment, timeline, clientName, loanAccountNumber, clientId, recalculateInterest);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId) {
|
|
||||||
final Loan loan = this.loanRepository.findOne(loanId);
|
|
||||||
|
|
||||||
if(loan == null) {
|
|
||||||
throw new LoanNotFoundException(loanId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.loan_id = ?";
|
}
|
||||||
|
|
||||||
return this.jdbcTemplate.query(sql, this.loanRescheduleRequestRowMapper, new Object[] { loanId });
|
@Override
|
||||||
}
|
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId) {
|
||||||
|
final Loan loan = this.loanRepository.findOne(loanId);
|
||||||
|
|
||||||
@Override
|
if (loan == null) { throw new LoanNotFoundException(loanId); }
|
||||||
public LoanRescheduleRequestData readLoanRescheduleRequest(Long requestId) {
|
|
||||||
|
|
||||||
try {
|
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.loan_id = ?";
|
||||||
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.id = ?";
|
|
||||||
|
|
||||||
return this.jdbcTemplate.queryForObject(sql, this.loanRescheduleRequestRowMapper, new Object[] { requestId });
|
return this.jdbcTemplate.query(sql, this.loanRescheduleRequestRowMapper, new Object[] { loanId });
|
||||||
}
|
}
|
||||||
|
|
||||||
catch(final EmptyResultDataAccessException e) {
|
@Override
|
||||||
return null;
|
public LoanRescheduleRequestData readLoanRescheduleRequest(Long requestId) {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
try {
|
||||||
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId, Integer statusEnum) {
|
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.id = ?";
|
||||||
final Loan loan = this.loanRepository.findOne(loanId);
|
|
||||||
|
|
||||||
if(loan == null) {
|
return this.jdbcTemplate.queryForObject(sql, this.loanRescheduleRequestRowMapper, new Object[] { requestId });
|
||||||
throw new LoanNotFoundException(loanId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final String sql = "select " + this.loanRescheduleRequestRowMapper.schema() + " where lr.loan_id = ?"
|
catch (final EmptyResultDataAccessException e) {
|
||||||
+ " and lr.status_enum = ?";
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return this.jdbcTemplate.query(sql, this.loanRescheduleRequestRowMapper, new Object[] { loanId, statusEnum });
|
@Override
|
||||||
}
|
public List<LoanRescheduleRequestData> readLoanRescheduleRequests(Long loanId, Integer statusEnum) {
|
||||||
|
final Loan loan = this.loanRepository.findOne(loanId);
|
||||||
|
|
||||||
|
if (loan == null) { throw new LoanNotFoundException(loanId); }
|
||||||
|
|
||||||
|
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 });
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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(id, loanId, statusEnum, rescheduleFromInstallment, graceOnPrincipal, graceOnInterest,
|
||||||
|
rescheduleFromDate, adjustedDueDate, extraTerms, interestRate, rescheduleReasonCodeValue, rescheduleReasonComment,
|
||||||
|
timeline, clientName, loanAccountNumber, clientId, recalculateInterest, rescheduleReasons);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user