fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [1/2] incubator-fineract git commit: fix for repayment info
Date Fri, 04 Mar 2016 05:45:23 GMT
Repository: incubator-fineract
Updated Branches:
  refs/heads/develop c1125cfdf -> 14499a26f


fix for repayment info


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

Branch: refs/heads/develop
Commit: fa02a3a712c4a798de9cf780fe2a0a959256aa83
Parents: 1485dc9
Author: sachinkulkarni12 <sachin.kulkarni@confluxtechnologies.com>
Authored: Thu Mar 3 16:45:24 2016 +0530
Committer: sachinkulkarni12 <sachin.kulkarni@confluxtechnologies.com>
Committed: Thu Mar 3 16:59:38 2016 +0530

----------------------------------------------------------------------
 .../service/LoanScheduleAssembler.java          |  4 +-
 ...onWritePlatformServiceJpaRepositoryImpl.java |  2 +-
 .../loanaccount/service/LoanAssembler.java      | 47 ++----------------
 .../loanaccount/service/LoanUtilService.java    | 50 +++++++++++++++++++-
 4 files changed, 57 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/fa02a3a7/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
index f6db0d2..3c284ee 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/loanschedule/service/LoanScheduleAssembler.java
@@ -540,8 +540,10 @@ public class LoanScheduleAssembler {
 
         validateDisbursementDateIsOnNonWorkingDay(loanApplicationTerms.getExpectedDisbursementDate(),
workingDays);
         validateDisbursementDateIsOnHoliday(loanApplicationTerms.getExpectedDisbursementDate(),
isHolidayEnabled, holidays);
+        
+        Set<LoanDisbursementDetails> loanDisbursementDetails = this.loanUtilService.fetchDisbursementData(element.getAsJsonObject());
 
-        return assembleLoanScheduleFrom(loanApplicationTerms, isHolidayEnabled, holidays,
workingDays, element, null);
+        return assembleLoanScheduleFrom(loanApplicationTerms, isHolidayEnabled, holidays,
workingDays, element, loanDisbursementDetails);
     }
 
     public LoanScheduleModel assembleLoanScheduleFrom(final LoanApplicationTerms loanApplicationTerms,
final boolean isHolidayEnabled,

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/fa02a3a7/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java
index e859b0d..869dd91 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanApplicationWritePlatformServiceJpaRepositoryImpl.java
@@ -508,7 +508,7 @@ public class LoanApplicationWritePlatformServiceJpaRepositoryImpl implements
Loa
                 LoanChargeData chargeData = new LoanChargeData(charge.getId(), charge.getDueLocalDate(),
charge.amountOrPercentage());
                 chargesMap.put(charge.getId(), chargeData);
             }
