Merge pull request #529 from apache/revert-526-create-and-approve-loan-on-batch-mode
Revert "FINERACT-684: Create and approve loan on batch mode "
This commit is contained in:
-48
@@ -19,7 +19,6 @@
|
|||||||
package org.apache.fineract.integrationtests;
|
package org.apache.fineract.integrationtests;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.fineract.batch.domain.BatchRequest;
|
import org.apache.fineract.batch.domain.BatchRequest;
|
||||||
@@ -423,51 +422,4 @@ public class BatchApiTest {
|
|||||||
Assert.assertEquals("Verify Status Code 200 for Approve Loan", 200L, (long) response.get(3).getStatusCode());
|
Assert.assertEquals("Verify Status Code 200 for Approve Loan", 200L, (long) response.get(3).getStatusCode());
|
||||||
Assert.assertEquals("Verify Status Code 200 for Disburse Loan", 200L, (long) response.get(4).getStatusCode());
|
Assert.assertEquals("Verify Status Code 200 for Disburse Loan", 200L, (long) response.get(4).getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Test for the successful create client, apply loan,approval and disbursal of a loan using
|
|
||||||
* Batch API with enclosingTransaction. A '200' status code is expected on successful activation.
|
|
||||||
*
|
|
||||||
* @see org.apache.fineract.batch.command.internal.ApproveLoanCommandStrategy
|
|
||||||
* @see org.apache.fineract.batch.command.internal.DisburseLoanCommandStrategy
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void shouldReturnOkStatusOnSuccessfulLoanApprovalAndDisburseWithTransaction(){
|
|
||||||
final String loanProductJSON = new LoanProductTestBuilder() //
|
|
||||||
.withPrincipal("10000000.00") //
|
|
||||||
.withNumberOfRepayments("24") //
|
|
||||||
.withRepaymentAfterEvery("1") //
|
|
||||||
.withRepaymentTypeAsMonth() //
|
|
||||||
.withinterestRatePerPeriod("2") //
|
|
||||||
.withInterestRateFrequencyTypeAsMonths() //
|
|
||||||
.withAmortizationTypeAsEqualPrincipalPayment() //
|
|
||||||
.withInterestTypeAsDecliningBalance() //
|
|
||||||
.currencyDetails("0", "100").build(null);
|
|
||||||
|
|
||||||
final Integer productId = new LoanTransactionHelper(this.requestSpec, this.responseSpec).getLoanProductId(loanProductJSON);
|
|
||||||
|
|
||||||
// Create a createClient Request
|
|
||||||
final BatchRequest br1 = BatchHelper.createActiveClientRequest(4740L, "");
|
|
||||||
|
|
||||||
// Create a ApplyLoan Request
|
|
||||||
final BatchRequest br2 = BatchHelper.applyLoanRequest(4742L, 4740L, productId);
|
|
||||||
|
|
||||||
// Create a approveLoan Request
|
|
||||||
final BatchRequest br3 = BatchHelper.approveLoanRequest(4743L, 4742L);
|
|
||||||
|
|
||||||
// Create a disburseLoan Request
|
|
||||||
final BatchRequest br4 = BatchHelper.disburseLoanRequest(4744L, 4743L);
|
|
||||||
|
|
||||||
final List<BatchRequest> batchRequests = Arrays.asList(br1,br2,br3,br4);
|
|
||||||
|
|
||||||
final String jsonifiedRequest = BatchHelper.toJsonString(batchRequests);
|
|
||||||
|
|
||||||
final List<BatchResponse> response = BatchHelper.postBatchRequestsWithEnclosingTransaction(this.requestSpec, this.responseSpec,
|
|
||||||
jsonifiedRequest);
|
|
||||||
|
|
||||||
Assert.assertEquals("Verify Status Code 200 for create client", 200L, (long) response.get(0).getStatusCode());
|
|
||||||
Assert.assertEquals("Verify Status Code 200 for apply Loan", 200L, (long) response.get(1).getStatusCode());
|
|
||||||
Assert.assertEquals("Verify Status Code 200 for approve Loan", 200L, (long) response.get(2).getStatusCode());
|
|
||||||
Assert.assertEquals("Verify Status Code 200 for disburse Loan", 200L, (long) response.get(3).getStatusCode());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
-24
@@ -155,30 +155,6 @@ public class BatchHelper {
|
|||||||
return br;
|
return br;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates and returns a
|
|
||||||
* {@link org.apache.fineract.batch.command.internal.CreateClientCommandStrategy}
|
|
||||||
* Request as one of the request in Batch.
|
|
||||||
*
|
|
||||||
* @param reqId
|
|
||||||
* @param externalId
|
|
||||||
* @return BatchRequest
|
|
||||||
*/
|
|
||||||
public static BatchRequest createActiveClientRequest(final Long requestId, final String externalId) {
|
|
||||||
|
|
||||||
final BatchRequest br = new BatchRequest();
|
|
||||||
br.setRequestId(requestId);
|
|
||||||
br.setRelativeUrl("clients");
|
|
||||||
br.setMethod("POST");
|
|
||||||
|
|
||||||
final String body = "{ \"officeId\": 1, \"firstname\": \"Petra\", \"lastname\": \"Yton\"," + "\"externalId\": " + externalId
|
|
||||||
+ ", \"dateFormat\": \"dd MMMM yyyy\", \"locale\": \"en\"," + "\"active\": true, \"activationDate\": \"04 March 2010\", \"submittedOnDate\": \"04 March 2010\"}";
|
|
||||||
|
|
||||||
br.setBody(body);
|
|
||||||
|
|
||||||
return br;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates and returns a
|
* Creates and returns a
|
||||||
* {@link org.apache.fineract.batch.command.internal.UpdateClientCommandStrategy}
|
* {@link org.apache.fineract.batch.command.internal.UpdateClientCommandStrategy}
|
||||||
|
|||||||
+8
-14
@@ -6497,20 +6497,14 @@ public class Loan extends AbstractPersistableCustom<Long> {
|
|||||||
return this.charges;
|
return this.charges;
|
||||||
}
|
}
|
||||||
public void initializeLazyCollections() {
|
public void initializeLazyCollections() {
|
||||||
checkAndFetchLazyCollection(this.charges);
|
this.charges.size() ;
|
||||||
checkAndFetchLazyCollection(this.trancheCharges);
|
this.trancheCharges.size() ;
|
||||||
checkAndFetchLazyCollection(this.repaymentScheduleInstallments);
|
this.repaymentScheduleInstallments.size() ;
|
||||||
checkAndFetchLazyCollection(this.loanTransactions);
|
this.loanTransactions.size() ;
|
||||||
checkAndFetchLazyCollection(this.disbursementDetails);
|
this.disbursementDetails.size() ;
|
||||||
checkAndFetchLazyCollection(this.loanTermVariations);
|
this.loanTermVariations.size() ;
|
||||||
checkAndFetchLazyCollection(this.collateral);
|
this.collateral.size() ;
|
||||||
checkAndFetchLazyCollection(this.loanOfficerHistory);
|
this.loanOfficerHistory.size() ;
|
||||||
}
|
|
||||||
|
|
||||||
private void checkAndFetchLazyCollection(Collection lazyCollection){
|
|
||||||
if (lazyCollection != null) {
|
|
||||||
lazyCollection.size();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initializeLoanOfficerHistory() {
|
public void initializeLoanOfficerHistory() {
|
||||||
|
|||||||
+1
-2
@@ -19,7 +19,6 @@
|
|||||||
package org.apache.fineract.portfolio.loanaccount.service;
|
package org.apache.fineract.portfolio.loanaccount.service;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -182,7 +181,7 @@ public class LoanAssembler {
|
|||||||
if (loanPurposeId != null) {
|
if (loanPurposeId != null) {
|
||||||
loanPurpose = this.codeValueRepository.findOneWithNotFoundDetection(loanPurposeId);
|
loanPurpose = this.codeValueRepository.findOneWithNotFoundDetection(loanPurposeId);
|
||||||
}
|
}
|
||||||
List<LoanDisbursementDetails> disbursementDetails = new ArrayList<>();
|
List<LoanDisbursementDetails> disbursementDetails = null;
|
||||||
BigDecimal fixedEmiAmount = null;
|
BigDecimal fixedEmiAmount = null;
|
||||||
if (loanProduct.isMultiDisburseLoan() || loanProduct.canDefineInstallmentAmount()) {
|
if (loanProduct.isMultiDisburseLoan() || loanProduct.canDefineInstallmentAmount()) {
|
||||||
fixedEmiAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, element);
|
fixedEmiAmount = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(LoanApiConstants.emiAmountParameterName, element);
|
||||||
|
|||||||
Reference in New Issue
Block a user