This is an automated email from the ASF dual-hosted git repository.
angelboxes pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git
The following commit(s) were added to refs/heads/develop by this push:
new fa6794c Stop creating unnecessary overdue charge when amount is 0
new 4d3d37c Merge pull request #614 from mohitsinha/new-develop
fa6794c is described below
commit fa6794c22c9d0510aa5075d9bae891c844f99432
Author: Mohit Sinha <[email protected]>
AuthorDate: Wed Jul 24 20:26:28 2019 +0700
Stop creating unnecessary overdue charge when amount is 0
---
.../ClientLoanIntegrationTest.java | 2 +-
.../integrationtests/SchedulerJobsTestResults.java | 64 ++++++++++++++++++++++
.../common/charges/ChargesHelper.java | 4 +-
.../common/loans/LoanTransactionHelper.java | 6 ++
.../LoanWritePlatformServiceJpaRepositoryImpl.java | 3 +
5 files changed, 76 insertions(+), 3 deletions(-)
diff --git
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
index 66740c8..0c20d99 100644
---
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
+++
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/ClientLoanIntegrationTest.java
@@ -3787,7 +3787,7 @@ public class ClientLoanIntegrationTest {
todaysDate = Calendar.getInstance(Utils.getTimeZoneOfTenant());
Integer overdueFeeChargeId =
ChargesHelper.createCharges(this.requestSpec, this.responseSpec,
-
ChargesHelper.getLoanOverdueFeeJSONWithCalculattionTypePercentage());
+
ChargesHelper.getLoanOverdueFeeJSONWithCalculattionTypePercentage("10"));
Assert.assertNotNull(overdueFeeChargeId);
final Integer clientID = ClientHelper.createClient(this.requestSpec,
this.responseSpec);
diff --git
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java
index 64a4d13..e559850 100644
---
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java
+++
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/SchedulerJobsTestResults.java
@@ -725,6 +725,70 @@ public class SchedulerJobsTestResults {
}
@Test
+ public void
testAvoidUnncessaryPenaltyWhenAmountZeroForOverdueLoansJobOutcome() throws
InterruptedException {
+ this.savingsAccountHelper = new SavingsAccountHelper(this.requestSpec,
this.responseSpec);
+ this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec,
this.responseSpec);
+ this.loanTransactionHelper = new
LoanTransactionHelper(this.requestSpec, this.responseSpec);
+
+ final Integer clientID = ClientHelper.createClient(this.requestSpec,
this.responseSpec);
+ Assert.assertNotNull(clientID);
+
+ Integer overdueFeeChargeId = ChargesHelper
+ .createCharges(this.requestSpec, this.responseSpec,
ChargesHelper.getLoanOverdueFeeJSONWithCalculattionTypePercentage("0.000001"));
+ Assert.assertNotNull(overdueFeeChargeId);
+
+ final Integer loanProductID =
createLoanProduct(overdueFeeChargeId.toString());
+ Assert.assertNotNull(loanProductID);
+
+ final Integer loanID = applyForLoanApplication(clientID.toString(),
loanProductID.toString(), null);
+ Assert.assertNotNull(loanID);
+
+ HashMap loanStatusHashMap =
LoanStatusChecker.getStatusOfLoan(this.requestSpec, this.responseSpec, loanID);
+ LoanStatusChecker.verifyLoanIsPending(loanStatusHashMap);
+
+ loanStatusHashMap =
this.loanTransactionHelper.approveLoan(AccountTransferTest.LOAN_APPROVAL_DATE,
loanID);
+ LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
+
+ loanStatusHashMap =
this.loanTransactionHelper.disburseLoan(AccountTransferTest.LOAN_APPROVAL_DATE_PLUS_ONE,
loanID);
+ LoanStatusChecker.verifyLoanIsActive(loanStatusHashMap);
+
+ ArrayList<HashMap> repaymentScheduleDataBefore =
this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
+ this.responseSpec, loanID);
+
+ String JobName = "Apply penalty to overdue loans";
+ Integer jobId = 12;
+
+ this.schedulerJobHelper.executeJob(JobName);
+
+ HashMap schedulerJob =
this.schedulerJobHelper.getSchedulerJobById(this.requestSpec,
this.responseSpec, jobId.toString());
+
+ Assert.assertNotNull(schedulerJob);
+ while ((Boolean) schedulerJob.get("currentlyRunning") == true) {
+ Thread.sleep(15000);
+ schedulerJob =
this.schedulerJobHelper.getSchedulerJobById(this.requestSpec,
this.responseSpec, jobId.toString());
+ Assert.assertNotNull(schedulerJob);
+ }
+
+ final HashMap chargeData =
ChargesHelper.getChargeById(this.requestSpec, this.responseSpec,
overdueFeeChargeId);
+
+ ArrayList<HashMap> repaymentScheduleDataAfter =
this.loanTransactionHelper.getLoanRepaymentSchedule(this.requestSpec,
+ this.responseSpec, loanID);
+
+ Assert.assertEquals("Verifying From Penalty Charges due fot first
Repayment after Successful completion of Scheduler Job",
+ 0, repaymentScheduleDataAfter.get(1).get("penaltyChargesDue"));
+
+ final ArrayList loanCharges =
this.loanTransactionHelper.getLoanCharges(this.requestSpec,
+ this.responseSpec, loanID);
+
+ Assert.assertNull("Verifying that charge isn't created when the amount
is 0", loanCharges);
+
+ loanStatusHashMap = this.loanTransactionHelper.undoDisbursal(loanID);
+ LoanStatusChecker.verifyLoanIsApproved(loanStatusHashMap);
+ LoanStatusChecker.verifyLoanIsWaitingForDisbursal(loanStatusHashMap);
+
+ }
+
+ @Test
public void testUpdateOverdueDaysForNPA() throws InterruptedException {
this.schedulerJobHelper = new SchedulerJobHelper(this.requestSpec,
this.responseSpec);
this.loanTransactionHelper = new
LoanTransactionHelper(this.requestSpec, this.responseSpec);
diff --git
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
index 521cd79..a3a267a 100755
---
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
+++
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
@@ -275,10 +275,10 @@ public class ChargesHelper {
return chargesCreateJson;
}
- public static String getLoanOverdueFeeJSONWithCalculattionTypePercentage()
{
+ public static String
getLoanOverdueFeeJSONWithCalculattionTypePercentage(String
penaltyPercentageAmount) {
final HashMap<String, Object> map = populateDefaultsForLoan();
map.put("penalty", ChargesHelper.penalty);
- map.put("amount", "10");
+ map.put("amount", penaltyPercentageAmount);
map.put("chargePaymentMode",
ChargesHelper.CHARGE_PAYMENT_MODE_REGULAR);
map.put("chargeTimeType", CHARGE_OVERDUE_INSTALLMENT_FEE);
map.put("chargeCalculationType",
ChargesHelper.CHARGE_CALCULATION_TYPE_PERCENTAGE_AMOUNT_AND_INTEREST);
diff --git
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
index 19aa98b..1e4196d 100755
---
a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
+++
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/loans/LoanTransactionHelper.java
@@ -106,6 +106,12 @@ public class LoanTransactionHelper {
return (ArrayList) response.get("periods");
}
+ public ArrayList getLoanCharges(final RequestSpecification requestSpec,
final ResponseSpecification responseSpec,
+ final Integer loanID) {
+ final String URL = "/fineract-provider/api/v1/loans/" + loanID +
"?associations=charges&" + Utils.TENANT_IDENTIFIER;
+ return (ArrayList) Utils.performServerGet(requestSpec, responseSpec,
URL, "charges");
+ }
+
public ArrayList getLoanFutureRepaymentSchedule(final RequestSpecification
requestSpec, final ResponseSpecification responseSpec,
final Integer loanID) {
final String URL = "/fineract-provider/api/v1/loans/" + loanID +
"?associations=repaymentSchedule,futureSchedule&"
diff --git
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
index 068265f..94a8308 100755
---
a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
+++
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanWritePlatformServiceJpaRepositoryImpl.java
@@ -2490,6 +2490,9 @@ public class LoanWritePlatformServiceJpaRepositoryImpl
implements LoanWritePlatf
final LoanCharge loanCharge =
LoanCharge.createNewFromJson(loan, chargeDefinition, command, entry.getValue());
+ if (BigDecimal.ZERO.compareTo(loanCharge.amount()) == 0) {
+ continue;
+ }
LoanOverdueInstallmentCharge overdueInstallmentCharge = new
LoanOverdueInstallmentCharge(loanCharge, installment,
entry.getKey());
loanCharge.updateOverdueInstallmentCharge(overdueInstallmentCharge);