fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject [1/2] fineract git commit: 324 , 325
Date Fri, 16 Jun 2017 15:02:47 GMT
Repository: fineract
Updated Branches:
  refs/heads/develop 0cd1e3965 -> 18e85856f


324 , 325


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

Branch: refs/heads/develop
Commit: 03b564f11636ccc6d7ba4ac2f0a958812dc64e6c
Parents: f537bae
Author: nazeer shaik <nazeer.shaik@confluxtechnologies.com>
Authored: Tue Jun 13 14:47:29 2017 +0530
Committer: nazeer shaik <nazeer.shaik@confluxtechnologies.com>
Committed: Tue Jun 13 14:47:29 2017 +0530

----------------------------------------------------------------------
 .../api/FixedDepositAccountsApiResource.java    | 16 ++++++++--
 .../savings/data/FixedDepositAccountData.java   | 10 ++++++
 .../savings/data/SavingsAccountChargeData.java  | 10 ++++++
 ...ntWritePlatformServiceJpaRepositoryImpl.java | 32 ++++++++++++++++----
 4 files changed, 60 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/fineract/blob/03b564f1/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResource.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResource.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResource.java
index ae8f87d..49cba4f 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResource.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/api/FixedDepositAccountsApiResource.java
@@ -18,6 +18,7 @@
  */
 package org.apache.fineract.portfolio.savings.api;
 
+import java.math.BigDecimal;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
@@ -175,16 +176,27 @@ public class FixedDepositAccountsApiResource {
 
         final FixedDepositAccountData account = (FixedDepositAccountData) this.depositAccountReadPlatformService.retrieveOneWithChartSlabs(
                 DepositAccountType.FIXED_DEPOSIT, accountId);
-
+        
         final Set<String> mandatoryResponseParameters = new HashSet<>();
         final FixedDepositAccountData accountTemplate = populateTemplateAndAssociations(accountId,
account, staffInSelectedOfficeOnly,
                 chargeStatus, uriInfo, mandatoryResponseParameters);
-
+        accountTemplate.setActivationCharge(getActivationCharge(accountId));
         final ApiRequestJsonSerializationSettings settings = this.apiRequestParameterHelper.process(uriInfo.getQueryParameters(),
                 mandatoryResponseParameters);
         return this.toApiJsonSerializer.serialize(settings, accountTemplate,
                 DepositsApiConstants.FIXED_DEPOSIT_ACCOUNT_RESPONSE_DATA_PARAMETERS);
     }
