diff --git a/api-docs/apiLive.htm b/api-docs/apiLive.htm
index 5698f1f16..ddd71b071 100644
--- a/api-docs/apiLive.htm
+++ b/api-docs/apiLive.htm
@@ -8003,6 +8003,14 @@ GET https://DomainName/mifosng-provider/api/v1/groups?paged=true
| Example Values: 0=Daily, 1=Same as repayment period |
+
+ | allowPartialPeriodInterestCalcualtion |
+
+
+ | This value will be supported along with interestCalculationPeriodType as Same as repayment period to calculate interest for partial periods.
+ Example: Interest charged from is 5th of April , Principal is 10000 and interest is 1% per month then the interest will be (10000 * 1%)* (25/30) , it calculates for the month first then calculates exact periods between start date and end date(can be a decimal)
+ |
+
| inArrearsTolerance |
@@ -9219,7 +9227,7 @@ Request Body:
Optional Fields |
- | graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, linkAccountId,
+ | graceOnPrincipalPayment, graceOnInterestPayment, graceOnInterestCharged, linkAccountId, allowPartialPeriodInterestCalcualtion,
fixedEmiAmount, maxOutstandingLoanBalance, disbursementData, graceOnArrearsAgeing, createStandingInstructionAtDisbursement (requires linkedAccountId if set to true)
|
@@ -12759,6 +12767,14 @@ Request Body:
| Example Values: 0=Daily, 1=Same as repayment period |
+
+ | allowPartialPeriodInterestCalcualtion |
+
+
+ | This value will be supported along with interestCalculationPeriodType as Same as repayment period to calculate interest for partial periods.
+ Example: Interest charged from is 5th of April , Principal is 10000 and interest is 1% per month then the interest will be (10000 * 1%)* (25/30) , it calculates for the month first then calculates exact periods between start date and end date(can be a decimal)
+ |
+
| inArrearsTolerance |
@@ -14236,7 +14252,7 @@ GET https://DomainName/api/v1/loanproducts/{productId}
numberOfRepaymentVariationsForBorrowerCycle,
interestRateVariationsForBorrowerCycle,
multiDisburseLoan,maxTrancheCount,
- outstandingLoanBalance,overdueDaysForNPA,holdGuaranteeFunds, principalThresholdForLastInstalment, accountMovesOutOfNPAOnlyOnArrearsCompletion, canDefineInstallmentAmount, installmentAmountInMultiplesOf, allowAttributeOverrides
+ outstandingLoanBalance,overdueDaysForNPA,holdGuaranteeFunds, principalThresholdForLastInstalment, accountMovesOutOfNPAOnlyOnArrearsCompletion, canDefineInstallmentAmount, installmentAmountInMultiplesOf, allowAttributeOverrides, allowPartialPeriodInterestCalcualtion
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientLoanIntegrationTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientLoanIntegrationTest.java
index a5b8a7c56..ed7499dff 100644
--- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientLoanIntegrationTest.java
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ClientLoanIntegrationTest.java
@@ -868,7 +868,7 @@ public class ClientLoanIntegrationTest {
private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
- final String loanProductJSON = new LoanProductTestBuilder() //
+ LoanProductTestBuilder builder = new LoanProductTestBuilder() //
.withPrincipal("12,000.00") //
.withNumberOfRepayments("4") //
.withRepaymentAfterEvery("1") //
@@ -878,7 +878,11 @@ public class ClientLoanIntegrationTest {
.withAmortizationTypeAsEqualInstallments() //
.withInterestTypeAsDecliningBalance() //
.withTranches(multiDisburseLoan) //
- .withAccounting(accountingRule, accounts).build(null);
+ .withAccounting(accountingRule, accounts);
+ if (multiDisburseLoan) {
+ builder = builder.withInterestCalculationPeriodTypeAsRepaymentPeriod(true);
+ }
+ final String loanProductJSON = builder.build(null);
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
}
@@ -4166,14 +4170,13 @@ public class ClientLoanIntegrationTest {
testLoanScheduleWithInterestRecalculation_FOR_PRE_CLOSE_WITH_MORATORIUM(
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_ON_PRE_CLOSE_DATE, "10006.59");
}
-
+
@Test
public void testLoanScheduleWithInterestRecalculation_FOR_PRE_CLOSE_WITH_MORATORIUM_INTEREST_APPLICABLE_STRATEGY_REST_DATE() {
testLoanScheduleWithInterestRecalculation_FOR_PRE_CLOSE_WITH_MORATORIUM(
LoanProductTestBuilder.INTEREST_APPLICABLE_STRATEGY_REST_DATE, "10046.15");
}
-
private void testLoanScheduleWithInterestRecalculation_FOR_PRE_CLOSE_WITH_MORATORIUM(final String preCloseStrategy,
final String preCloseAmount) {
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
@@ -4307,6 +4310,7 @@ public class ClientLoanIntegrationTest {
.withInterestRateFrequencyTypeAsMonths()
.withRepaymentStrategy(repaymentStrategy)
.withAmortizationTypeAsEqualPrincipalPayment()
+ .withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
.withInterestTypeAsDecliningBalance()
.withInterestRecalculationDetails(interestRecalculationCompoundingMethod, rescheduleStrategyMethod,
preCloseInterestCalculationStrategy)
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ConcurrencyIntegrationTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ConcurrencyIntegrationTest.java
index 32cec67b7..ae70e93ad 100755
--- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ConcurrencyIntegrationTest.java
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/ConcurrencyIntegrationTest.java
@@ -80,7 +80,7 @@ public class ConcurrencyIntegrationTest {
private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
- final String loanProductJSON = new LoanProductTestBuilder() //
+ LoanProductTestBuilder builder = new LoanProductTestBuilder() //
.withPrincipal("12,000.00") //
.withNumberOfRepayments("4") //
.withRepaymentAfterEvery("1") //
@@ -90,7 +90,12 @@ public class ConcurrencyIntegrationTest {
.withAmortizationTypeAsEqualInstallments() //
.withInterestTypeAsDecliningBalance() //
.withTranches(multiDisburseLoan) //
- .withAccounting(accountingRule, accounts).build(null);
+ .withAccounting(accountingRule, accounts);
+
+ if (multiDisburseLoan) {
+ builder = builder.withInterestCalculationPeriodTypeAsRepaymentPeriod(true);
+ }
+ final String loanProductJSON = builder.build(null);
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
}
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanApplicationApprovalTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanApplicationApprovalTest.java
index 214e3abb9..5b015d58f 100644
--- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanApplicationApprovalTest.java
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanApplicationApprovalTest.java
@@ -121,7 +121,8 @@ public class LoanApplicationApprovalTest {
+ clientID);
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
- .withInterestTypeAsDecliningBalance().withTranches(true).build(null));
+ .withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
+ .build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
+ loanProductID);
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanApplicationUndoLastTrancheTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanApplicationUndoLastTrancheTest.java
index d3eb5d27a..36bd91c35 100644
--- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanApplicationUndoLastTrancheTest.java
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanApplicationUndoLastTrancheTest.java
@@ -11,7 +11,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
-
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -31,12 +30,12 @@ import org.mifosplatform.integrationtests.LoanApplicationApprovalTest;
@SuppressWarnings("rawtypes")
public class LoanApplicationUndoLastTrancheTest {
-
- private ResponseSpecification responseSpec;
+
+ private ResponseSpecification responseSpec;
private RequestSpecification requestSpec;
private LoanTransactionHelper loanTransactionHelper;
private LoanApplicationApprovalTest loanApplicationApprovalTest;
-
+
@Before
public void setup() {
Utils.initializeRESTAssured();
@@ -46,32 +45,33 @@ public class LoanApplicationUndoLastTrancheTest {
this.loanTransactionHelper = new LoanTransactionHelper(this.requestSpec, this.responseSpec);
this.loanApplicationApprovalTest = new LoanApplicationApprovalTest();
}
-
+
@Test
- public void LoanApplicationUndoLastTranche(){
-
- final String proposedAmount = "5000";
+ public void LoanApplicationUndoLastTranche() {
+
+ final String proposedAmount = "5000";
final String approvalAmount = "2000";
final String approveDate = "1 March 2014";
final String expectedDisbursementDate = "1 March 2014";
final String disbursalDate = "1 March 2014";
-
+
// CREATE CLIENT
- final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
+ final Integer clientID = ClientHelper.createClient(this.requestSpec, this.responseSpec, "01 January 2014");
System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
+ clientID);
// CREATE LOAN MULTIDISBURSAL PRODUCT
final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
- .withInterestTypeAsDecliningBalance().withTranches(true).build(null));
+ .withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(true)
+ .build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
+ loanProductID);
-
+
// CREATE TRANCHES
List createTranches = new ArrayList<>();
createTranches.add(this.loanApplicationApprovalTest.createTrancheDetail("1 March 2014", "1000"));
createTranches.add(this.loanApplicationApprovalTest.createTrancheDetail("23 June 2014", "4000"));
-
+
// APPROVE TRANCHES
List approveTranches = new ArrayList<>();
approveTranches.add(this.loanApplicationApprovalTest.createTrancheDetail("1 March 2014", "1000"));
@@ -82,25 +82,25 @@ public class LoanApplicationUndoLastTrancheTest {
System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------"
+ loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
-
+
// VALIDATE THE LOAN STATUS
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
System.out.println("-----------------------------------APPROVE LOAN-----------------------------------------------------------");
loanStatusHashMap = this.loanTransactionHelper.approveLoanWithApproveAmount(approveDate, expectedDisbursementDate, approvalAmount,
loanID, approveTranches);
-
+
// VALIDATE THE LOAN IS APPROVED
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
-
+
// DISBURSE A LOAN
this.loanTransactionHelper.disburseLoan(disbursalDate, loanID);
loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
-
+
// VALIDATE THE LOAN IS ACTIVE STATUS
LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
-
+
System.out.println("-------------Make repayment 1-----------");
this.loanTransactionHelper.makeRepayment("01 April 2014", Float.valueOf("420"), loanID);
System.out.println("-------------Make repayment 2-----------");
@@ -111,15 +111,15 @@ public class LoanApplicationUndoLastTrancheTest {
this.loanTransactionHelper.disburseLoan("23 June 2014", loanID);
// UNDO LAST TRANCHE
Float disbursedAmount = this.loanTransactionHelper.undoLastDisbursal(loanID);
- validateDisbursedAmount(disbursedAmount);
+ validateDisbursedAmount(disbursedAmount);
}
-
- private void validateDisbursedAmount(Float disbursedAmount) {
- Assert.assertEquals(Float.valueOf("1000.0"), disbursedAmount);
-
- }
- public Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal,
+ private void validateDisbursedAmount(Float disbursedAmount) {
+ Assert.assertEquals(Float.valueOf("1000.0"), disbursedAmount);
+
+ }
+
+ public Integer applyForLoanApplicationWithTranches(final Integer clientID, final Integer loanProductID, String principal,
List tranches) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
@@ -140,6 +140,5 @@ public class LoanApplicationUndoLastTrancheTest {
return this.loanTransactionHelper.getLoanId(loanApplicationJSON);
}
-
}
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanDisbursementDetailsIntegrationTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanDisbursementDetailsIntegrationTest.java
index 32198f677..a0257903a 100644
--- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanDisbursementDetailsIntegrationTest.java
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/LoanDisbursementDetailsIntegrationTest.java
@@ -64,12 +64,12 @@ public class LoanDisbursementDetailsIntegrationTest {
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);
+ System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
+ + clientID);
- final Integer loanProductID = this.loanTransactionHelper
- .getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withMoratorium("", "")
- .withAmortizationTypeAsEqualInstallments().withTranches(true).build(null));
+ final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
+ .withInterestTypeAsDecliningBalance().withMoratorium("", "").withAmortizationTypeAsEqualInstallments().withTranches(true)
+ .withInterestCalculationPeriodTypeAsRepaymentPeriod(true).build(null));
System.out.println("----------------------------------LOAN PRODUCT CREATED WITH ID-------------------------------------------"
+ loanProductID);
@@ -96,8 +96,8 @@ public class LoanDisbursementDetailsIntegrationTest {
createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
- System.out.println(
- "-----------------------------------MULTI DISBURSAL LOAN WITH EMI APPROVED SUCCESSFULLY---------------------------------------");
+ System.out
+ .println("-----------------------------------MULTI DISBURSAL LOAN WITH EMI APPROVED SUCCESSFULLY---------------------------------------");
final Integer loanIDWithoutEmi = applyForLoanApplicationWithEmiAmount(clientID, loanProductID, proposedAmount, createTranches,
withoutInstallmentAmount);
@@ -108,8 +108,8 @@ public class LoanDisbursementDetailsIntegrationTest {
ArrayList periods1 = (ArrayList) repaymentScheduleWithEmi.get("periods");
assertEquals(periods1.size(), 15);
- System.out.println(
- "-----------------------------------LOAN CREATED WITHOUT EMI LOANID-------------------------------------------------"
+ System.out
+ .println("-----------------------------------LOAN CREATED WITHOUT EMI LOANID-------------------------------------------------"
+ loanIDWithoutEmi);
/* To be uncommented once issue MIFOSX-2006 is closed. */
@@ -123,8 +123,8 @@ public class LoanDisbursementDetailsIntegrationTest {
loanIDWithoutEmi, createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
- System.out.println(
- "-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------");
+ System.out
+ .println("-----------------------------------MULTI DISBURSAL LOAN WITHOUT EMI APPROVED SUCCESSFULLY---------------------------------------");
}
@@ -201,8 +201,8 @@ public class LoanDisbursementDetailsIntegrationTest {
assertEquals(period.get("dueDate").toString(), expectedRepaymentSchedule.getDueDate());
assertEquals(period.get("principalLoanBalanceOutstanding"), expectedRepaymentSchedule.getPrincipalLoanBalanceOutstanding());
System.out.println(period.get("totalOriginalDueForPeriod").toString());
- assertEquals(new Float(period.get("totalOriginalDueForPeriod").toString()),
- expectedRepaymentSchedule.getTotalOriginalDueForPeriod().floatValue(), 0.0f);
+ assertEquals(new Float(period.get("totalOriginalDueForPeriod").toString()), expectedRepaymentSchedule
+ .getTotalOriginalDueForPeriod().floatValue(), 0.0f);
assertEquals(new Float(period.get("totalOutstandingForPeriod").toString()).floatValue(),
expectedRepaymentSchedule.getTotalOutstandingForPeriod(), 0.0f);
@@ -335,7 +335,7 @@ public class LoanDisbursementDetailsIntegrationTest {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
- //
+ //
.withPrincipal(proposedAmount)
//
.withLoanTermFrequency("12")
@@ -364,17 +364,18 @@ public class LoanDisbursementDetailsIntegrationTest {
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);
+ System.out.println("---------------------------------CLIENT CREATED WITH ID---------------------------------------------------"
+ + clientID);
- final Integer loanProductID = this.loanTransactionHelper
- .getLoanProductId(new LoanProductTestBuilder().withInterestTypeAsDecliningBalance().withTranches(true).build(null));
+ final Integer loanProductID = this.loanTransactionHelper.getLoanProductId(new LoanProductTestBuilder()
+ .withInterestTypeAsDecliningBalance().withTranches(true).withInterestCalculationPeriodTypeAsRepaymentPeriod(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);
+ System.out.println("-----------------------------------LOAN CREATED WITH LOANID-------------------------------------------------"
+ + loanID);
HashMap loanStatusHashMap = LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
@@ -384,8 +385,8 @@ public class LoanDisbursementDetailsIntegrationTest {
loanID, createTranches);
LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
- System.out.println(
- "-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
+ System.out
+ .println("-----------------------------------MULTI DISBURSAL LOAN APPROVED SUCCESSFULLY---------------------------------------");
ArrayList disbursementDetails = (ArrayList) this.loanTransactionHelper.getLoanDetail(this.requestSpec,
this.responseSpec, this.loanID, "disbursementDetails");
this.disbursementId = (Integer) disbursementDetails.get(0).get("id");
@@ -466,7 +467,7 @@ public class LoanDisbursementDetailsIntegrationTest {
List tranches) {
System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
final String loanApplicationJSON = new LoanApplicationTestBuilder()
- //
+ //
.withPrincipal(principal)
//
.withLoanTermFrequency("5")
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/ProvisioningIntegrationTest.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/ProvisioningIntegrationTest.java
index 5d8193b55..c79232195 100644
--- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/ProvisioningIntegrationTest.java
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/ProvisioningIntegrationTest.java
@@ -161,7 +161,7 @@ public class ProvisioningIntegrationTest {
private Integer createLoanProduct(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
- final String loanProductJSON = new LoanProductTestBuilder() //
+ LoanProductTestBuilder builder = new LoanProductTestBuilder() //
.withPrincipal("1,00,000.00") //
.withNumberOfRepayments("4") //
.withRepaymentAfterEvery("1") //
@@ -171,7 +171,12 @@ public class ProvisioningIntegrationTest {
.withAmortizationTypeAsEqualInstallments() //
.withInterestTypeAsDecliningBalance() //
.withTranches(multiDisburseLoan) //
- .withAccounting(accountingRule, accounts).build(null);
+ .withAccounting(accountingRule, accounts);
+ if (multiDisburseLoan) {
+ builder = builder.withInterestCalculationPeriodTypeAsRepaymentPeriod(true);
+ }
+ final String loanProductJSON = builder.build(null);
+
return this.loanTransactionHelper.getLoanProductId(loanProductJSON);
}
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/loans/LoanProductTestBuilder.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/loans/LoanProductTestBuilder.java
index 455e58bd4..342db5e25 100644
--- a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/loans/LoanProductTestBuilder.java
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/common/loans/LoanProductTestBuilder.java
@@ -104,6 +104,11 @@ public class LoanProductTestBuilder {
private String graceOnPrincipalPayment = "1";
private String graceOnInterestPayment = "1";
private JsonObject allowAttributeOverrides = null;
+ private Boolean allowPartialPeriodInterestCalcualtion = false;
+
+ private Boolean allowVariableInstallments = Boolean.FALSE;
+ private Integer minimumGap;
+ private Integer maximumGap;
public String build(final String chargeId) {
final HashMap map = new HashMap<>();
@@ -183,6 +188,12 @@ public class LoanProductTestBuilder {
if (allowAttributeOverrides != null) {
map.put("allowAttributeOverrides", this.allowAttributeOverrides);
}
+ map.put("allowPartialPeriodInterestCalcualtion", this.allowPartialPeriodInterestCalcualtion);
+ map.put("allowVariableInstallments", allowVariableInstallments) ;
+ if(allowVariableInstallments) {
+ map.put("minimumGap", minimumGap) ;
+ map.put("maximumGap", maximumGap) ;
+ }
return new Gson().toJson(map);
}
@@ -276,8 +287,9 @@ public class LoanProductTestBuilder {
return this;
}
- public LoanProductTestBuilder withInterestCalculationPeriodTypeAsRepaymentPeriod() {
+ public LoanProductTestBuilder withInterestCalculationPeriodTypeAsRepaymentPeriod(final Boolean allowPartialPeriodInterestCalcualtion) {
this.interestCalculationPeriodType = CALCULATION_PERIOD_SAME_AS_REPAYMENT_PERIOD;
+ this.allowPartialPeriodInterestCalcualtion = allowPartialPeriodInterestCalcualtion;
return this;
}
@@ -419,7 +431,7 @@ public class LoanProductTestBuilder {
this.recalculationRestFrequencyDate = recalculationRestFrequencyDate;
return this;
}
-
+
public LoanProductTestBuilder withInterestRecalculationCompoundingFrequencyDetails(final String recalculationCompoundingFrequencyType,
final String recalculationCompoundingFrequencyInterval, final String recalculationCompoundingFrequencyDate) {
this.isInterestRecalculationEnabled = true;
@@ -458,4 +470,11 @@ public class LoanProductTestBuilder {
this.allowAttributeOverrides = loanProductConfigurableAttributes;
return this;
}
+
+ public LoanProductTestBuilder withVariableInstallmentsConfig(Boolean allowVariableInstallments, Integer minimumGap, Integer maximumGap) {
+ this.allowVariableInstallments = allowVariableInstallments ;
+ this.minimumGap = minimumGap;
+ this.maximumGap = maximumGap;
+ return this ;
+ }
}
diff --git a/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/variableinstallments/VariableInstallmentsDecliningBalanceHelper.java b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/variableinstallments/VariableInstallmentsDecliningBalanceHelper.java
new file mode 100644
index 000000000..449225d52
--- /dev/null
+++ b/mifosng-provider/src/integrationTest/java/org/mifosplatform/integrationtests/variableinstallments/VariableInstallmentsDecliningBalanceHelper.java
@@ -0,0 +1,298 @@
+/**
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+package org.mifosplatform.integrationtests.variableinstallments;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.mifosplatform.integrationtests.common.accounting.Account;
+import org.mifosplatform.integrationtests.common.loans.LoanApplicationTestBuilder;
+import org.mifosplatform.integrationtests.common.loans.LoanProductTestBuilder;
+
+import com.google.gson.Gson;
+
+@SuppressWarnings({"rawtypes", "unchecked"})
+public class VariableInstallmentsDecliningBalanceHelper {
+
+ public static String createLoanProductWithoutVaribleConfig(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
+ System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
+ final String loanProductJSON = new LoanProductTestBuilder() //
+ .withPrincipal("1,00,000.00") //
+ .withNumberOfRepayments("4") //
+ .withRepaymentAfterEvery("1") //
+ .withRepaymentTypeAsMonth() //
+ .withinterestRatePerPeriod("1") //
+ .withInterestRateFrequencyTypeAsMonths() //
+ .withAmortizationTypeAsEqualInstallments() //
+ .withInterestTypeAsDecliningBalance() //
+ .withTranches(multiDisburseLoan) //
+ .withAccounting(accountingRule, accounts).build(null);
+ return loanProductJSON ;
+ }
+
+ public static String createLoanProductWithVaribleConfig(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
+ System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
+ final String loanProductJSON = new LoanProductTestBuilder() //
+ .withPrincipal("1,00,000.00") //
+ .withNumberOfRepayments("4") //
+ .withRepaymentAfterEvery("1") //
+ .withRepaymentTypeAsMonth() //
+ .withinterestRatePerPeriod("1") //
+ .withInterestRateFrequencyTypeAsMonths() //
+ .withAmortizationTypeAsEqualInstallments() //
+ .withInterestTypeAsDecliningBalance() //
+ .withTranches(multiDisburseLoan) //
+ .withInterestCalculationPeriodTypeAsRepaymentPeriod(true)//
+ .withVariableInstallmentsConfig(Boolean.TRUE, new Integer(5), new Integer(90))//
+ .withAccounting(accountingRule, accounts).build(null);
+ return loanProductJSON ;
+ }
+
+ public static String createLoanProductWithVaribleConfigwithEqualPrincipal(final boolean multiDisburseLoan, final String accountingRule, final Account... accounts) {
+ System.out.println("------------------------------CREATING NEW LOAN PRODUCT ---------------------------------------");
+ final String loanProductJSON = new LoanProductTestBuilder() //
+ .withPrincipal("1,00,000.00") //
+ .withNumberOfRepayments("4") //
+ .withRepaymentAfterEvery("1") //
+ .withRepaymentTypeAsMonth() //
+ .withinterestRatePerPeriod("1") //
+ .withInterestRateFrequencyTypeAsMonths() //
+ .withAmortizationTypeAsEqualPrincipalPayment() //
+ .withInterestTypeAsDecliningBalance() //
+ .withTranches(multiDisburseLoan) //
+ .withInterestCalculationPeriodTypeAsRepaymentPeriod(true)//
+ .withVariableInstallmentsConfig(Boolean.TRUE, new Integer(5), new Integer(90))//
+ .withAccounting(accountingRule, accounts).build(null);
+ return loanProductJSON ;
+ }
+
+ public static String applyForLoanApplication(final Integer clientID, final Integer loanProductID, List charges,
+ final String savingsId, String principal) {
+ System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
+ final String loanApplicationJSON = new LoanApplicationTestBuilder() //
+ .withPrincipal(principal) //
+ .withLoanTermFrequency("4") //
+ .withLoanTermFrequencyAsMonths() //
+ .withNumberOfRepayments("4") //
+ .withRepaymentEveryAfter("1") //
+ .withRepaymentFrequencyTypeAsMonths() //
+ .withInterestRatePerPeriod("2") //
+ .withAmortizationTypeAsEqualInstallments() //
+ .withInterestTypeAsDecliningBalance() //
+ .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
+ .withExpectedDisbursementDate("20 September 2011") //
+ .withSubmittedOnDate("20 September 2011") //
+ .withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId);
+ return loanApplicationJSON ;
+ }
+
+ public static String applyForLoanApplicationWithEqualPrincipal(final Integer clientID, final Integer loanProductID, List charges,
+ final String savingsId, String principal) {
+ System.out.println("--------------------------------APPLYING FOR LOAN APPLICATION--------------------------------");
+ final String loanApplicationJSON = new LoanApplicationTestBuilder() //
+ .withPrincipal(principal) //
+ .withLoanTermFrequency("4") //
+ .withLoanTermFrequencyAsMonths() //
+ .withNumberOfRepayments("4") //
+ .withRepaymentEveryAfter("1") //
+ .withRepaymentFrequencyTypeAsMonths() //
+ .withInterestRatePerPeriod("2") //
+ .withAmortizationTypeAsEqualPrincipalPayments() //
+ .withInterestTypeAsDecliningBalance() //
+ .withInterestCalculationPeriodTypeSameAsRepaymentPeriod() //
+ .withExpectedDisbursementDate("20 September 2011") //
+ .withSubmittedOnDate("20 September 2011") //
+ .withCharges(charges).build(clientID.toString(), loanProductID.toString(), savingsId);
+ return loanApplicationJSON ;
+ }
+
+ public static String createDeleteVariations(ArrayList