fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject incubator-fineract git commit: FINERACT-126 - Not able to Submit the loan application if multi tranche is added and the Expected disbursement on field is left blank displays internal server error
Date Tue, 31 Jan 2017 10:44:57 GMT
Repository: incubator-fineract
Updated Branches:
  refs/heads/develop d8a0a0742 -> e1a0e3f1e


FINERACT-126 - Not able to Submit the loan application if multi tranche is added and the Expected
disbursement on field is left blank displays internal server error


Project: http://git-wip-us.apache.org/repos/asf/incubator-fineract/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-fineract/commit/e1a0e3f1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/e1a0e3f1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/e1a0e3f1

Branch: refs/heads/develop
Commit: e1a0e3f1ea3d75f7f93189ec1cf47d3239311c86
Parents: d8a0a07
Author: Nazeer Hussain Shaik <nazeer.shaik@confluxtechnologies.com>
Authored: Mon Jan 23 16:30:09 2017 +0530
Committer: Nazeer Hussain Shaik <nazeer.shaik@confluxtechnologies.com>
Committed: Mon Jan 23 16:30:09 2017 +0530

----------------------------------------------------------------------
 ...LoanApplicationCommandFromApiJsonHelper.java | 34 +++++++-------------
 1 file changed, 12 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/e1a0e3f1/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java
index 523207d..198f524 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/serialization/LoanApplicationCommandFromApiJsonHelper.java
@@ -1077,7 +1077,6 @@ public final class LoanApplicationCommandFromApiJsonHelper {
         if (this.fromApiJsonHelper.parameterExists(LoanApiConstants.disbursementDataParameterName,
element) && expectedDisbursement != null
                 && totalPrincipal != null) {
             BigDecimal tatalDisbursement = BigDecimal.ZERO;
-            boolean isFirstinstallmentOnExpectedDisbursementDate = false;
             final JsonArray variationArray = this.fromApiJsonHelper.extractJsonArrayNamed(LoanApiConstants.disbursementDataParameterName,
                     element);
             List<LocalDate> expectedDisbursementDates = new ArrayList<>();
@@ -1085,18 +1084,23 @@ public final class LoanApplicationCommandFromApiJsonHelper {
                 int i = 0;
                 do {
                     final JsonObject jsonObject = variationArray.get(i).getAsJsonObject();
-                    if (jsonObject.has(LoanApiConstants.disbursementDateParameterName)
-                            && jsonObject.has(LoanApiConstants.disbursementPrincipalParameterName))
{
                         LocalDate expectedDisbursementDate = this.fromApiJsonHelper.extractLocalDateNamed(
                                 LoanApiConstants.disbursementDateParameterName, jsonObject,
dateFormat, locale);
-                        if (expectedDisbursementDates.contains(expectedDisbursementDate))
{
+                        baseDataValidator.reset().parameter(LoanApiConstants.disbursementDataParameterName)
+                        .parameterAtIndexArray(LoanApiConstants.disbursementDateParameterName,
i).value(expectedDisbursementDate)
+                        .notNull();
+                        if(i == 0 && expectedDisbursementDate != null &&
!expectedDisbursement.equals(expectedDisbursementDate)) {
+                        	 baseDataValidator.reset().parameter(LoanApiConstants.disbursementDateParameterName)
+                             .failWithCode(LoanApiConstants.DISBURSEMENT_DATE_START_WITH_ERROR);
+                        }else if(i > 0 && expectedDisbursementDate != null &&
expectedDisbursementDate.isBefore(expectedDisbursement)) {
+                        	baseDataValidator.reset().parameter(LoanApiConstants.disbursementDataParameterName)
+                            .failWithCode(LoanApiConstants.DISBURSEMENT_DATE_BEFORE_ERROR);
+                        }
+                        
+                        if (expectedDisbursementDate != null && expectedDisbursementDates.contains(expectedDisbursementDate))
{
                             baseDataValidator.reset().parameter(LoanApiConstants.disbursementDateParameterName)
                                     .failWithCode(LoanApiConstants.DISBURSEMENT_DATE_UNIQUE_ERROR);
                         }
-                        if (expectedDisbursementDate.isBefore(expectedDisbursement)) {
-                            baseDataValidator.reset().parameter(LoanApiConstants.disbursementDataParameterName)
-                                    .failWithCode(LoanApiConstants.DISBURSEMENT_DATE_BEFORE_ERROR);
-                        }
                         expectedDisbursementDates.add(expectedDisbursementDate);
 
                         BigDecimal principal = this.fromApiJsonHelper.extractBigDecimalNamed(
@@ -1106,22 +1110,8 @@ public final class LoanApplicationCommandFromApiJsonHelper {
                         if (principal != null) {
                             tatalDisbursement = tatalDisbursement.add(principal);
                         }
-
-                        baseDataValidator.reset().parameter(LoanApiConstants.disbursementDataParameterName)
-                                .parameterAtIndexArray(LoanApiConstants.disbursementDateParameterName,
i).value(expectedDisbursementDate)
-                                .notNull();
-
-                        if (expectedDisbursement.equals(expectedDisbursementDate)) {
-                            isFirstinstallmentOnExpectedDisbursementDate = true;
-                        }
-
-                    }
                     i++;
                 } while (i < variationArray.size());
-                if (!isFirstinstallmentOnExpectedDisbursementDate) {
-                    baseDataValidator.reset().parameter(LoanApiConstants.disbursementDateParameterName)
-                            .failWithCode(LoanApiConstants.DISBURSEMENT_DATE_START_WITH_ERROR);
-                }
 
                 if (tatalDisbursement.compareTo(totalPrincipal) == 1) {
                     baseDataValidator.reset().parameter(LoanApiConstants.disbursementPrincipalParameterName)


Mime
View raw message