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-345 : Should not allow to add guarantor, If savings account transaction date is greter that loan application submitted date
Date Wed, 22 Mar 2017 06:05:33 GMT
Repository: incubator-fineract
Updated Branches:
  refs/heads/develop 8cc560cd8 -> e47f4dde8


FINERACT-345 : Should not allow to add guarantor, If savings account transaction date is greter
that loan application submitted 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/e47f4dde
Tree: http://git-wip-us.apache.org/repos/asf/incubator-fineract/tree/e47f4dde
Diff: http://git-wip-us.apache.org/repos/asf/incubator-fineract/diff/e47f4dde

Branch: refs/heads/develop
Commit: e47f4dde8b33701d3c3a092abc9b4e54c747d913
Parents: 8cc560c
Author: nazeer1100126 <nazeer.shaik@confluxtechnologies.com>
Authored: Tue Mar 14 18:28:08 2017 +0530
Committer: nazeer1100126 <nazeer.shaik@confluxtechnologies.com>
Committed: Tue Mar 14 19:25:20 2017 +0530

----------------------------------------------------------------------
 .../service/GuarantorDomainServiceImpl.java     | 21 +++++++++++++++++---
 .../savings/domain/SavingsAccount.java          |  5 +++++
 2 files changed, 23 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/e47f4dde/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/service/GuarantorDomainServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/service/GuarantorDomainServiceImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/service/GuarantorDomainServiceImpl.java
index ff45966..50a72df 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/service/GuarantorDomainServiceImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/loanaccount/guarantor/service/GuarantorDomainServiceImpl.java
@@ -19,7 +19,6 @@
 package org.apache.fineract.portfolio.loanaccount.guarantor.service;
 
 import java.math.BigDecimal;
-import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -57,6 +56,8 @@ import org.apache.fineract.portfolio.paymentdetail.domain.PaymentDetail;
 import org.apache.fineract.portfolio.savings.domain.DepositAccountOnHoldTransaction;
 import org.apache.fineract.portfolio.savings.domain.DepositAccountOnHoldTransactionRepository;
 import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
+import org.apache.fineract.portfolio.savings.domain.SavingsAccountAssembler;
+import org.apache.fineract.portfolio.savings.domain.SavingsAccountTransaction;
 import org.apache.fineract.portfolio.savings.exception.InsufficientAccountBalanceException;
 import org.joda.time.LocalDate;
 import org.joda.time.format.DateTimeFormatter;
@@ -73,6 +74,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService
{
     private final BusinessEventNotifierService businessEventNotifierService;
     private final DepositAccountOnHoldTransactionRepository depositAccountOnHoldTransactionRepository;
     private final Map<Long, Long> releaseLoanIds = new HashMap<>(2);
+    private final SavingsAccountAssembler savingsAccountAssembler;
     
 
     @Autowired
@@ -81,13 +83,15 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService
{
             final GuarantorFundingTransactionRepository guarantorFundingTransactionRepository,
             final AccountTransfersWritePlatformService accountTransfersWritePlatformService,
             final BusinessEventNotifierService businessEventNotifierService,
-            final DepositAccountOnHoldTransactionRepository depositAccountOnHoldTransactionRepository)
{
+            final DepositAccountOnHoldTransactionRepository depositAccountOnHoldTransactionRepository,
+            final SavingsAccountAssembler savingsAccountAssembler) {
         this.guarantorRepository = guarantorRepository;
         this.guarantorFundingRepository = guarantorFundingRepository;
         this.guarantorFundingTransactionRepository = guarantorFundingTransactionRepository;
         this.accountTransfersWritePlatformService = accountTransfersWritePlatformService;
         this.businessEventNotifierService = businessEventNotifierService;
         this.depositAccountOnHoldTransactionRepository = depositAccountOnHoldTransactionRepository;
+        this.savingsAccountAssembler = savingsAccountAssembler;
     }
 
     @PostConstruct
@@ -327,7 +331,17 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService
{
                 final List<GuarantorFundingDetails> fundingDetails = guarantor.getGuarantorFundDetails();
                 for (GuarantorFundingDetails guarantorFundingDetails : fundingDetails) {
                     if (guarantorFundingDetails.getStatus().isActive()) {
-                        SavingsAccount savingsAccount = guarantorFundingDetails.getLinkedSavingsAccount();
+                        final SavingsAccount savingsAccount = guarantorFundingDetails.getLinkedSavingsAccount();
+                        if (loan.isApproved() && !loan.isDisbursed()) {
+                            final List<SavingsAccountTransaction> transactions = new
ArrayList<>();
+                            for (final SavingsAccountTransaction transaction : savingsAccount.getTransactions())
{
+                                if (!transaction.getTransactionLocalDate().isAfter(loan.getApprovedOnDate()))
{
+                                    transactions.add(transaction);
+                                }
+                            }
+                            this.savingsAccountAssembler.setHelpers(savingsAccount);
+                            savingsAccount.updateSavingsAccountSummary(transactions);
+                        }
                         savingsAccount.holdFunds(guarantorFundingDetails.getAmount());
                         totalGuarantee = totalGuarantee.add(guarantorFundingDetails.getAmount());
                         DepositAccountOnHoldTransaction onHoldTransaction = DepositAccountOnHoldTransaction.hold(savingsAccount,
@@ -340,6 +354,7 @@ public class GuarantorDomainServiceImpl implements GuarantorDomainService
{
                         if (savingsAccount.getWithdrawableBalance().compareTo(BigDecimal.ZERO)
== -1) {
                             insufficientBalanceIds.add(savingsAccount.getId());
                         }
+                        savingsAccount.updateSavingsAccountSummary(savingsAccount.getTransactions());
                     }
                 }
             }

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/e47f4dde/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
index d851aa5..9825d81 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/domain/SavingsAccount.java
@@ -2817,4 +2817,9 @@ public class SavingsAccount extends AbstractPersistableCustom<Long>
{
         charges.size();
         savingsOfficerHistory.size();
     }
+    
+    public void updateSavingsAccountSummary(final List<SavingsAccountTransaction> transactions)
{
+        this.summary.updateSummary(this.currency, this.savingsAccountTransactionSummaryWrapper,
transactions);
+    }
+    
 }
\ No newline at end of file


Mime
View raw message