-            Set<LoanDisbursementDetails> disbursementDetails = this.loanAssembler.fetchDisbursementData(command.parsedJson()
+            Set<LoanDisbursementDetails> disbursementDetails = this.loanUtilService.fetchDisbursementData(command.parsedJson()
                     .getAsJsonObject());
 
             /**

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/fa02a3a7/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAssembler.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAssembler.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAssembler.java
index a5f9af5..755a751 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAssembler.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanAssembler.java
@@ -20,13 +20,10 @@ package org.apache.fineract.portfolio.loanaccount.service;
 
 import java.math.BigDecimal;
 import java.util.Arrays;
-import java.util.Date;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Locale;
 import java.util.Set;
 
-import org.apache.commons.lang.StringUtils;
 import org.apache.fineract.infrastructure.codes.domain.CodeValue;
 import org.apache.fineract.infrastructure.codes.domain.CodeValueRepositoryWrapper;
 import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
@@ -85,10 +82,7 @@ import org.apache.fineract.useradministration.domain.AppUser;
 import org.joda.time.LocalDate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
-
-import com.google.gson.JsonArray;
 import com.google.gson.JsonElement;
-import com.google.gson.JsonObject;
 
 @Service
 public class LoanAssembler {
@@ -110,6 +104,7 @@ public class LoanAssembler {
     private final HolidayRepository holidayRepository;
     private final ConfigurationDomainService configurationDomainService;
     private final WorkingDaysRepositoryWrapper workingDaysRepository;
+    private final LoanUtilService loanUtilService;
 
     @Autowired
     public LoanAssembler(final FromJsonHelper fromApiJsonHelper, final LoanRepositoryWrapper
loanRepository,
@@ -121,7 +116,7 @@ public class LoanAssembler {
             final CollateralAssembler loanCollateralAssembler, final LoanSummaryWrapper loanSummaryWrapper,
             final LoanRepaymentScheduleTransactionProcessorFactory loanRepaymentScheduleTransactionProcessorFactory,
             final HolidayRepository holidayRepository, final ConfigurationDomainService configurationDomainService,
-            final WorkingDaysRepositoryWrapper workingDaysRepository) {
+            final WorkingDaysRepositoryWrapper workingDaysRepository, final LoanUtilService
loanUtilService) {
         this.fromApiJsonHelper = fromApiJsonHelper;
         this.loanRepository = loanRepository;
         this.loanProductRepository = loanProductRepository;
@@ -139,6 +134,7 @@ public class LoanAssembler {
         this.holidayRepository = holidayRepository;
         this.configurationDomainService = configurationDomainService;
         this.workingDaysRepository = workingDaysRepository;
+        this.loanUtilService = loanUtilService;
     }
 
     public Loan assembleFrom(final Long accountId) {
@@ -192,7 +188,7 @@ public class LoanAssembler {
         }
         BigDecimal maxOutstandingLoanBalance = null;
         if (loanProduct.isMultiDisburseLoan()) {
-            disbursementDetails = fetchDisbursementData(element.getAsJsonObject());
+            disbursementDetails = this.loanUtilService.fetchDisbursementData(element.getAsJsonObject());
             final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(element.getAsJsonObject());
             maxOutstandingLoanBalance = this.fromApiJsonHelper.extractBigDecimalNamed(LoanApiConstants.maxOutstandingBalanceParameterName,
                     element, locale);
@@ -307,41 +303,6 @@ public class LoanAssembler {
         return loanApplication;
     }
 
-    public Set<LoanDisbursementDetails> fetchDisbursementData(final JsonObject command)
{
-        final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(command);
-        final String dateFormat = this.fromApiJsonHelper.extractDateFormatParameter(command);
-        Set<LoanDisbursementDetails> disbursementDatas = new HashSet<>();
-        if (command.has(LoanApiConstants.disbursementDataParameterName)) {
-            final JsonArray disbursementDataArray = command.getAsJsonArray(LoanApiConstants.disbursementDataParameterName);
-            if (disbursementDataArray != null && disbursementDataArray.size() >
0) {
-                int i = 0;
-                do {
-                    final JsonObject jsonObject = disbursementDataArray.get(i).getAsJsonObject();
-                    Date expectedDisbursementDate = null;
-                    Date actualDisbursementDate = null;
-                    BigDecimal principal = null;
-
-                    if (jsonObject.has(LoanApiConstants.disbursementDateParameterName)) {
-                        LocalDate date = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.disbursementDateParameterName,
-                                jsonObject, dateFormat, locale);
-                        if (date != null) {
-                            expectedDisbursementDate = date.toDate();
-                        }
-                    }
-                    if (jsonObject.has(LoanApiConstants.disbursementPrincipalParameterName)
-                            && jsonObject.get(LoanApiConstants.disbursementPrincipalParameterName).isJsonPrimitive()
-                            && StringUtils.isNotBlank((jsonObject.get(LoanApiConstants.disbursementPrincipalParameterName).getAsString())))
{
-                        principal = jsonObject.getAsJsonPrimitive(LoanApiConstants.disbursementPrincipalParameterName).getAsBigDecimal();
-                    }
-
-                    disbursementDatas.add(new LoanDisbursementDetails(expectedDisbursementDate,
actualDisbursementDate, principal));
-                    i++;
-                } while (i < disbursementDataArray.size());
-            }
-        }
-        return disbursementDatas;
-    }
-
     private LoanLifecycleStateMachine defaultLoanLifecycleStateMachine() {
         final List<LoanStatus> allowedLoanStatuses = Arrays.asList(LoanStatus.values());
         return new DefaultLoanLifecycleStateMachine(allowedLoanStatuses);

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/fa02a3a7/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java
index 103209b..ce63594 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanUtilService.java
@@ -19,10 +19,15 @@
 package org.apache.fineract.portfolio.loanaccount.service;
 
 import java.math.BigDecimal;
+import java.util.Date;
+import java.util.HashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.Set;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.fineract.infrastructure.configuration.domain.ConfigurationDomainService;
+import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
 import org.apache.fineract.organisation.holiday.domain.Holiday;
 import org.apache.fineract.organisation.holiday.domain.HolidayRepository;
 import org.apache.fineract.organisation.holiday.domain.HolidayStatusType;
@@ -42,15 +47,20 @@ import org.apache.fineract.portfolio.floatingrates.data.FloatingRateDTO;
 import org.apache.fineract.portfolio.floatingrates.data.FloatingRatePeriodData;
 import org.apache.fineract.portfolio.floatingrates.exception.FloatingRateNotFoundException;
 import org.apache.fineract.portfolio.floatingrates.service.FloatingRatesReadPlatformService;
+import org.apache.fineract.portfolio.loanaccount.api.LoanApiConstants;
 import org.apache.fineract.portfolio.loanaccount.data.HolidayDetailDTO;
 import org.apache.fineract.portfolio.loanaccount.data.ScheduleGeneratorDTO;
 import org.apache.fineract.portfolio.loanaccount.domain.Loan;
+import org.apache.fineract.portfolio.loanaccount.domain.LoanDisbursementDetails;
 import org.apache.fineract.portfolio.loanaccount.loanschedule.domain.LoanScheduleGeneratorFactory;
 import org.apache.fineract.portfolio.loanproduct.domain.LoanProductRelatedDetail;
 import org.joda.time.LocalDate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
+
 @Component
 public class LoanUtilService {
 
@@ -61,12 +71,14 @@ public class LoanUtilService {
     private final WorkingDaysRepositoryWrapper workingDaysRepository;
     private final LoanScheduleGeneratorFactory loanScheduleFactory;
     private final FloatingRatesReadPlatformService floatingRatesReadPlatformService;
+    private final FromJsonHelper fromApiJsonHelper;
 
     @Autowired
     public LoanUtilService(final ApplicationCurrencyRepositoryWrapper applicationCurrencyRepository,
             final CalendarInstanceRepository calendarInstanceRepository, final ConfigurationDomainService
configurationDomainService,
             final HolidayRepository holidayRepository, final WorkingDaysRepositoryWrapper
workingDaysRepository,
-            final LoanScheduleGeneratorFactory loanScheduleFactory, final FloatingRatesReadPlatformService
floatingRatesReadPlatformService) {
+            final LoanScheduleGeneratorFactory loanScheduleFactory, final FloatingRatesReadPlatformService
floatingRatesReadPlatformService,
+            final FromJsonHelper fromApiJsonHelper) {
         this.applicationCurrencyRepository = applicationCurrencyRepository;
         this.calendarInstanceRepository = calendarInstanceRepository;
         this.configurationDomainService = configurationDomainService;
@@ -74,6 +86,7 @@ public class LoanUtilService {
         this.workingDaysRepository = workingDaysRepository;
         this.loanScheduleFactory = loanScheduleFactory;
         this.floatingRatesReadPlatformService = floatingRatesReadPlatformService;
+        this.fromApiJsonHelper = fromApiJsonHelper;
     }
 
     public ScheduleGeneratorDTO buildScheduleGeneratorDTO(final Loan loan, final LocalDate
recalculateFrom) {
@@ -204,5 +217,40 @@ public class LoanUtilService {
         }
         return calculatedRepaymentsStartingFromDate;
     }
+    
+    public Set<LoanDisbursementDetails> fetchDisbursementData(final JsonObject command)
{
+        final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(command);
+        final String dateFormat = this.fromApiJsonHelper.extractDateFormatParameter(command);
+        Set<LoanDisbursementDetails> disbursementDatas = new HashSet<>();
+        if (command.has(LoanApiConstants.disbursementDataParameterName)) {
+            final JsonArray disbursementDataArray = command.getAsJsonArray(LoanApiConstants.disbursementDataParameterName);
+            if (disbursementDataArray != null && disbursementDataArray.size() >
0) {
+                int i = 0;
+                do {
+                    final JsonObject jsonObject = disbursementDataArray.get(i).getAsJsonObject();
+                    Date expectedDisbursementDate = null;
+                    Date actualDisbursementDate = null;
+                    BigDecimal principal = null;
+
+                    if (jsonObject.has(LoanApiConstants.disbursementDateParameterName)) {
+                        LocalDate date = this.fromApiJsonHelper.extractLocalDateNamed(LoanApiConstants.disbursementDateParameterName,
+                                jsonObject, dateFormat, locale);
+                        if (date != null) {
+                            expectedDisbursementDate = date.toDate();
+                        }
+                    }
+                    if (jsonObject.has(LoanApiConstants.disbursementPrincipalParameterName)
+                            && jsonObject.get(LoanApiConstants.disbursementPrincipalParameterName).isJsonPrimitive()
+                            && StringUtils.isNotBlank((jsonObject.get(LoanApiConstants.disbursementPrincipalParameterName).getAsString())))
{
+                        principal = jsonObject.getAsJsonPrimitive(LoanApiConstants.disbursementPrincipalParameterName).getAsBigDecimal();
+                    }
+
+                    disbursementDatas.add(new LoanDisbursementDetails(expectedDisbursementDate,
actualDisbursementDate, principal));
+                    i++;
+                } while (i < disbursementDataArray.size());
+            }
+        }
+        return disbursementDatas;
+    }
 
 }


Mime
View raw message