+    
+    private BigDecimal getActivationCharge(Long accountId){
+        BigDecimal activationCharge = BigDecimal.ZERO;
+        Collection<SavingsAccountChargeData> savingCharges = this.savingsAccountChargeReadPlatformService.retrieveSavingsAccountCharges(accountId,
"active");
+        for (SavingsAccountChargeData savingsAccountChargeData : savingCharges) {
+            if(savingsAccountChargeData.isSavingsActivation()){
+                activationCharge = activationCharge.add(savingsAccountChargeData.getAmountOutstanding());
+            }
+        }
+        return activationCharge;
+    }
 
     private FixedDepositAccountData populateTemplateAndAssociations(final Long accountId,
final FixedDepositAccountData savingsAccount,
             final boolean staffInSelectedOfficeOnly, final String chargeStatus, final UriInfo
uriInfo,

http://git-wip-us.apache.org/repos/asf/fineract/blob/03b564f1/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/FixedDepositAccountData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/FixedDepositAccountData.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/FixedDepositAccountData.java
index a69a3c7..60ee6a2 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/FixedDepositAccountData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/FixedDepositAccountData.java
@@ -53,6 +53,7 @@ public class FixedDepositAccountData extends DepositAccountData {
     private LocalDate maturityDate;
     private Integer depositPeriod;
     private EnumOptionData depositPeriodFrequency;
+    private BigDecimal activationCharge;
 
     // used for account close
     private EnumOptionData onAccountClosure;
@@ -449,4 +450,13 @@ public class FixedDepositAccountData extends DepositAccountData {
         return new HashCodeBuilder(17, 37).append(this.id).append(this.accountNo).toHashCode();
     }
 
+    
+    public BigDecimal getActivationCharge() {
+        return this.activationCharge;
+    }
+
+    
+    public void setActivationCharge(BigDecimal activationCharge) {
+        this.activationCharge = activationCharge;
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/03b564f1/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountChargeData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountChargeData.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountChargeData.java
index 18f207b..81245c0 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountChargeData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/data/SavingsAccountChargeData.java
@@ -158,4 +158,14 @@ public class SavingsAccountChargeData {
     public boolean isAnnualFee() {
         return ChargeTimeType.fromInt(this.chargeTimeType.getId().intValue()).isAnnualFee();
     }
+    
+    public boolean isSavingsActivation() {
+        return ChargeTimeType.fromInt(this.chargeTimeType.getId().intValue()).isSavingsActivation();
+    }
+
+    public BigDecimal getAmountOutstanding() {
+        return this.amountOutstanding;
+    } 
+    
+    
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/fineract/blob/03b564f1/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java
b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java
index 8726bdd..80f7158 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/savings/service/DepositAccountWritePlatformServiceJpaRepositoryImpl.java
@@ -208,13 +208,12 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements
Depo
         updateExistingTransactionsDetails(account, existingTransactionIds, existingReversedTransactionIds);
 
         final Map<String, Object> changes = account.activate(user, command, DateUtils.getLocalDateOfTenant());
-
+        Money activationChargeAmount = getActivationCharge(account);
         if (!changes.isEmpty()) {
             final Locale locale = command.extractLocale();
-            final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
-            Money amountForDeposit = account.activateWithBalance();
+            final DateTimeFormatter fmt = DateTimeFormat.forPattern(command.dateFormat()).withLocale(locale);
           
+            Money amountForDeposit = account.activateWithBalance().plus(activationChargeAmount);
           
             if (amountForDeposit.isGreaterThanZero()) {
-
                 final PortfolioAccountData portfolioAccountData = this.accountAssociationsReadPlatformService
                         .retriveSavingsLinkedAssociation(savingsId);
 
@@ -235,6 +234,9 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements
Depo
                 }
                 final boolean isInterestTransfer = false;
                 final LocalDate postInterestOnDate = null;
+                if(activationChargeAmount.isGreaterThanZero()){
+                    payActivationCharge(account, user);
+                }                
                 if (account.isBeforeLastPostingPeriod(account.getActivationLocalDate()))
{
                     final LocalDate today = DateUtils.getLocalDateOfTenant();
                     account.postInterest(mc, today, isInterestTransfer, isSavingsInterestPostingAtCurrentPeriodEnd,
@@ -259,8 +261,7 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements
Depo
             account.validateAccountBalanceDoesNotBecomeNegative(SavingsAccountTransactionType.PAY_CHARGE.name(),
                     depositAccountOnHoldTransactions);
             this.savingAccountRepositoryWrapper.saveAndFlush(account);
-        }
-
+        }     
         postJournalEntries(account, existingTransactionIds, existingReversedTransactionIds);
 
         return new CommandProcessingResultBuilder() //
@@ -273,6 +274,25 @@ public class DepositAccountWritePlatformServiceJpaRepositoryImpl implements
Depo
                 .build();
     }
 
+    private Money getActivationCharge(final FixedDepositAccount account) {
+        Money activationChargeAmount = Money.zero(account.getCurrency());
+        for (SavingsAccountCharge savingsAccountCharge : account.charges()) {
+            if (savingsAccountCharge.isSavingsActivation()) {
+                activationChargeAmount = activationChargeAmount.plus(savingsAccountCharge.getAmount(account.getCurrency()));
+            }
+        }
+        return activationChargeAmount;
+    }
+    
+    private void payActivationCharge(final FixedDepositAccount account, AppUser user){
+        for (SavingsAccountCharge savingsAccountCharge : account.charges()) {
+            if (savingsAccountCharge.isSavingsActivation()) {
+                account.payCharge(savingsAccountCharge, savingsAccountCharge.getAmount(account.getCurrency()),
+                        account.getActivationLocalDate(), user);
+            }
+        }
+    }
+
     @Transactional
     @Override
     public CommandProcessingResult activateRDAccount(final Long savingsId, final JsonCommand
command) {


Mime
View raw message