merging chandrika's pull request for test cases
This commit is contained in:
+563
@@ -0,0 +1,563 @@
|
||||
package org.mifosplatform.integrationtests;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mifosplatform.integrationtests.common.ClientHelper;
|
||||
import org.mifosplatform.integrationtests.common.Utils;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanDisbursementTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanStatusChecker;
|
||||
import org.mifosplatform.integrationtests.common.loans.LoanTransactionHelper;
|
||||
|
||||
import com.jayway.restassured.builder.RequestSpecBuilder;
|
||||
import com.jayway.restassured.builder.ResponseSpecBuilder;
|
||||
import com.jayway.restassured.http.ContentType;
|
||||
import com.jayway.restassured.specification.RequestSpecification;
|
||||
import com.jayway.restassured.specification.ResponseSpecification;
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class LoanDisbursementDetailsIntegrationTest {
|
||||
|
||||
private ResponseSpecification responseSpec;
|
||||
private RequestSpecification requestSpec;
|
||||
private LoanTransactionHelper loanTransactionHelper;
|
||||
private Integer loanID;
|
||||
private Integer disbursementId;
|
||||
final String approveDate = "01 March 2014";
|
||||
final String expectedDisbursementDate = "01 March 2014";
|
||||
final String proposedAmount = "5000";
|
||||
final String approvalAmount = "5000";
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
Utils.initializeRESTAssured();
|
||||
this.requestSpec = new RequestSpecBuilder().setContentType(
|
||||
ContentType.JSON).build();
|
||||
this.requestSpec
|
||||
.header("Authorization",
|
||||
"Basic "
|
||||
+ Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
|
||||
this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200)
|
||||
.build();
|
||||
this.loanTransactionHelper = new LoanTransactionHelper(
|
||||
this.requestSpec, this.responseSpec);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createAndValidateMultiDisburseLoansBasedOnEmi() {
|
||||
List<HashMap> createTranches = new ArrayList<>();
|
||||
String id = null;
|
||||
String installmentAmount = "800";
|
||||
String withoutInstallmentAmount = "";
|
||||
String proposedAmount = "10000";
|
||||
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id,
|
||||
"01 June 2015", "5000"));
|
||||
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id,
|
||||
"01 Sep 2015", "5000"));
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec,
|
||||
this.responseSpec, "01 January 2014");
|
||||
System.out
|
||||
.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
|
||||
+ clientID);
|
||||
|
||||
final Integer loanProductID = this.loanTransactionHelper
|
||||
.getLoanProductId(new LoanProductTestBuilder()
|
||||
.withInterestTypeAsDecliningBalance()
|
||||
.withMoratorium("", "")
|
||||
.withAmortizationTypeAsEqualInstallments()
|
||||
.withTranches(true).build(null));
|
||||
System.out
|
||||
.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
|
||||
+ loanProductID);
|
||||
|
||||
final Integer loanIDWithEmi = applyForLoanApplicationWithEmiAmount(
|
||||
clientID, loanProductID, proposedAmount, createTranches,
|
||||
installmentAmount);
|
||||
|
||||
System.out
|
||||
.println("-----------------------------------LOAN CREATED WITH EMI LOANID-------------------------------------------------"
|
||||
+ loanIDWithEmi);
|
||||
|
||||
HashMap repaymentScheduleWithEmi = (HashMap) this.loanTransactionHelper
|
||||
.getLoanDetail(this.requestSpec, this.responseSpec,
|
||||
loanIDWithEmi, "repaymentSchedule");
|
||||
|
||||
ArrayList<HashMap> periods = (ArrayList<HashMap>) repaymentScheduleWithEmi
|
||||
.get("periods");
|
||||
assertEquals(periods.size(), 15);
|
||||
|
||||
this.validateRepaymentScheduleWithEMI(periods);
|
||||
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(
|
||||
this.requestSpec, this.responseSpec, loanIDWithEmi);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
System.out
|
||||
.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper
|
||||
.approveLoanWithApproveAmount("01 June 2015", "01 June 2015",
|
||||
"10000", loanIDWithEmi, createTranches);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
System.out
|
||||
.println("-----------------------------------MULTI DISBURSAL LOAN WITH EMI APPROVED SUCCESSFULLY---------------------------------------");
|
||||
|
||||
final Integer loanIDWithoutEmi = applyForLoanApplicationWithEmiAmount(
|
||||
clientID, loanProductID, proposedAmount, createTranches,
|
||||
withoutInstallmentAmount);
|
||||
|
||||
HashMap repaymentScheduleWithoutEmi = (HashMap) this.loanTransactionHelper
|
||||
.getLoanDetail(this.requestSpec, this.responseSpec,
|
||||
loanIDWithoutEmi, "repaymentSchedule");
|
||||
|
||||
ArrayList<HashMap> periods1 = (ArrayList<HashMap>) repaymentScheduleWithEmi
|
||||
.get("periods");
|
||||
assertEquals(periods1.size(), 15);
|
||||
|
||||
System.out
|
||||
.println("-----------------------------------LOAN CREATED WITHOUT EMI LOANID-------------------------------------------------"
|
||||
+ loanIDWithoutEmi);
|
||||
|
||||
/* To be uncommented once issue MIFOSX-2006 is closed. */
|
||||
// this.validateRepaymentScheduleWithoutEMI(periods1);
|
||||
|
||||
HashMap loanStatusMap = LoanStatusChecker.getStatusOfLoan(
|
||||
this.requestSpec, this.responseSpec, loanIDWithoutEmi);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusMap);
|
||||
|
||||
System.out
|
||||
.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper
|
||||
.approveLoanWithApproveAmount("01 June 2015", "01 June 2015",
|
||||
"10000", loanIDWithoutEmi, createTranches);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
System.out
|
||||
.println("-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
private void validateRepaymentScheduleWithEMI(ArrayList<HashMap> periods){
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule0 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 6, 1]", 0.0f, 0.0f, null, null, 5000.0f, null, null,
|
||||
null);
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule1 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 7, 1]", 800.0f, 800.0f, 50.0f, 750.0f, 4250.0f, 750.0f,
|
||||
750.0f, "[2015, 6, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule2 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 8, 1]", 800.0f, 800.0f, 42.5f, 757.5f, 3492.5f, 757.5f,
|
||||
757.5f, "[2015, 7, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule3 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 9, 1]", 0.0f, 0.0f, null, null, 5000.0f, null, null, null);
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule4 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 9, 1]", 800.0f, 800.0f, 34.92f, 765.08f, 7727.42f,
|
||||
765.08f, 765.08f, "[2015, 8, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule5 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 10, 1]", 800.0f, 800.0f, 77.27f, 722.73f, 7004.69f,
|
||||
722.73f, 722.73f, "[2015, 9, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule6 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 11, 1]", 800.0f, 800.0f, 70.05f, 729.95f, 6274.74f,
|
||||
729.95f, 729.95f, "[2015, 10, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule7 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 12, 1]", 800.0f, 800.0f, 62.75f, 737.25f, 5537.49f,
|
||||
737.25f, 737.25f, "[2015, 11, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule8 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 1, 1]", 800.0f, 800.0f, 55.37f, 744.63f, 4792.86f,
|
||||
744.63f, 744.63f, "[2015, 12, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule9 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 2, 1]", 800.0f, 800.0f, 47.93f, 752.07f, 4040.79f,
|
||||
752.07f, 752.07f, "[2016, 1, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule10 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 3, 1]", 800.0f, 800.0f, 40.41f, 759.59f, 3281.2f,
|
||||
759.59f, 759.59f, "[2016, 2, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule11 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 4, 1]", 800.0f, 800.0f, 32.81f, 767.19f, 2514.01f,
|
||||
767.19f, 767.19f, "[2016, 3, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule12 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 5, 1]", 800.0f, 800.0f, 25.14f, 774.86f, 1739.15f,
|
||||
774.86f, 774.86f, "[2016, 4, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule13 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 6, 1]", 800.0f, 800.0f, 17.39f, 782.61f, 956.54f,
|
||||
782.61f, 782.61f, "[2016, 5, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule14 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 7, 1]", 966.11f, 966.11f, 9.57f, 956.54f, 0.0f,
|
||||
956.54f, 956.54f, "[2016, 6, 1]");
|
||||
|
||||
ArrayList<LoanDisbursementTestBuilder> list = new ArrayList<LoanDisbursementTestBuilder>();
|
||||
list.add(expectedRepaymentSchedule0);
|
||||
list.add(expectedRepaymentSchedule1);
|
||||
list.add(expectedRepaymentSchedule2);
|
||||
list.add(expectedRepaymentSchedule3);
|
||||
list.add(expectedRepaymentSchedule4);
|
||||
list.add(expectedRepaymentSchedule5);
|
||||
list.add(expectedRepaymentSchedule6);
|
||||
list.add(expectedRepaymentSchedule7);
|
||||
list.add(expectedRepaymentSchedule8);
|
||||
list.add(expectedRepaymentSchedule9);
|
||||
list.add(expectedRepaymentSchedule10);
|
||||
list.add(expectedRepaymentSchedule11);
|
||||
list.add(expectedRepaymentSchedule12);
|
||||
list.add(expectedRepaymentSchedule13);
|
||||
list.add(expectedRepaymentSchedule14);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
this.assertRepaymentScheduleValuesWithEMI(periods.get(i), list.get(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertRepaymentScheduleValuesWithEMI(HashMap period,
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule, int position) {
|
||||
|
||||
assertEquals(period.get("dueDate").toString(),
|
||||
expectedRepaymentSchedule.getDueDate());
|
||||
assertEquals(period.get("principalLoanBalanceOutstanding"),
|
||||
expectedRepaymentSchedule.getPrincipalLoanBalanceOutstanding());
|
||||
assertEquals(period.get("totalOriginalDueForPeriod"),
|
||||
expectedRepaymentSchedule.getTotalOriginalDueForPeriod());
|
||||
assertEquals(period.get("totalOutstandingForPeriod"),
|
||||
expectedRepaymentSchedule.getTotalOutstandingForPeriod());
|
||||
|
||||
if (position != 0 && position != 3) {
|
||||
|
||||
assertEquals(period.get("interestOutstanding"),
|
||||
expectedRepaymentSchedule.getInterestOutstanding());
|
||||
assertEquals(period.get("principalOutstanding"),
|
||||
expectedRepaymentSchedule.getPrincipalOutstanding());
|
||||
assertEquals(period.get("principalDue"),
|
||||
expectedRepaymentSchedule.getPrincipalDue());
|
||||
assertEquals(period.get("principalOriginalDue"),
|
||||
expectedRepaymentSchedule.getPrincipalOriginalDue());
|
||||
assertEquals(period.get("fromDate").toString(),
|
||||
expectedRepaymentSchedule.getFromDate());
|
||||
}
|
||||
}
|
||||
|
||||
/* Uncomment and modify test builder values once MIFOSX-2006 is closed.*/
|
||||
/*private void validateRepaymentScheduleWithoutEMI(ArrayList<HashMap> periods){
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule0 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 6, 1]", 0.0f, 0.0f, null, null, 5000.0f, null, null,
|
||||
null);
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule1 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 7, 1]", 800.0f, 800.0f, 50.0f, 750.0f, 4250.0f, 750.0f,
|
||||
750.0f, "[2015, 6, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule2 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 8, 1]", 800.0f, 800.0f, 42.5f, 757.5f, 3492.5f, 757.5f,
|
||||
757.5f, "[2015, 7, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule3 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 9, 1]", 0.0f, 0.0f, null, null, 5000.0f, null, null, null);
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule4 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 9, 1]", 800.0f, 800.0f, 34.92f, 765.08f, 7727.42f,
|
||||
765.08f, 765.08f, "[2015, 8, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule5 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 10, 1]", 800.0f, 800.0f, 77.27f, 722.73f, 7004.69f,
|
||||
722.73f, 722.73f, "[2015, 9, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule6 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 11, 1]", 800.0f, 800.0f, 70.05f, 729.95f, 6274.74f,
|
||||
729.95f, 729.95f, "[2015, 10, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule7 = new LoanDisbursementTestBuilder(
|
||||
"[2015, 12, 1]", 800.0f, 800.0f, 62.75f, 737.25f, 5537.49f,
|
||||
737.25f, 737.25f, "[2015, 11, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule8 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 1, 1]", 800.0f, 800.0f, 55.37f, 744.63f, 4792.86f,
|
||||
744.63f, 744.63f, "[2015, 12, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule9 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 2, 1]", 800.0f, 800.0f, 47.93f, 752.07f, 4040.79f,
|
||||
752.07f, 752.07f, "[2016, 1, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule10 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 3, 1]", 800.0f, 800.0f, 40.41f, 759.59f, 3281.2f,
|
||||
759.59f, 759.59f, "[2016, 2, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule11 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 4, 1]", 800.0f, 800.0f, 32.81f, 767.19f, 2514.01f,
|
||||
767.19f, 767.19f, "[2016, 3, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule12 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 5, 1]", 800.0f, 800.0f, 25.14f, 774.86f, 1739.15f,
|
||||
774.86f, 774.86f, "[2016, 4, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule13 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 6, 1]", 800.0f, 800.0f, 17.39f, 782.61f, 956.54f,
|
||||
782.61f, 782.61f, "[2016, 5, 1]");
|
||||
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule14 = new LoanDisbursementTestBuilder(
|
||||
"[2016, 7, 1]", 966.11f, 966.11f, 9.57f, 956.54f, 0.0f,
|
||||
956.54f, 956.54f, "[2016, 6, 1]");
|
||||
|
||||
ArrayList<LoanDisbursementTestBuilder> list = new ArrayList<LoanDisbursementTestBuilder>();
|
||||
list.add(expectedRepaymentSchedule0);
|
||||
list.add(expectedRepaymentSchedule1);
|
||||
list.add(expectedRepaymentSchedule2);
|
||||
list.add(expectedRepaymentSchedule3);
|
||||
list.add(expectedRepaymentSchedule4);
|
||||
list.add(expectedRepaymentSchedule5);
|
||||
list.add(expectedRepaymentSchedule6);
|
||||
list.add(expectedRepaymentSchedule7);
|
||||
list.add(expectedRepaymentSchedule8);
|
||||
list.add(expectedRepaymentSchedule9);
|
||||
list.add(expectedRepaymentSchedule10);
|
||||
list.add(expectedRepaymentSchedule11);
|
||||
list.add(expectedRepaymentSchedule12);
|
||||
list.add(expectedRepaymentSchedule13);
|
||||
list.add(expectedRepaymentSchedule14);
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
this.assertRepaymentScheduleValuesWithoutEMI(periods.get(i), list.get(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
private void assertRepaymentScheduleValuesWithoutEMI(HashMap period,
|
||||
LoanDisbursementTestBuilder expectedRepaymentSchedule, int position) {
|
||||
|
||||
assertEquals(period.get("dueDate").toString(),
|
||||
expectedRepaymentSchedule.getDueDate());
|
||||
assertEquals(period.get("principalLoanBalanceOutstanding"),
|
||||
expectedRepaymentSchedule.getPrincipalLoanBalanceOutstanding());
|
||||
assertEquals(period.get("totalOriginalDueForPeriod"),
|
||||
expectedRepaymentSchedule.getTotalOriginalDueForPeriod());
|
||||
assertEquals(period.get("totalOutstandingForPeriod"),
|
||||
expectedRepaymentSchedule.getTotalOutstandingForPeriod());
|
||||
|
||||
if (position != 0 && position != 3) {
|
||||
|
||||
assertEquals(period.get("interestOutstanding"),
|
||||
expectedRepaymentSchedule.getInterestOutstanding());
|
||||
assertEquals(period.get("principalOutstanding"),
|
||||
expectedRepaymentSchedule.getPrincipalOutstanding());
|
||||
assertEquals(period.get("principalDue"),
|
||||
expectedRepaymentSchedule.getPrincipalDue());
|
||||
assertEquals(period.get("principalOriginalDue"),
|
||||
expectedRepaymentSchedule.getPrincipalOriginalDue());
|
||||
assertEquals(period.get("fromDate").toString(),
|
||||
expectedRepaymentSchedule.getFromDate());
|
||||
}
|
||||
}
|
||||
*/
|
||||
private Integer applyForLoanApplicationWithEmiAmount(
|
||||
final Integer clientID, final Integer loanProductID,
|
||||
final String proposedAmount, List<HashMap> tranches,
|
||||
final String installmentAmount) {
|
||||
|
||||
System.out
|
||||
.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder()
|
||||
//
|
||||
.withPrincipal(proposedAmount)
|
||||
//
|
||||
.withLoanTermFrequency("12")
|
||||
//
|
||||
.withLoanTermFrequencyAsMonths()
|
||||
//
|
||||
.withNumberOfRepayments("12").withRepaymentEveryAfter("1")
|
||||
.withRepaymentFrequencyTypeAsMonths() //
|
||||
.withInterestRatePerPeriod("1") //
|
||||
.withExpectedDisbursementDate("01 June 2015") //
|
||||
.withTranches(tranches) //
|
||||
.withFixedEmiAmount(installmentAmount) //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.withSubmittedOnDate("01 June 2015") //
|
||||
.withAmortizationTypeAsEqualInstallments() //
|
||||
.build(clientID.toString(), loanProductID.toString(), null);
|
||||
|
||||
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createApproveAndValidateMultiDisburseLoan() {
|
||||
|
||||
List<HashMap> createTranches = new ArrayList<>();
|
||||
String id = null;
|
||||
createTranches.add(this.loanTransactionHelper.createTrancheDetail(id,
|
||||
"01 March 2014", "1000"));
|
||||
|
||||
final Integer clientID = ClientHelper.createClient(this.requestSpec,
|
||||
this.responseSpec, "01 January 2014");
|
||||
System.out
|
||||
.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
|
||||
+ clientID);
|
||||
|
||||
final Integer loanProductID = this.loanTransactionHelper
|
||||
.getLoanProductId(new LoanProductTestBuilder()
|
||||
.withInterestTypeAsDecliningBalance()
|
||||
.withTranches(true).build(null));
|
||||
System.out
|
||||
.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
|
||||
+ loanProductID);
|
||||
|
||||
this.loanID = applyForLoanApplicationWithTranches(clientID,
|
||||
loanProductID, proposedAmount, createTranches);
|
||||
System.out
|
||||
.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------"
|
||||
+ loanID);
|
||||
|
||||
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(
|
||||
this.requestSpec, this.responseSpec, loanID);
|
||||
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
|
||||
|
||||
System.out
|
||||
.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
|
||||
loanStatusHashMap = this.loanTransactionHelper
|
||||
.approveLoanWithApproveAmount(approveDate,
|
||||
expectedDisbursementDate, approvalAmount, loanID,
|
||||
createTranches);
|
||||
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
|
||||
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
|
||||
System.out
|
||||
.println("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
|
||||
ArrayList<HashMap> disbursementDetails = (ArrayList<HashMap>) this.loanTransactionHelper
|
||||
.getLoanDetail(this.requestSpec, this.responseSpec,
|
||||
this.loanID, "disbursementDetails");
|
||||
this.disbursementId = (Integer) disbursementDetails.get(0).get("id");
|
||||
this.editLoanDisbursementDetails();
|
||||
}
|
||||
|
||||
private void editLoanDisbursementDetails() {
|
||||
this.editDateAndPrincipalOfExistingTranche();
|
||||
this.addNewDisbursementDetails();
|
||||
this.deleteDisbursmentDetails();
|
||||
}
|
||||
|
||||
private void addNewDisbursementDetails() {
|
||||
List<HashMap> addTranches = new ArrayList<>();
|
||||
ArrayList<HashMap> disbursementDetails = (ArrayList<HashMap>) this.loanTransactionHelper
|
||||
.getLoanDetail(this.requestSpec, this.responseSpec,
|
||||
this.loanID, "disbursementDetails");
|
||||
ArrayList expectedDisbursementDate = (ArrayList) disbursementDetails
|
||||
.get(0).get("expectedDisbursementDate");
|
||||
String date = formatExpectedDisbursementDate(expectedDisbursementDate
|
||||
.toString());
|
||||
|
||||
String id = null;
|
||||
addTranches.add(this.loanTransactionHelper.createTrancheDetail(
|
||||
disbursementDetails.get(0).get("id").toString(), date,
|
||||
disbursementDetails.get(0).get("principal").toString()));
|
||||
addTranches.add(this.loanTransactionHelper.createTrancheDetail(id,
|
||||
"3 March 2014", "2000"));
|
||||
addTranches.add(this.loanTransactionHelper.createTrancheDetail(id,
|
||||
"4 March 2014", "500"));
|
||||
|
||||
/* Add disbursement detail */
|
||||
this.loanTransactionHelper.addAndDeleteDisbursementDetail(this.loanID,
|
||||
this.approvalAmount, this.expectedDisbursementDate,
|
||||
addTranches, "");
|
||||
}
|
||||
|
||||
private void deleteDisbursmentDetails() {
|
||||
List<HashMap> deleteTranches = new ArrayList<>();
|
||||
ArrayList<HashMap> disbursementDetails = (ArrayList<HashMap>) this.loanTransactionHelper
|
||||
.getLoanDetail(this.requestSpec, this.responseSpec,
|
||||
this.loanID, "disbursementDetails");
|
||||
/* Delete the last tranche */
|
||||
for (int i = 0; i < disbursementDetails.size() - 1; i++) {
|
||||
ArrayList expectedDisbursementDate = (ArrayList) disbursementDetails
|
||||
.get(i).get("expectedDisbursementDate");
|
||||
String disbursementDate = formatExpectedDisbursementDate(expectedDisbursementDate
|
||||
.toString());
|
||||
deleteTranches.add(this.loanTransactionHelper.createTrancheDetail(
|
||||
disbursementDetails.get(i).get("id").toString(),
|
||||
disbursementDate,
|
||||
disbursementDetails.get(i).get("principal").toString()));
|
||||
}
|
||||
|
||||
/* Add disbursement detail */
|
||||
this.loanTransactionHelper.addAndDeleteDisbursementDetail(this.loanID,
|
||||
this.approvalAmount, this.expectedDisbursementDate,
|
||||
deleteTranches, "");
|
||||
}
|
||||
|
||||
private void editDateAndPrincipalOfExistingTranche() {
|
||||
String updatedExpectedDisbursementDate = "01 March 2014";
|
||||
String updatedPrincipal = "900";
|
||||
/* Update */
|
||||
this.loanTransactionHelper.editDisbursementDetail(this.loanID,
|
||||
this.disbursementId, this.approvalAmount,
|
||||
this.expectedDisbursementDate, updatedExpectedDisbursementDate,
|
||||
updatedPrincipal, "");
|
||||
/* Validate Edit */
|
||||
ArrayList<HashMap> disbursementDetails = (ArrayList<HashMap>) this.loanTransactionHelper
|
||||
.getLoanDetail(this.requestSpec, this.responseSpec,
|
||||
this.loanID, "disbursementDetails");
|
||||
assertEquals(Float.valueOf(updatedPrincipal), disbursementDetails
|
||||
.get(0).get("principal"));
|
||||
ArrayList expectedDisbursementDate = (ArrayList) disbursementDetails
|
||||
.get(0).get("expectedDisbursementDate");
|
||||
String date = formatExpectedDisbursementDate(expectedDisbursementDate
|
||||
.toString());
|
||||
assertEquals(updatedExpectedDisbursementDate, date);
|
||||
|
||||
}
|
||||
|
||||
private String formatExpectedDisbursementDate(
|
||||
String expectedDisbursementDate) {
|
||||
|
||||
SimpleDateFormat source = new SimpleDateFormat("[yyyy, MM, dd]");
|
||||
SimpleDateFormat target = new SimpleDateFormat("dd MMMM yyyy");
|
||||
String date = null;
|
||||
try {
|
||||
date = target.format(source.parse(expectedDisbursementDate));
|
||||
} catch (ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
private Integer applyForLoanApplicationWithTranches(final Integer clientID,
|
||||
final Integer loanProductID, String principal,
|
||||
List<HashMap> tranches) {
|
||||
System.out
|
||||
.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
|
||||
final String loanApplicationJSON = new LoanApplicationTestBuilder()
|
||||
//
|
||||
.withPrincipal(principal)
|
||||
//
|
||||
.withLoanTermFrequency("5")
|
||||
//
|
||||
.withLoanTermFrequencyAsMonths()
|
||||
//
|
||||
.withNumberOfRepayments("5").withRepaymentEveryAfter("1")
|
||||
.withRepaymentFrequencyTypeAsMonths() //
|
||||
.withInterestRatePerPeriod("2") //
|
||||
.withExpectedDisbursementDate("01 March 2014") //
|
||||
.withTranches(tranches) //
|
||||
.withInterestTypeAsDecliningBalance() //
|
||||
.withSubmittedOnDate("01 March 2014") //
|
||||
.build(clientID.toString(), loanProductID.toString(), null);
|
||||
|
||||
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
|
||||
}
|
||||
|
||||
}
|
||||
+7
-1
@@ -44,8 +44,10 @@ public class LoanApplicationTestBuilder {
|
||||
private String maxOutstandingLoanBalance = "36000";
|
||||
private String graceOnPrincipalPayment = null;
|
||||
private String graceOnInterestPayment = null;
|
||||
@SuppressWarnings("rawtypes")
|
||||
private List<HashMap> disbursementData = null;
|
||||
private List<HashMap> charges = new ArrayList<HashMap>();
|
||||
@SuppressWarnings("rawtypes")
|
||||
private List<HashMap> charges = new ArrayList<>();
|
||||
private String recalculationRestFrequencyDate = null;
|
||||
private String recalculationCompoundingFrequencyDate = null;
|
||||
private String repaymentsStartingFromDate = null;
|
||||
@@ -308,4 +310,8 @@ public class LoanApplicationTestBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
public LoanApplicationTestBuilder withFixedEmiAmount(final String installmentAmount) {
|
||||
this.fixedEmiAmount = installmentAmount;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package org.mifosplatform.integrationtests.common.loans;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class LoanDisbursementTestBuilder {
|
||||
|
||||
String dueDate = null;
|
||||
Float totalOriginalDueForPeriod = null;
|
||||
Float totalOutstandingForPeriod = null;
|
||||
Float interestOutstanding = null;
|
||||
Float principalOutstanding = null;
|
||||
Float principalLoanBalanceOutstanding = null;
|
||||
Float principalDue = null;
|
||||
Float principalOriginalDue = null;
|
||||
String fromDate = null;
|
||||
|
||||
public LoanDisbursementTestBuilder(String dueDate,Float totalOriginalDueForPeriod,Float totalOutstandingForPeriod,
|
||||
Float interestOutstanding, Float principalOutstanding, Float principalLoanBalanceOutstanding, Float principalDue,
|
||||
Float principalOriginalDue, String fromDate) {
|
||||
this.dueDate = dueDate;
|
||||
this.totalOriginalDueForPeriod = totalOriginalDueForPeriod;
|
||||
this.totalOutstandingForPeriod = totalOutstandingForPeriod;
|
||||
this.interestOutstanding = interestOutstanding;
|
||||
this.principalOutstanding = principalOutstanding;
|
||||
this.principalLoanBalanceOutstanding = principalLoanBalanceOutstanding;
|
||||
this.principalDue = principalDue;
|
||||
this.principalOriginalDue = principalOriginalDue;
|
||||
this.fromDate = fromDate;
|
||||
}
|
||||
|
||||
public String getDueDate() {
|
||||
return this.dueDate;
|
||||
}
|
||||
|
||||
public Float getTotalOriginalDueForPeriod() {
|
||||
return this.totalOriginalDueForPeriod;
|
||||
}
|
||||
|
||||
public Float getTotalOutstandingForPeriod() {
|
||||
return this.totalOutstandingForPeriod;
|
||||
}
|
||||
|
||||
public Float getInterestOutstanding() {
|
||||
return this.interestOutstanding;
|
||||
}
|
||||
|
||||
public Float getPrincipalOutstanding() {
|
||||
return this.principalOutstanding;
|
||||
}
|
||||
|
||||
public Float getPrincipalLoanBalanceOutstanding() {
|
||||
return this.principalLoanBalanceOutstanding;
|
||||
}
|
||||
|
||||
public Float getPrincipalDue() {
|
||||
return this.principalDue;
|
||||
}
|
||||
|
||||
public Float getPrincipalOriginalDue() {
|
||||
return this.principalOriginalDue;
|
||||
}
|
||||
|
||||
public String getFromDate() {
|
||||
return this.fromDate;
|
||||
}
|
||||
|
||||
/*public HashMap<String, String> build(String dueDate,String totalOriginalDueForPeriod,String totalOutstandingForPeriod,
|
||||
String interestOutstanding, String principalOutstanding, String principalLoanBalanceOutstanding, String principalDue,
|
||||
String principalOriginalDue, String fromDate) {
|
||||
HashMap<String, String> expectedRepaymentSchedule = new HashMap<String, String>();
|
||||
expectedRepaymentSchedule.put("dueDate", dueDate);
|
||||
expectedRepaymentSchedule.put("totalOriginalDueForPeriod",
|
||||
totalOriginalDueForPeriod);
|
||||
expectedRepaymentSchedule.put("totalOutstandingForPeriod",
|
||||
totalOutstandingForPeriod);
|
||||
expectedRepaymentSchedule.put("interestOutstanding", interestOutstanding);
|
||||
expectedRepaymentSchedule.put("principalOutstanding",
|
||||
principalOutstanding);
|
||||
expectedRepaymentSchedule.put("principalLoanBalanceOutstanding",
|
||||
principalLoanBalanceOutstanding);
|
||||
expectedRepaymentSchedule.put("principalDue", principalDue);
|
||||
expectedRepaymentSchedule.put("principalOriginalDue",
|
||||
principalOriginalDue);
|
||||
expectedRepaymentSchedule.put("fromDate", fromDate);
|
||||
|
||||
return expectedRepaymentSchedule;
|
||||
}*/
|
||||
}
|
||||
+60
@@ -538,4 +538,64 @@ public class LoanTransactionHelper {
|
||||
map.put("locale", "en");
|
||||
return new Gson().toJson(map);
|
||||
}
|
||||
|
||||
public HashMap createTrancheDetail(final String id, final String date, final String amount) {
|
||||
HashMap<String, Object> detail = new HashMap<>();
|
||||
if(id != null){
|
||||
detail.put("id", id);
|
||||
}
|
||||
detail.put("expectedDisbursementDate", date);
|
||||
detail.put("principal", amount);
|
||||
|
||||
return detail;
|
||||
}
|
||||
|
||||
public Object editDisbursementDetail(final Integer loanID, final Integer disbursementId, final String approvalAmount, final String expectedDisbursementDate,
|
||||
final String updatedExpectedDisbursementDate, final String updatedPrincipal, final String jsonAttributeToGetBack) {
|
||||
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, createEditDisbursementURL(loanID, disbursementId), getEditDisbursementsAsJSON(approvalAmount, expectedDisbursementDate,
|
||||
updatedExpectedDisbursementDate, updatedPrincipal), jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
public Object addAndDeleteDisbursementDetail(final Integer loanID, final String approvalAmount, final String expectedDisbursementDate
|
||||
, List<HashMap> disbursementData, final String jsonAttributeToGetBack) {
|
||||
|
||||
return Utils.performServerPut(this.requestSpec, this.responseSpec, createAddAndDeleteDisbursementURL(loanID),
|
||||
getAddAndDeleteDisbursementsAsJSON(approvalAmount, expectedDisbursementDate, disbursementData), jsonAttributeToGetBack);
|
||||
}
|
||||
|
||||
private String createEditDisbursementURL(Integer loanID, Integer disbursementId) {
|
||||
return "/mifosng-provider/api/v1/loans/" + loanID + "/disbursements/" + disbursementId + "?" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
private String createAddAndDeleteDisbursementURL(Integer loanID) {
|
||||
return "/mifosng-provider/api/v1/loans/" + loanID + "/disbursements/editDisbursements?" + Utils.TENANT_IDENTIFIER;
|
||||
}
|
||||
|
||||
public static String getEditDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate,
|
||||
final String updatedExpectedDisbursementDate, final String updatedPrincipal) {
|
||||
final HashMap<String, String> map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("approvedLoanAmount", approvalAmount);
|
||||
map.put("expectedDisbursementDate", expectedDisbursementDate);
|
||||
map.put("updatedExpectedDisbursementDate", updatedExpectedDisbursementDate);
|
||||
map.put("updatedPrincipal", updatedPrincipal);
|
||||
String json = new Gson().toJson(map);
|
||||
System.out.println(json);
|
||||
return json;
|
||||
}
|
||||
|
||||
public static String getAddAndDeleteDisbursementsAsJSON(final String approvalAmount, final String expectedDisbursementDate,
|
||||
final List<HashMap> disbursementData) {
|
||||
final HashMap map = new HashMap<>();
|
||||
map.put("locale", "en");
|
||||
map.put("dateFormat", "dd MMMM yyyy");
|
||||
map.put("approvedLoanAmount", approvalAmount);
|
||||
map.put("expectedDisbursementDate", expectedDisbursementDate);
|
||||
map.put("disbursementData", disbursementData);
|
||||
String json = new Gson().toJson(map);
|
||||
System.out.println(json);
|
||||
return json;
|
||||
}
|
||||
}
|
||||
+95
-119
@@ -197,8 +197,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
sqlBuilder.append(" left join m_office transferToOffice on transferToOffice.id = c.transfer_to_office_id ");
|
||||
sqlBuilder.append(" where l.id=? and ( o.hierarchy like ? or transferToOffice.hierarchy like ?)");
|
||||
|
||||
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(), rm, new Object[] { loanId, hierarchySearchString,
|
||||
hierarchySearchString });
|
||||
return this.jdbcTemplate.queryForObject(sqlBuilder.toString(), rm,
|
||||
new Object[] { loanId, hierarchySearchString, hierarchySearchString });
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
throw new LoanNotFoundException(loanId);
|
||||
}
|
||||
@@ -211,9 +211,9 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
try {
|
||||
this.context.authenticatedUser();
|
||||
|
||||
|
||||
final LoanScheduleResultSetExtractor fullResultsetExtractor = new LoanScheduleResultSetExtractor(
|
||||
repaymentScheduleRelatedLoanData, disbursementData, isInterestRecalculationEnabled ,totalPaidFeeCharges);
|
||||
repaymentScheduleRelatedLoanData, disbursementData, isInterestRecalculationEnabled, totalPaidFeeCharges);
|
||||
final String sql = "select " + fullResultsetExtractor.schema() + " where ls.loan_id = ? order by ls.loan_id, ls.installment";
|
||||
|
||||
return this.jdbcTemplate.query(sql, fullResultsetExtractor, new Object[] { loanId });
|
||||
@@ -233,9 +233,10 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
// been 'contra'ed by another transaction
|
||||
// repayments at time of disbursement (e.g. charges)
|
||||
|
||||
/*** TODO Vishwas: Remove references to "Contra" from the codebase ***/
|
||||
final String sql = "select "
|
||||
+ rm.LoanPaymentsSchema()
|
||||
/***
|
||||
* TODO Vishwas: Remove references to "Contra" from the codebase
|
||||
***/
|
||||
final String sql = "select " + rm.LoanPaymentsSchema()
|
||||
+ " where tr.loan_id = ? and tr.transaction_type_enum not in (0, 3) and (tr.is_reversed=0 or tr.manually_adjusted_or_reversed = 1) order by tr.transaction_date ASC,id ";
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanId });
|
||||
} catch (final EmptyResultDataAccessException e) {
|
||||
@@ -394,9 +395,10 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final BigDecimal outstandingLoanBalance = null;
|
||||
final BigDecimal unrecognizedIncomePortion = null;
|
||||
return new LoanTransactionData(null, null, null, transactionType, null, currencyData, earliestUnpaidInstallmentDate,
|
||||
loanRepaymentScheduleInstallment.getTotalOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment
|
||||
.getPrincipalOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment.getInterestOutstanding(currency)
|
||||
.getAmount(), loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency).getAmount(),
|
||||
loanRepaymentScheduleInstallment.getTotalOutstanding(currency).getAmount(),
|
||||
loanRepaymentScheduleInstallment.getPrincipalOutstanding(currency).getAmount(),
|
||||
loanRepaymentScheduleInstallment.getInterestOutstanding(currency).getAmount(),
|
||||
loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency).getAmount(),
|
||||
loanRepaymentScheduleInstallment.getPenaltyChargesOutstanding(currency).getAmount(), null, unrecognizedIncomePortion,
|
||||
paymentOptions, null, null, null, outstandingLoanBalance, false);
|
||||
}
|
||||
@@ -423,11 +425,11 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
if (loan.repaymentScheduleDetail().isInterestRecalculationEnabled()) {
|
||||
restCalendarInstance = calendarInstanceRepository.findCalendarInstaneByEntityId(loan.loanInterestRecalculationDetailId(),
|
||||
CalendarEntityType.LOAN_RECALCULATION_REST_DETAIL.getValue());
|
||||
compoundingCalendarInstance = calendarInstanceRepository.findCalendarInstaneByEntityId(
|
||||
loan.loanInterestRecalculationDetailId(), CalendarEntityType.LOAN_RECALCULATION_COMPOUNDING_DETAIL.getValue());
|
||||
compoundingCalendarInstance = calendarInstanceRepository.findCalendarInstaneByEntityId(loan.loanInterestRecalculationDetailId(),
|
||||
CalendarEntityType.LOAN_RECALCULATION_COMPOUNDING_DETAIL.getValue());
|
||||
final boolean isHolidayEnabled = this.configurationDomainService.isRescheduleRepaymentsOnHolidaysEnabled();
|
||||
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(), loan
|
||||
.getDisbursementDate().toDate(), HolidayStatusType.ACTIVE.getValue());
|
||||
final List<Holiday> holidays = this.holidayRepository.findByOfficeIdAndGreaterThanDate(loan.getOfficeId(),
|
||||
loan.getDisbursementDate().toDate(), HolidayStatusType.ACTIVE.getValue());
|
||||
final WorkingDays workingDays = this.workingDaysRepository.findOne();
|
||||
holidayDetailDTO = new HolidayDetailDTO(isHolidayEnabled, holidays, workingDays);
|
||||
}
|
||||
@@ -439,9 +441,10 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final BigDecimal outstandingLoanBalance = loanRepaymentScheduleInstallment.getPrincipalOutstanding(currency).getAmount();
|
||||
final BigDecimal unrecognizedIncomePortion = null;
|
||||
return new LoanTransactionData(null, null, null, transactionType, null, currencyData, earliestUnpaidInstallmentDate,
|
||||
loanRepaymentScheduleInstallment.getTotalOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment
|
||||
.getPrincipalOutstanding(currency).getAmount(), loanRepaymentScheduleInstallment.getInterestOutstanding(currency)
|
||||
.getAmount(), loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency).getAmount(),
|
||||
loanRepaymentScheduleInstallment.getTotalOutstanding(currency).getAmount(),
|
||||
loanRepaymentScheduleInstallment.getPrincipalOutstanding(currency).getAmount(),
|
||||
loanRepaymentScheduleInstallment.getInterestOutstanding(currency).getAmount(),
|
||||
loanRepaymentScheduleInstallment.getFeeChargesOutstanding(currency).getAmount(),
|
||||
loanRepaymentScheduleInstallment.getPenaltyChargesOutstanding(currency).getAmount(), null, unrecognizedIncomePortion,
|
||||
paymentOptions, null, null, null, outstandingLoanBalance, false);
|
||||
}
|
||||
@@ -565,19 +568,14 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
+ " lps.name as transactionStrategyName, "
|
||||
+ " l.currency_code as currencyCode, l.currency_digits as currencyDigits, l.currency_multiplesof as inMultiplesOf, rc.`name` as currencyName, rc.display_symbol as currencyDisplaySymbol, rc.internationalized_name_code as currencyNameCode, "
|
||||
+ " l.loan_officer_id as loanOfficerId, s.display_name as loanOfficerName, "
|
||||
+ " l.principal_disbursed_derived as principalDisbursed,"
|
||||
+ " l.principal_repaid_derived as principalPaid,"
|
||||
+ " l.principal_disbursed_derived as principalDisbursed," + " l.principal_repaid_derived as principalPaid,"
|
||||
+ " l.principal_writtenoff_derived as principalWrittenOff,"
|
||||
+ " l.principal_outstanding_derived as principalOutstanding,"
|
||||
+ " l.interest_charged_derived as interestCharged,"
|
||||
+ " l.interest_repaid_derived as interestPaid,"
|
||||
+ " l.interest_waived_derived as interestWaived,"
|
||||
+ " l.interest_writtenoff_derived as interestWrittenOff,"
|
||||
+ " l.interest_outstanding_derived as interestOutstanding,"
|
||||
+ " l.principal_outstanding_derived as principalOutstanding," + " l.interest_charged_derived as interestCharged,"
|
||||
+ " l.interest_repaid_derived as interestPaid," + " l.interest_waived_derived as interestWaived,"
|
||||
+ " l.interest_writtenoff_derived as interestWrittenOff," + " l.interest_outstanding_derived as interestOutstanding,"
|
||||
+ " l.fee_charges_charged_derived as feeChargesCharged,"
|
||||
+ " l.total_charges_due_at_disbursement_derived as feeChargesDueAtDisbursementCharged,"
|
||||
+ " l.fee_charges_repaid_derived as feeChargesPaid,"
|
||||
+ " l.fee_charges_waived_derived as feeChargesWaived,"
|
||||
+ " l.fee_charges_repaid_derived as feeChargesPaid," + " l.fee_charges_waived_derived as feeChargesWaived,"
|
||||
+ " l.fee_charges_writtenoff_derived as feeChargesWrittenOff,"
|
||||
+ " l.fee_charges_outstanding_derived as feeChargesOutstanding,"
|
||||
+ " l.penalty_charges_charged_derived as penaltyChargesCharged,"
|
||||
@@ -585,21 +583,14 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
+ " l.penalty_charges_waived_derived as penaltyChargesWaived,"
|
||||
+ " l.penalty_charges_writtenoff_derived as penaltyChargesWrittenOff,"
|
||||
+ " l.penalty_charges_outstanding_derived as penaltyChargesOutstanding,"
|
||||
+ " l.total_expected_repayment_derived as totalExpectedRepayment,"
|
||||
+ " l.total_repayment_derived as totalRepayment,"
|
||||
+ " l.total_expected_costofloan_derived as totalExpectedCostOfLoan,"
|
||||
+ " l.total_costofloan_derived as totalCostOfLoan,"
|
||||
+ " l.total_waived_derived as totalWaived,"
|
||||
+ " l.total_writtenoff_derived as totalWrittenOff,"
|
||||
+ " l.total_outstanding_derived as totalOutstanding,"
|
||||
+ " l.total_overpaid_derived as totalOverpaid,"
|
||||
+ " l.fixed_emi_amount as fixedEmiAmount,"
|
||||
+ " l.max_outstanding_loan_balance as outstandingLoanBalance,"
|
||||
+ " la.principal_overdue_derived as principalOverdue,"
|
||||
+ " la.interest_overdue_derived as interestOverdue,"
|
||||
+ " l.total_expected_repayment_derived as totalExpectedRepayment," + " l.total_repayment_derived as totalRepayment,"
|
||||
+ " l.total_expected_costofloan_derived as totalExpectedCostOfLoan," + " l.total_costofloan_derived as totalCostOfLoan,"
|
||||
+ " l.total_waived_derived as totalWaived," + " l.total_writtenoff_derived as totalWrittenOff,"
|
||||
+ " l.total_outstanding_derived as totalOutstanding," + " l.total_overpaid_derived as totalOverpaid,"
|
||||
+ " l.fixed_emi_amount as fixedEmiAmount," + " l.max_outstanding_loan_balance as outstandingLoanBalance,"
|
||||
+ " la.principal_overdue_derived as principalOverdue," + " la.interest_overdue_derived as interestOverdue,"
|
||||
+ " la.fee_charges_overdue_derived as feeChargesOverdue,"
|
||||
+ " la.penalty_charges_overdue_derived as penaltyChargesOverdue,"
|
||||
+ " la.total_overdue_derived as totalOverdue,"
|
||||
+ " la.penalty_charges_overdue_derived as penaltyChargesOverdue," + " la.total_overdue_derived as totalOverdue,"
|
||||
+ " la.overdue_since_date_derived as overdueSinceDate,"
|
||||
+ " l.sync_disbursement_with_meeting as syncDisbursementWithMeeting,"
|
||||
+ " l.loan_counter as loanCounter, l.loan_product_counter as loanProductCounter,"
|
||||
@@ -610,8 +601,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
+ " lir.rest_freqency_date as restFrequencyDate, "
|
||||
+ " lir.compounding_frequency_type_enum as compoundingFrequencyEnum, lir.compounding_frequency_interval as compoundingInterval, "
|
||||
+ " lir.compounding_freqency_date as compoundingFrequencyDate, "
|
||||
+ " l.create_standing_instruction_at_disbursement as createStandingInstructionAtDisbursement "
|
||||
+ " from m_loan l" //
|
||||
+ " l.create_standing_instruction_at_disbursement as createStandingInstructionAtDisbursement " + " from m_loan l" //
|
||||
+ " join m_product_loan lp on lp.id = l.product_id" //
|
||||
+ " left join m_loan_recalculation_details lir on lir.loan_id = l.id "
|
||||
+ " join m_currency rc on rc.`code` = l.currency_code" //
|
||||
@@ -624,8 +614,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
+ " left join m_appuser rbu on rbu.id = l.rejectedon_userid"
|
||||
+ " left join m_appuser wbu on wbu.id = l.withdrawnon_userid"
|
||||
+ " left join m_appuser abu on abu.id = l.approvedon_userid"
|
||||
+ " left join m_appuser dbu on dbu.id = l.disbursedon_userid"
|
||||
+ " left join m_appuser cbu on cbu.id = l.closedon_userid"
|
||||
+ " left join m_appuser dbu on dbu.id = l.disbursedon_userid" + " left join m_appuser cbu on cbu.id = l.closedon_userid"
|
||||
+ " left join m_code_value cv on cv.id = l.loanpurpose_cv_id"
|
||||
+ " left join ref_loan_transaction_processing_strategy lps on lps.id = l.loan_transaction_strategy_id";
|
||||
}
|
||||
@@ -838,8 +827,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final Integer groupStatusEnum = JdbcSupport.getInteger(rs, "statusEnum");
|
||||
final EnumOptionData groupStatus = ClientEnumerations.status(groupStatusEnum);
|
||||
final LocalDate activationDate = JdbcSupport.getLocalDate(rs, "activationDate");
|
||||
groupData = GroupGeneralData.instance(groupId, groupAccountNo, groupName, groupExternalId, groupStatus, activationDate, groupOfficeId,
|
||||
null, groupParentId, null, groupStaffId, null, groupHierarchy, groupLevel, null);
|
||||
groupData = GroupGeneralData.instance(groupId, groupAccountNo, groupName, groupExternalId, groupStatus, activationDate,
|
||||
groupOfficeId, null, groupParentId, null, groupStaffId, null, groupHierarchy, groupLevel, null);
|
||||
}
|
||||
|
||||
final Integer loanCounter = JdbcSupport.getInteger(rs, "loanCounter");
|
||||
@@ -906,8 +895,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
+ " ls.fee_charges_amount as feeChargesDue, ls.fee_charges_completed_derived as feeChargesPaid, ls.fee_charges_waived_derived as feeChargesWaived, ls.fee_charges_writtenoff_derived as feeChargesWrittenOff, "
|
||||
+ " ls.penalty_charges_amount as penaltyChargesDue, ls.penalty_charges_completed_derived as penaltyChargesPaid, ls.penalty_charges_waived_derived as penaltyChargesWaived, ls.penalty_charges_writtenoff_derived as penaltyChargesWrittenOff, "
|
||||
+ " ls.total_paid_in_advance_derived as totalPaidInAdvanceForPeriod, ls.total_paid_late_derived as totalPaidLateForPeriod, "
|
||||
+ " mc.amount,mc.id as chargeId "
|
||||
+ " from m_loan_repayment_schedule ls "
|
||||
+ " mc.amount,mc.id as chargeId " + " from m_loan_repayment_schedule ls "
|
||||
+ " inner join m_loan ml on ml.id = ls.loan_id "
|
||||
+ " join m_product_loan_charge plc on plc.product_loan_id = ml.product_id "
|
||||
+ " join m_charge mc on mc.id = plc.charge_id ";
|
||||
@@ -954,7 +942,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
private LocalDate lastDueDate;
|
||||
private BigDecimal outstandingLoanPrincipalBalance;
|
||||
private boolean excludePastUndisbursed;
|
||||
private BigDecimal totalPaidFeeCharges ;
|
||||
private BigDecimal totalPaidFeeCharges;
|
||||
|
||||
public LoanScheduleResultSetExtractor(final RepaymentScheduleRelatedLoanData repaymentScheduleRelatedLoanData,
|
||||
Collection<DisbursementData> disbursementData, boolean isInterestRecalculationEnabled, BigDecimal totalPaidFeeCharges) {
|
||||
this.currency = repaymentScheduleRelatedLoanData.getCurrency();
|
||||
@@ -964,7 +953,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
this.outstandingLoanPrincipalBalance = this.disbursement.amount();
|
||||
this.disbursementData = disbursementData;
|
||||
this.excludePastUndisbursed = isInterestRecalculationEnabled;
|
||||
this.totalPaidFeeCharges = totalPaidFeeCharges ;
|
||||
this.totalPaidFeeCharges = totalPaidFeeCharges;
|
||||
}
|
||||
|
||||
public String schema() {
|
||||
@@ -1032,29 +1021,29 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
for (DisbursementData data : disbursementData) {
|
||||
if (fromDate.equals(this.disbursement.disbursementDate()) && data.disbursementDate().equals(fromDate)) {
|
||||
principal = principal.add(data.amount());
|
||||
if(data.getChargeAmount() == null){
|
||||
final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
|
||||
if (data.getChargeAmount() == null) {
|
||||
final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
|
||||
data.disbursementDate(), data.amount(), BigDecimal.ZERO, data.isDisbursed());
|
||||
periods.add(periodData);
|
||||
}else{
|
||||
final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
|
||||
} else {
|
||||
final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
|
||||
data.disbursementDate(), data.amount(), data.getChargeAmount(), data.isDisbursed());
|
||||
periods.add(periodData);
|
||||
}
|
||||
}
|
||||
this.outstandingLoanPrincipalBalance = this.outstandingLoanPrincipalBalance.add(data.amount());
|
||||
} else if (data.isDueForDisbursement(fromDate, dueDate)) {
|
||||
if (!excludePastUndisbursed
|
||||
|| (excludePastUndisbursed && (data.isDisbursed() || !data.disbursementDate().isBefore(LocalDate.now())))) {
|
||||
if (!excludePastUndisbursed || (excludePastUndisbursed
|
||||
&& (data.isDisbursed() || !data.disbursementDate().isBefore(LocalDate.now())))) {
|
||||
principal = principal.add(data.amount());
|
||||
if(data.getChargeAmount() == null){
|
||||
final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
|
||||
if (data.getChargeAmount() == null) {
|
||||
final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
|
||||
data.disbursementDate(), data.amount(), BigDecimal.ZERO, data.isDisbursed());
|
||||
periods.add(periodData);
|
||||
}else{
|
||||
final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
|
||||
} else {
|
||||
final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
|
||||
data.disbursementDate(), data.amount(), data.getChargeAmount(), data.isDisbursed());
|
||||
periods.add(periodData);
|
||||
}
|
||||
}
|
||||
this.outstandingLoanPrincipalBalance = this.outstandingLoanPrincipalBalance.add(data.amount());
|
||||
}
|
||||
}
|
||||
@@ -1104,12 +1093,12 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
"totalPaidInAdvanceForPeriod");
|
||||
final BigDecimal totalPaidLateForPeriod = JdbcSupport.getBigDecimalDefaultToZeroIfNull(rs, "totalPaidLateForPeriod");
|
||||
|
||||
final BigDecimal penaltyChargesActualDue = penaltyChargesExpectedDue.subtract(penaltyChargesWaived).subtract(
|
||||
penaltyChargesWrittenOff);
|
||||
final BigDecimal penaltyChargesActualDue = penaltyChargesExpectedDue.subtract(penaltyChargesWaived)
|
||||
.subtract(penaltyChargesWrittenOff);
|
||||
final BigDecimal penaltyChargesOutstanding = penaltyChargesActualDue.subtract(penaltyChargesPaid);
|
||||
|
||||
final BigDecimal totalExpectedCostOfLoanForPeriod = interestExpectedDue.add(feeChargesExpectedDue).add(
|
||||
penaltyChargesExpectedDue);
|
||||
final BigDecimal totalExpectedCostOfLoanForPeriod = interestExpectedDue.add(feeChargesExpectedDue)
|
||||
.add(penaltyChargesExpectedDue);
|
||||
|
||||
final BigDecimal totalDueForPeriod = principalDue.add(totalExpectedCostOfLoanForPeriod);
|
||||
final BigDecimal totalPaidForPeriod = principalPaid.add(interestPaid).add(feeChargesPaid).add(penaltyChargesPaid);
|
||||
@@ -1150,11 +1139,11 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
periods.add(periodData);
|
||||
}
|
||||
|
||||
return new LoanScheduleData(this.currency, periods, loanTermInDays, totalPrincipalDisbursed,
|
||||
totalPrincipalExpected.getAmount(), totalPrincipalPaid.getAmount(), totalInterestCharged.getAmount(),
|
||||
totalFeeChargesCharged.getAmount(), totalPenaltyChargesCharged.getAmount(), totalWaived.getAmount(),
|
||||
totalWrittenOff.getAmount(), totalRepaymentExpected.getAmount(), totalRepayment.getAmount(),
|
||||
totalPaidInAdvance.getAmount(), totalPaidLate.getAmount(), totalOutstanding.getAmount());
|
||||
return new LoanScheduleData(this.currency, periods, loanTermInDays, totalPrincipalDisbursed, totalPrincipalExpected.getAmount(),
|
||||
totalPrincipalPaid.getAmount(), totalInterestCharged.getAmount(), totalFeeChargesCharged.getAmount(),
|
||||
totalPenaltyChargesCharged.getAmount(), totalWaived.getAmount(), totalWrittenOff.getAmount(),
|
||||
totalRepaymentExpected.getAmount(), totalRepayment.getAmount(), totalPaidInAdvance.getAmount(),
|
||||
totalPaidLate.getAmount(), totalOutstanding.getAmount());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1167,8 +1156,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
+ " tr.principal_portion_derived as principal, tr.interest_portion_derived as interest, "
|
||||
+ " tr.fee_charges_portion_derived as fees, tr.penalty_charges_portion_derived as penalties, "
|
||||
+ " tr.overpayment_portion_derived as overpayment, tr.outstanding_loan_balance_derived as outstandingLoanBalance, "
|
||||
+ " tr.unrecognized_income_portion as unrecognizedIncome,"
|
||||
+ " tr.submitted_on_date as submittedOnDate, "
|
||||
+ " tr.unrecognized_income_portion as unrecognizedIncome," + " tr.submitted_on_date as submittedOnDate, "
|
||||
+ " tr.manually_adjusted_or_reversed as manuallyReversed, "
|
||||
+ " pd.payment_type_id as paymentType,pd.account_number as accountNumber,pd.check_number as checkNumber, "
|
||||
+ " pd.receipt_number as receiptNumber, pd.bank_number as bankNumber,pd.routing_code as routingCode, "
|
||||
@@ -1272,8 +1260,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
+ " fromtran.description as fromTransferDescription,"
|
||||
+ " totran.id as toTransferId, totran.is_reversed as toTransferReversed,"
|
||||
+ " totran.transaction_date as toTransferDate, totran.amount as toTransferAmount,"
|
||||
+ " totran.description as toTransferDescription "
|
||||
+ " from m_loan l join m_loan_transaction tr on tr.loan_id = l.id"
|
||||
+ " totran.description as toTransferDescription " + " from m_loan l join m_loan_transaction tr on tr.loan_id = l.id"
|
||||
+ " join m_currency rc on rc.`code` = l.currency_code "
|
||||
+ " left join m_account_transfer_transaction fromtran on fromtran.from_loan_transaction_id = tr.id "
|
||||
+ " left join m_account_transfer_transaction totran on totran.to_loan_transaction_id = tr.id ";
|
||||
@@ -1343,14 +1330,14 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final Collection<CodeValueData> loanCollateralOptions = this.codeValueReadPlatformService
|
||||
.retrieveCodeValuesByCode("LoanCollateral");
|
||||
Collection<ChargeData> chargeOptions = null;
|
||||
if(loanProduct.getMultiDisburseLoan()){
|
||||
chargeOptions = this.chargeReadPlatformService.retrieveLoanProductApplicableCharges(productId,
|
||||
if (loanProduct.getMultiDisburseLoan()) {
|
||||
chargeOptions = this.chargeReadPlatformService.retrieveLoanProductApplicableCharges(productId,
|
||||
new ChargeTimeType[] { ChargeTimeType.OVERDUE_INSTALLMENT });
|
||||
}else{
|
||||
chargeOptions = this.chargeReadPlatformService.retrieveLoanProductApplicableCharges(productId,
|
||||
} else {
|
||||
chargeOptions = this.chargeReadPlatformService.retrieveLoanProductApplicableCharges(productId,
|
||||
new ChargeTimeType[] { ChargeTimeType.OVERDUE_INSTALLMENT, ChargeTimeType.TRANCHE_DISBURSEMENT });
|
||||
}
|
||||
|
||||
|
||||
Integer loanCycleCounter = null;
|
||||
if (loanProduct.useBorrowerCycle()) {
|
||||
if (clientId == null) {
|
||||
@@ -1408,8 +1395,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
@Override
|
||||
public Collection<CalendarData> retrieveCalendars(final Long groupId) {
|
||||
Collection<CalendarData> calendarsData = new ArrayList<>();
|
||||
calendarsData.addAll(this.calendarReadPlatformService.retrieveParentCalendarsByEntity(groupId,
|
||||
CalendarEntityType.GROUPS.getValue(), null));
|
||||
calendarsData.addAll(
|
||||
this.calendarReadPlatformService.retrieveParentCalendarsByEntity(groupId, CalendarEntityType.GROUPS.getValue(), null));
|
||||
calendarsData
|
||||
.addAll(this.calendarReadPlatformService.retrieveCalendarsByEntity(groupId, CalendarEntityType.GROUPS.getValue(), null));
|
||||
calendarsData = this.calendarReadPlatformService.updateWithRecurringDates(calendarsData);
|
||||
@@ -1461,8 +1448,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<DisbursementData> retrieveLoanDisbursementDetails
|
||||
(final Long loanId) {
|
||||
public Collection<DisbursementData> retrieveLoanDisbursementDetails(final Long loanId) {
|
||||
final LoanDisbursementDetailMapper rm = new LoanDisbursementDetailMapper();
|
||||
final String sql = "select " + rm.schema() + " where dd.loan_id=? group by dd.id order by dd.expected_disburse_date";
|
||||
return this.jdbcTemplate.query(sql, rm, new Object[] { loanId });
|
||||
@@ -1471,9 +1457,9 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
private static final class LoanDisbursementDetailMapper implements RowMapper<DisbursementData> {
|
||||
|
||||
public String schema() {
|
||||
return "dd.id as id,dd.expected_disburse_date as expectedDisbursementdate, dd.disbursedon_date as actualDisbursementdate,dd.principal as principal,sum(lc.amount) chargeAmount, lc.amount_waived_derived waivedAmount,group_concat(lc.id) loanChargeId "+
|
||||
"from m_loan l inner join m_loan_disbursement_detail dd on dd.loan_id = l.id left join m_loan_tranche_disbursement_charge tdc on tdc.disbursement_detail_id=dd.id " +
|
||||
"left join m_loan_charge lc on lc.id=tdc.loan_charge_id and lc.is_active=1";
|
||||
return "dd.id as id,dd.expected_disburse_date as expectedDisbursementdate, dd.disbursedon_date as actualDisbursementdate,dd.principal as principal,sum(lc.amount) chargeAmount, lc.amount_waived_derived waivedAmount,group_concat(lc.id) loanChargeId "
|
||||
+ "from m_loan l inner join m_loan_disbursement_detail dd on dd.loan_id = l.id left join m_loan_tranche_disbursement_charge tdc on tdc.disbursement_detail_id=dd.id "
|
||||
+ "left join m_loan_charge lc on lc.id=tdc.loan_charge_id and lc.is_active=1";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1484,11 +1470,10 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final BigDecimal principal = rs.getBigDecimal("principal");
|
||||
final String loanChargeId = rs.getString("loanChargeId");
|
||||
BigDecimal chargeAmount = rs.getBigDecimal("chargeAmount");
|
||||
final BigDecimal waivedAmount = rs.getBigDecimal("waivedAmount") ;
|
||||
if(chargeAmount != null && waivedAmount != null)
|
||||
chargeAmount = chargeAmount.subtract(waivedAmount) ;
|
||||
final DisbursementData disbursementData = new DisbursementData(id, expectedDisbursementdate, actualDisbursementdate, principal, loanChargeId,
|
||||
chargeAmount);
|
||||
final BigDecimal waivedAmount = rs.getBigDecimal("waivedAmount");
|
||||
if (chargeAmount != null && waivedAmount != null) chargeAmount = chargeAmount.subtract(waivedAmount);
|
||||
final DisbursementData disbursementData = new DisbursementData(id, expectedDisbursementdate, actualDisbursementdate, principal,
|
||||
loanChargeId, chargeAmount);
|
||||
return disbursementData;
|
||||
}
|
||||
|
||||
@@ -1533,15 +1518,13 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
LoanScheduleAccrualMapper mapper = new LoanScheduleAccrualMapper();
|
||||
final StringBuilder sqlBuilder = new StringBuilder(400);
|
||||
sqlBuilder
|
||||
.append("select ")
|
||||
.append(mapper.schema())
|
||||
sqlBuilder.append("select ").append(mapper.schema())
|
||||
.append(" where ((ls.fee_charges_amount <> if(ls.accrual_fee_charges_derived is null,0, ls.accrual_fee_charges_derived))")
|
||||
.append(" or ( ls.penalty_charges_amount <> if(ls.accrual_penalty_charges_derived is null,0,ls.accrual_penalty_charges_derived))")
|
||||
.append(" or ( ls.interest_amount <> if(ls.accrual_interest_derived is null,0,ls.accrual_interest_derived)))")
|
||||
.append(" and loan.loan_status_id=? and mpl.accounting_type=? and loan.is_npa=0 and ls.duedate <= CURDATE() order by loan.id,ls.duedate");
|
||||
return this.jdbcTemplate.query(sqlBuilder.toString(), mapper, new Object[] { LoanStatus.ACTIVE.getValue(),
|
||||
AccountingRuleType.ACCRUAL_PERIODIC.getValue() });
|
||||
return this.jdbcTemplate.query(sqlBuilder.toString(), mapper,
|
||||
new Object[] { LoanStatus.ACTIVE.getValue(), AccountingRuleType.ACCRUAL_PERIODIC.getValue() });
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1549,9 +1532,7 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
LoanSchedulePeriodicAccrualMapper mapper = new LoanSchedulePeriodicAccrualMapper();
|
||||
final StringBuilder sqlBuilder = new StringBuilder(400);
|
||||
sqlBuilder
|
||||
.append("select ")
|
||||
.append(mapper.schema())
|
||||
sqlBuilder.append("select ").append(mapper.schema())
|
||||
.append(" where ((ls.fee_charges_amount <> if(ls.accrual_fee_charges_derived is null,0, ls.accrual_fee_charges_derived))")
|
||||
.append(" or (ls.penalty_charges_amount <> if(ls.accrual_penalty_charges_derived is null,0,ls.accrual_penalty_charges_derived))")
|
||||
.append(" or (ls.interest_amount <> if(ls.accrual_interest_derived is null,0,ls.accrual_interest_derived)))")
|
||||
@@ -1568,16 +1549,13 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
public String schema() {
|
||||
final StringBuilder sqlBuilder = new StringBuilder(400);
|
||||
sqlBuilder
|
||||
.append("loan.id as loanId ,if(loan.client_id is null,mg.office_id,mc.office_id) as officeId,")
|
||||
sqlBuilder.append("loan.id as loanId ,if(loan.client_id is null,mg.office_id,mc.office_id) as officeId,")
|
||||
.append("loan.accrued_till as accruedTill, loan.repayment_period_frequency_enum as frequencyEnum, ")
|
||||
.append("loan.interest_calculated_from_date as interestCalculatedFrom, ")
|
||||
.append("loan.repay_every as repayEvery,")
|
||||
.append("loan.interest_calculated_from_date as interestCalculatedFrom, ").append("loan.repay_every as repayEvery,")
|
||||
.append("ls.installment as installmentNumber, ")
|
||||
.append("ls.duedate as duedate,ls.fromdate as fromdate ,ls.id as scheduleId,loan.product_id as productId,")
|
||||
.append("ls.interest_amount as interest, ls.interest_waived_derived as interestWaived,")
|
||||
.append("ls.penalty_charges_amount as penalty, ")
|
||||
.append("ls.fee_charges_amount as charges, ")
|
||||
.append("ls.penalty_charges_amount as penalty, ").append("ls.fee_charges_amount as charges, ")
|
||||
.append("ls.accrual_interest_derived as accinterest,ls.accrual_fee_charges_derived as accfeecharege,ls.accrual_penalty_charges_derived as accpenalty,")
|
||||
.append(" loan.currency_code as currencyCode,loan.currency_digits as currencyDigits,loan.currency_multiplesof as inMultiplesOf,")
|
||||
.append("curr.display_symbol as currencyDisplaySymbol,curr.name as currencyName,curr.internationalized_name_code as currencyNameCode")
|
||||
@@ -1632,13 +1610,11 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
public String schema() {
|
||||
final StringBuilder sqlBuilder = new StringBuilder(400);
|
||||
sqlBuilder
|
||||
.append("loan.id as loanId ,if(loan.client_id is null,mg.office_id,mc.office_id) as officeId,")
|
||||
sqlBuilder.append("loan.id as loanId ,if(loan.client_id is null,mg.office_id,mc.office_id) as officeId,")
|
||||
.append("ls.duedate as duedate,ls.fromdate as fromdate,ls.id as scheduleId,loan.product_id as productId,")
|
||||
.append("ls.installment as installmentNumber, ")
|
||||
.append("ls.interest_amount as interest, ls.interest_waived_derived as interestWaived,")
|
||||
.append("ls.penalty_charges_amount as penalty, ")
|
||||
.append("ls.fee_charges_amount as charges, ")
|
||||
.append("ls.penalty_charges_amount as penalty, ").append("ls.fee_charges_amount as charges, ")
|
||||
.append("ls.accrual_interest_derived as accinterest,ls.accrual_fee_charges_derived as accfeecharege,ls.accrual_penalty_charges_derived as accpenalty,")
|
||||
.append(" loan.currency_code as currencyCode,loan.currency_digits as currencyDigits,loan.currency_multiplesof as inMultiplesOf,")
|
||||
.append("curr.display_symbol as currencyDisplaySymbol,curr.name as currencyName,curr.internationalized_name_code as currencyNameCode")
|
||||
@@ -1857,10 +1833,10 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
|
||||
return LoanSchedulePeriodData.repaymentPeriodWithPayments(loanId, period, fromDate, dueDate, obligationsMetOnDate, complete,
|
||||
principalOriginalDue, principalPaid, principalWrittenOff, principalOutstanding, outstandingPrincipalBalanceOfLoan,
|
||||
interestDueOnPrincipalOutstanding, interestPaid, interestWaived, interestWrittenOff, interestOutstanding,
|
||||
feeChargesDue, feeChargesPaid, feeChargesWaived, feeChargesWrittenOff, feeChargesOutstanding, penaltyChargesDue,
|
||||
penaltyChargesPaid, penaltyChargesWaived, penaltyChargesWrittenOff, penaltyChargesOutstanding, totalDueForPeriod,
|
||||
totalPaid, totalPaidInAdvanceForPeriod, totalPaidLateForPeriod, totalWaived, totalWrittenOff, totalOutstanding,
|
||||
interestDueOnPrincipalOutstanding, interestPaid, interestWaived, interestWrittenOff, interestOutstanding, feeChargesDue,
|
||||
feeChargesPaid, feeChargesWaived, feeChargesWrittenOff, feeChargesOutstanding, penaltyChargesDue, penaltyChargesPaid,
|
||||
penaltyChargesWaived, penaltyChargesWrittenOff, penaltyChargesOutstanding, totalDueForPeriod, totalPaid,
|
||||
totalPaidInAdvanceForPeriod, totalPaidLateForPeriod, totalWaived, totalWrittenOff, totalOutstanding,
|
||||
totalActualCostOfLoanForPeriod);
|
||||
}
|
||||
}
|
||||
@@ -1869,8 +1845,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
public Date retrieveMinimumDateOfRepaymentTransaction(Long loanId) {
|
||||
// TODO Auto-generated method stub
|
||||
Date date = this.jdbcTemplate.queryForObject(
|
||||
"select min(transaction_date) from m_loan_transaction where loan_id=? and transaction_type_enum=2",
|
||||
new Object[] { loanId }, Date.class);
|
||||
"select min(transaction_date) from m_loan_transaction where loan_id=? and transaction_type_enum=2", new Object[] { loanId },
|
||||
Date.class);
|
||||
|
||||
return date;
|
||||
}
|
||||
@@ -1916,8 +1892,8 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService {
|
||||
final Collection<PaymentTypeData> paymentOptions = this.paymentTypeReadPlatformService.retrieveAllPaymentTypes();
|
||||
|
||||
return new LoanTransactionData(null, null, null, transactionType, null, currencyData, earliestUnpaidInstallmentDate,
|
||||
retrieveTotalPaidInAdvance(loan.getId()).getPaidInAdvance(), null, null, null, null, null, null, paymentOptions, null,
|
||||
null, null, null, false);
|
||||
retrieveTotalPaidInAdvance(loan.getId()).getPaidInAdvance(), null, null, null, null, null, null, paymentOptions, null, null,
|
||||
null, null, false);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user