fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject [1/2] incubator-fineract git commit: FINERACT-89 : 1st tranche will appear twice in repayment schedule when disbursement date and first repayment date is on same date
Date Mon, 13 Mar 2017 11:56:10 GMT
Repository: incubator-fineract
Updated Branches:
  refs/heads/develop f1f3d6516 -> f159e59c1


FINERACT-89 : 1st tranche will appear twice in repayment schedule when disbursement date and
first repayment date is on same date


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

Branch: refs/heads/develop
Commit: 069c8ada5688eda871246969fe1bf7d1f3c39f5a
Parents: b36ba8e
Author: nazeer1100126 <nazeer.shaik@confluxtechnologies.com>
Authored: Tue Mar 7 19:45:29 2017 +0530
Committer: nazeer1100126 <nazeer.shaik@confluxtechnologies.com>
Committed: Tue Mar 7 19:45:29 2017 +0530

----------------------------------------------------------------------
 .../service/LoanReadPlatformServiceImpl.java    | 39 +++++++++++---------
 1 file changed, 22 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/069c8ada/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
index 46d9795..4bf7326 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/service/LoanReadPlatformServiceImpl.java
@@ -92,7 +92,6 @@ import org.apache.fineract.portfolio.loanaccount.data.ScheduleGeneratorDTO;
 import org.apache.fineract.portfolio.loanaccount.domain.Loan;
 import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleInstallment;
 import org.apache.fineract.portfolio.loanaccount.domain.LoanRepaymentScheduleTransactionProcessorFactory;
-import org.apache.fineract.portfolio.loanaccount.domain.LoanRepository;
 import org.apache.fineract.portfolio.loanaccount.domain.LoanRepositoryWrapper;
 import org.apache.fineract.portfolio.loanaccount.domain.LoanStatus;
 import org.apache.fineract.portfolio.loanaccount.domain.LoanSubStatus;
@@ -1065,30 +1064,36 @@ public class LoanReadPlatformServiceImpl implements LoanReadPlatformService
{
                 final boolean complete = rs.getBoolean("complete");
                 if (disbursementData != null) {
                     BigDecimal principal = BigDecimal.ZERO;
-                    for (DisbursementData data : disbursementData) {
+                    for (final 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(
-                                        data.disbursementDate(), data.amount(), disbursementChargeAmount,
data.isDisbursed());
-                                periods.add(periodData);
-                            } else {
-                                final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
-                                        data.disbursementDate(), data.amount(), disbursementChargeAmount.add(data.getChargeAmount()),
data.isDisbursed());
-                                periods.add(periodData);
+                            if (periods.size() == 0) {
+                                principal = principal.add(data.amount());
+                                LoanSchedulePeriodData periodData = null;
+                                if (data.getChargeAmount() == null) {
+                                    periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(),
data.amount(),
+                                            disbursementChargeAmount, data.isDisbursed());
+                                } else {
+                                    periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(),
data.amount(),
+                                            disbursementChargeAmount.add(data.getChargeAmount()),
data.isDisbursed());
+                                }
+                                if (periodData != null) {
+                                    periods.add(periodData);
+                                }
+                                this.outstandingLoanPrincipalBalance = this.outstandingLoanPrincipalBalance.add(data.amount());
                             }
-                            this.outstandingLoanPrincipalBalance = this.outstandingLoanPrincipalBalance.add(data.amount());
                         } else if (data.isDueForDisbursement(fromDate, dueDate)) {
                             if (!excludePastUndisbursed
                                     || (excludePastUndisbursed && (data.isDisbursed()
|| !data.disbursementDate().isBefore(LocalDate.now())))) {
                                 principal = principal.add(data.amount());
+                                LoanSchedulePeriodData periodData = null;
                                 if (data.getChargeAmount() == null) {
-                                    final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
-                                            data.disbursementDate(), data.amount(), BigDecimal.ZERO,
data.isDisbursed());
-                                    periods.add(periodData);
+                                    periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(),
data.amount(),
+                                            BigDecimal.ZERO, data.isDisbursed());
                                 } else {
-                                    final LoanSchedulePeriodData periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(
-                                            data.disbursementDate(), data.amount(), data.getChargeAmount(),
data.isDisbursed());
+                                    periodData = LoanSchedulePeriodData.disbursementOnlyPeriod(data.disbursementDate(),
data.amount(),
+                                            data.getChargeAmount(), data.isDisbursed());
+                                }
+                                if (periodData != null) {
                                     periods.add(periodData);
                                 }
                                 this.outstandingLoanPrincipalBalance = this.outstandingLoanPrincipalBalance.add(data.amount());


Mime
View raw message