MIFOSX-1918 : API changes to add option for fetching pre-close detail based on date
This commit is contained in:
@@ -1052,6 +1052,14 @@
|
|||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>loans/{loanId}/transactions?command=prepayLoan</td>
|
||||||
|
<td><a href="#loans_transaction_pre_close_loan">Loan Pre-Closure transaction template</a></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
@@ -9531,7 +9539,39 @@ Request Body:
|
|||||||
</code>
|
</code>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<a id="loans_transaction_pre_close_loan" name="loans_transaction_pre_close_loan" class="old-syle-anchor"> </a>
|
||||||
|
<div class="method-section">
|
||||||
|
<div class="method-description">
|
||||||
|
<h4> Pre-Close template</h4>
|
||||||
|
<p>This Api retrieves pre closure details of loan</p>
|
||||||
|
</div>
|
||||||
|
<div class="method-example">
|
||||||
|
<code class="method-declaration">
|
||||||
|
POST https://DomainName/api/v1/loans/{loanId}/transactions?command=prepayLoan <b>or</b><br/>
|
||||||
|
|
||||||
|
https://DomainName/api/v1/loans/{loanId}/transactions?command=prepayLoan&dateFormat=dd+MMMM+yyyy&locale=en&transactionDate=02+April+2015
|
||||||
|
</code>
|
||||||
|
<code class="method-request">
|
||||||
|
POST loans/70/transactions?command=prepayLoan
|
||||||
|
Content-Type: application/json
|
||||||
|
Request Body:
|
||||||
|
{ }
|
||||||
|
</code>
|
||||||
|
<code class="method-response">
|
||||||
|
|
||||||
|
{
|
||||||
|
"amount":7765.28,
|
||||||
|
"principalPortion":7573.76,
|
||||||
|
"interestPortion":191.52,
|
||||||
|
"feeChargesPortion":0.00,
|
||||||
|
"penaltyChargesPortion":0.00
|
||||||
|
}
|
||||||
|
</code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<a id="loans_transaction_retrieve" name="loans_transaction_retrieve" class="old-syle-anchor"> </a>
|
<a id="loans_transaction_retrieve" name="loans_transaction_retrieve" class="old-syle-anchor"> </a>
|
||||||
<div class="method-section">
|
<div class="method-section">
|
||||||
<div class="method-description">
|
<div class="method-description">
|
||||||
|
|||||||
+12
-2
@@ -22,6 +22,8 @@ import javax.ws.rs.core.MediaType;
|
|||||||
import javax.ws.rs.core.UriInfo;
|
import javax.ws.rs.core.UriInfo;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.joda.time.LocalDate;
|
||||||
|
import org.mifosplatform.accounting.journalentry.api.DateParam;
|
||||||
import org.mifosplatform.commands.domain.CommandWrapper;
|
import org.mifosplatform.commands.domain.CommandWrapper;
|
||||||
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
import org.mifosplatform.commands.service.CommandWrapperBuilder;
|
||||||
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
import org.mifosplatform.commands.service.PortfolioCommandSourceWritePlatformService;
|
||||||
@@ -30,6 +32,7 @@ import org.mifosplatform.infrastructure.core.data.CommandProcessingResult;
|
|||||||
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
|
import org.mifosplatform.infrastructure.core.exception.UnrecognizedQueryParamException;
|
||||||
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
import org.mifosplatform.infrastructure.core.serialization.ApiRequestJsonSerializationSettings;
|
||||||
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
import org.mifosplatform.infrastructure.core.serialization.DefaultToApiJsonSerializer;
|
||||||
|
import org.mifosplatform.infrastructure.core.service.DateUtils;
|
||||||
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
import org.mifosplatform.infrastructure.security.service.PlatformSecurityContext;
|
||||||
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData;
|
import org.mifosplatform.portfolio.loanaccount.data.LoanTransactionData;
|
||||||
import org.mifosplatform.portfolio.loanaccount.service.LoanReadPlatformService;
|
import org.mifosplatform.portfolio.loanaccount.service.LoanReadPlatformService;
|
||||||
@@ -79,7 +82,8 @@ public class LoanTransactionsApiResource {
|
|||||||
@Consumes({ MediaType.APPLICATION_JSON })
|
@Consumes({ MediaType.APPLICATION_JSON })
|
||||||
@Produces({ MediaType.APPLICATION_JSON })
|
@Produces({ MediaType.APPLICATION_JSON })
|
||||||
public String retrieveTransactionTemplate(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam,
|
public String retrieveTransactionTemplate(@PathParam("loanId") final Long loanId, @QueryParam("command") final String commandParam,
|
||||||
@Context final UriInfo uriInfo) {
|
@Context final UriInfo uriInfo, @QueryParam("dateFormat") final String dateFormat,
|
||||||
|
@QueryParam("transactionDate") final DateParam transactionDateParam, @QueryParam("locale") final String locale) {
|
||||||
|
|
||||||
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
this.context.authenticatedUser().validateHasReadPermission(this.resourceNameForPermissions);
|
||||||
|
|
||||||
@@ -101,7 +105,13 @@ public class LoanTransactionsApiResource {
|
|||||||
} else if (is(commandParam, "recoverypayment")) {
|
} else if (is(commandParam, "recoverypayment")) {
|
||||||
transactionData = this.loanReadPlatformService.retrieveRecoveryPaymentTemplate(loanId);
|
transactionData = this.loanReadPlatformService.retrieveRecoveryPaymentTemplate(loanId);
|
||||||
} else if (is(commandParam, "prepayLoan")) {
|
} else if (is(commandParam, "prepayLoan")) {
|
||||||
transactionData = this.loanReadPlatformService.retrieveLoanPrePaymentTemplate(loanId);
|
LocalDate transactionDate = null;
|
||||||
|
if (transactionDateParam == null) {
|
||||||
|
transactionDate = DateUtils.getLocalDateOfTenant();
|
||||||
|
} else {
|
||||||
|
transactionDate = LocalDate.fromDateFields(transactionDateParam.getDate("transactionDate", dateFormat, locale));
|
||||||
|
}
|
||||||
|
transactionData = this.loanReadPlatformService.retrieveLoanPrePaymentTemplate(loanId, transactionDate);
|
||||||
} else if (is(commandParam, "refundbycash")) {
|
} else if (is(commandParam, "refundbycash")) {
|
||||||
transactionData = this.loanReadPlatformService.retrieveRefundByCashTemplate(loanId);
|
transactionData = this.loanReadPlatformService.retrieveRefundByCashTemplate(loanId);
|
||||||
} else if (is(commandParam, "refundbytransfer")) {
|
} else if (is(commandParam, "refundbytransfer")) {
|
||||||
|
|||||||
+2
-2
@@ -4737,7 +4737,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LoanRepaymentScheduleInstallment fetchPrepaymentDetail(final LoanScheduleGeneratorFactory loanScheduleFactory,
|
public LoanRepaymentScheduleInstallment fetchPrepaymentDetail(final LoanScheduleGeneratorFactory loanScheduleFactory,
|
||||||
CalendarInstance restCalendarInstance, HolidayDetailDTO holidayDetailDTO) {
|
CalendarInstance restCalendarInstance, HolidayDetailDTO holidayDetailDTO, LocalDate onDate) {
|
||||||
LoanRepaymentScheduleInstallment installment = null;
|
LoanRepaymentScheduleInstallment installment = null;
|
||||||
|
|
||||||
if (this.loanRepaymentScheduleDetail.isInterestRecalculationEnabled()) {
|
if (this.loanRepaymentScheduleDetail.isInterestRecalculationEnabled()) {
|
||||||
@@ -4790,7 +4790,7 @@ public class Loan extends AbstractPersistable<Long> {
|
|||||||
this.loanProduct.preCloseInterestCalculationStrategy());
|
this.loanProduct.preCloseInterestCalculationStrategy());
|
||||||
|
|
||||||
installment = loanScheduleGenerator.calculatePrepaymentAmount(this.repaymentScheduleInstallments, getCurrency(),
|
installment = loanScheduleGenerator.calculatePrepaymentAmount(this.repaymentScheduleInstallments, getCurrency(),
|
||||||
DateUtils.getLocalDateOfTenant(), loanApplicationTerms, mc, charges(), holidayDetailDTO);
|
onDate, loanApplicationTerms, mc, charges(), holidayDetailDTO);
|
||||||
} else {
|
} else {
|
||||||
installment = this.getTotalOutstandingOnLoan();
|
installment = this.getTotalOutstandingOnLoan();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -96,7 +96,7 @@ public interface LoanReadPlatformService {
|
|||||||
|
|
||||||
Collection<Long> fetchArrearLoans();
|
Collection<Long> fetchArrearLoans();
|
||||||
|
|
||||||
LoanTransactionData retrieveLoanPrePaymentTemplate(Long loanId);
|
LoanTransactionData retrieveLoanPrePaymentTemplate(Long loanId, LocalDate onDate);
|
||||||
|
|
||||||
Collection<LoanTransactionData> retrieveWaiverLoanTransactions(Long loanId);
|
Collection<LoanTransactionData> retrieveWaiverLoanTransactions(Long loanId);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -398,7 +398,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoanTransactionData retrieveLoanPrePaymentTemplate(final Long loanId) {
|
public LoanTransactionData retrieveLoanPrePaymentTemplate(final Long loanId, LocalDate onDate) {
|
||||||
|
|
||||||
this.context.authenticatedUser();
|
this.context.authenticatedUser();
|
||||||
|
|
||||||
@@ -425,7 +425,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = loan.fetchPrepaymentDetail(this.loanScheduleFactory,
|
final LoanRepaymentScheduleInstallment loanRepaymentScheduleInstallment = loan.fetchPrepaymentDetail(this.loanScheduleFactory,
|
||||||
restCalendarInstance, holidayDetailDTO);
|
restCalendarInstance, holidayDetailDTO, onDate);
|
||||||
final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.REPAYMENT);
|
final LoanTransactionEnumData transactionType = LoanEnumerations.transactionType(LoanTransactionType.REPAYMENT);
|
||||||
final Collection<PaymentTypeData> paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes();
|
final Collection<PaymentTypeData> paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes();
|
||||||
final BigDecimal outstandingLoanBalance = loanRepaymentScheduleInstallment.getPrincipalOutstanding(currency).getAmount();
|
final BigDecimal outstandingLoanBalance = loanRepaymentScheduleInstallment.getPrincipalOutstanding(currency).getAmount();
|
||||||
|
|||||||
Reference in New Issue
Block a user