fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nazeer1100...@apache.org
Subject [3/3] incubator-fineract git commit: Shares Integration Tests and Fixes
Date Tue, 17 May 2016 13:17:37 GMT
Shares Integration Tests and Fixes


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

Branch: refs/heads/develop
Commit: 7ae9b67d930c50b736d995910c4b8f3184569db7
Parents: 0b81e80
Author: Nazeer Hussain Shaik <nazeer.shaik@confluxtechnologies.com>
Authored: Tue May 17 12:34:22 2016 +0530
Committer: Nazeer Hussain Shaik <nazeer.shaik@confluxtechnologies.com>
Committed: Tue May 17 12:34:54 2016 +0530

----------------------------------------------------------------------
 .../common/charges/ChargesHelper.java           |   67 +-
 .../shares/DividendsIntegrationTests.java       |  203 ++++
 .../common/shares/ShareAccountHelper.java       |  144 +++
 .../shares/ShareAccountIntegrationTests.java    | 1032 ++++++++++++++++++
 .../shares/ShareAccountTransactionHelper.java   |   55 +
 .../shares/ShareDividendsTransactionHelper.java |   58 +
 .../common/shares/ShareProductHelper.java       |  199 ++++
 .../shares/ShareProductTransactionHelper.java   |   51 +
 .../accounts/api/AccountsApiResource.java       |   56 +-
 .../service/AccountReadPlatformService.java     |    4 +-
 .../fineract/portfolio/note/domain/Note.java    |   17 +
 .../portfolio/note/domain/NoteType.java         |    5 +-
 .../products/api/ProductsApiResource.java       |   61 +-
 .../exception/ResourceNotFoundException.java    |   33 +
 .../shareaccounts/domain/ShareAccount.java      |   29 +-
 .../domain/ShareAccountTransaction.java         |    4 +
 .../ShareAccountDataSerializer.java             |  108 +-
 .../ShareAccountReadPlatformServiceImpl.java    |   49 +-
 ...ntWritePlatformServiceJpaRepositoryImpl.java |   34 +-
 .../service/SharesEnumerations.java             |   33 +-
 .../ShareProductDataSerializer.java             |    3 +-
 .../ShareProductReadPlatformServiceImpl.java    |   19 +-
 .../core_db/V307__add_share_notes.sql           |    2 +
 23 files changed, 2136 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/7ae9b67d/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
index c8134a6..b4b7dc5 100755
--- a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/charges/ChargesHelper.java
@@ -37,7 +37,8 @@ public class ChargesHelper {
     private static final Integer CHARGE_APPLIES_TO_LOAN = 1;
     private static final Integer CHARGE_APPLIES_TO_SAVINGS = 2;
     private static final Integer CHARGE_APPLIES_TO_CLIENT = 3;
-
+    private static final Integer CHARGE_APPLIES_TO_SHARES = 4;
+    
     private static final Integer CHARGE_DISBURSEMENT_FEE = 1;
     private static final Integer CHARGE_SPECIFIED_DUE_DATE = 2;
     private static final Integer CHARGE_SAVINGS_ACTIVATION_FEE = 3;
@@ -48,6 +49,10 @@ public class ChargesHelper {
     private static final Integer CHARGE_OVERDUE_INSTALLMENT_FEE = 9;
     private static final Integer CHARGE_OVERDRAFT_FEE = 10;
     private static final Integer WEEKLY_FEE = 11;
+    private static final Integer SHAREACCOUNT_ACTIVATION = 13 ;
+    private static final Integer SHARE_PURCHASE = 14 ;
+    private static final Integer SHARE_REDEEM = 15 ;
+    
     private static final Integer CHARGE_SAVINGS_NO_ACTIVITY_FEE = 16;
     
     private static final Integer CHARGE_CLIENT_SPECIFIED_DUE_DATE = 1;
@@ -235,6 +240,27 @@ public class ChargesHelper {
         return getLoanInstallmentJSON(ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT, ChargesHelper.amount,
ChargesHelper.penalty);
     }
 
+    public static String getShareAccountActivationChargeJson() {
+        HashMap<String, Object> map = populateDefaultsShareActivationCharge() ;
+        String chargesCreateJson = new Gson().toJson(map);
+        System.out.println(chargesCreateJson);
+        return chargesCreateJson;
+    }
+    
+    public static String getShareAccountPurchaseChargeJson() {
+        HashMap<String, Object> map = populateDefaultsSharePurchaseFlatCharge() ;
+        String chargesCreateJson = new Gson().toJson(map);
+        System.out.println(chargesCreateJson);
+        return chargesCreateJson;
+    }
+    
+    public static String getShareAccountRedeemChargeJson() {
+        HashMap<String, Object> map = populateDefaultsShareRedeemFlatCharge() ;
+        String chargesCreateJson = new Gson().toJson(map);
+        System.out.println(chargesCreateJson);
+        return chargesCreateJson;
+    }
+    
     public static String getLoanOverdueFeeJSON() {
         final HashMap<String, Object> map = populateDefaultsForLoan();
         map.put("penalty", ChargesHelper.penalty);
@@ -287,6 +313,45 @@ public class ChargesHelper {
         return map;
     }
 
+    public static HashMap<String, Object> populateDefaultsShareActivationCharge() {
+        final HashMap<String, Object> map = new HashMap<>();
+        map.put("active", ChargesHelper.active);
+        map.put("amount", ChargesHelper.amount);
+        map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
+        map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
+        map.put("chargeTimeType",ChargesHelper.SHAREACCOUNT_ACTIVATION);
+        map.put("currencyCode", ChargesHelper.currencyCode);
+        map.put("locale", CommonConstants.locale);
+        map.put("name", Utils.randomNameGenerator("Charge_Share_Activation_", 8));
+        return map;
+    }
+    
+    public static HashMap<String, Object> populateDefaultsSharePurchaseFlatCharge()
{
+        final HashMap<String, Object> map = new HashMap<>();
+        map.put("active", ChargesHelper.active);
+        map.put("amount", ChargesHelper.amount);
+        map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
+        map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
+        map.put("chargeTimeType",ChargesHelper.SHARE_PURCHASE);
+        map.put("currencyCode", ChargesHelper.currencyCode);
+        map.put("locale", CommonConstants.locale);
+        map.put("name", Utils.randomNameGenerator("Charge_Share_Purchase_", 8));
+        return map;
+    }
+    
+    public static HashMap<String, Object> populateDefaultsShareRedeemFlatCharge() {
+        final HashMap<String, Object> map = new HashMap<>();
+        map.put("active", ChargesHelper.active);
+        map.put("amount", ChargesHelper.amount);
+        map.put("chargeAppliesTo", ChargesHelper.CHARGE_APPLIES_TO_SHARES);
+        map.put("chargeCalculationType", ChargesHelper.CHARGE_CALCULATION_TYPE_FLAT);
+        map.put("chargeTimeType",ChargesHelper.SHARE_REDEEM);
+        map.put("currencyCode", ChargesHelper.currencyCode);
+        map.put("locale", CommonConstants.locale);
+        map.put("name", Utils.randomNameGenerator("Charge_Share_Redeem_", 8));
+        return map;
+    }
+    
     public static Integer createCharges(final RequestSpecification requestSpec, final ResponseSpecification
responseSpec,
             final String request) {
         return Utils.performServerPost(requestSpec, responseSpec, CREATE_CHARGES_URL, request,
"resourceId");

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/7ae9b67d/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/DividendsIntegrationTests.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/DividendsIntegrationTests.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/DividendsIntegrationTests.java
new file mode 100644
index 0000000..5634dce
--- /dev/null
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/DividendsIntegrationTests.java
@@ -0,0 +1,203 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests.common.shares;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.fineract.integrationtests.common.ClientHelper;
+import org.apache.fineract.integrationtests.common.Utils;
+import org.apache.fineract.integrationtests.common.savings.SavingsAccountHelper;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.google.gson.Gson;
+import com.jayway.restassured.builder.RequestSpecBuilder;
+import com.jayway.restassured.builder.ResponseSpecBuilder;
+import com.jayway.restassured.http.ContentType;
+import com.jayway.restassured.specification.RequestSpecification;
+import com.jayway.restassured.specification.ResponseSpecification;
+
+
+public class DividendsIntegrationTests {
+
+    private final String[] dates = {"01 Jan 2015", "01 Apr 2015", "01 Oct 2015", "01 Dec
2015", "01 Mar 2016"} ;
+    private final String[] shares = {"100", "200", "300", "100", "500"} ;
+    
+    private RequestSpecification requestSpec;
+    private ResponseSpecification responseSpec;
+
+    @Before
+    public void setup() {
+        Utils.initializeRESTAssured();
+        this.requestSpec = new RequestSpecBuilder().setContentType(ContentType.JSON).build();
+        this.requestSpec.header("Authorization", "Basic " + Utils.loginIntoServerAndGetBase64EncodedAuthenticationKey());
+        this.responseSpec = new ResponseSpecBuilder().expectStatusCode(200).build();
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void testCreateDividends() {
+        DateFormat simple = new SimpleDateFormat("dd MMM yyyy");
+        final Integer productId = createShareProduct() ;
+        ArrayList<Integer> clients = new ArrayList<>() ;
+        ArrayList<Integer> savingAccounts = new ArrayList<>() ;
+        ArrayList<Integer> shareAccounts = new ArrayList<>() ;
+        for(int i = 0  ; i < 5; i++) {
+            final Integer clientId = ClientHelper.createClient(this.requestSpec, this.responseSpec);
+            clients.add(clientId) ;
+            Assert.assertNotNull(clientId);
+            Integer savingsAccountId = SavingsAccountHelper.openSavingsAccount(requestSpec,
responseSpec, clientId, "1000");
+            savingAccounts.add(savingsAccountId) ;
+            Assert.assertNotNull(savingsAccountId);
+            final Integer shareAccountId = createShareAccount(clientId, productId, savingsAccountId,
dates[i], shares[i]);
+            shareAccounts.add(shareAccountId) ;
+            Assert.assertNotNull(shareAccountId);
+            Map<String, Object> shareAccountData = ShareAccountTransactionHelper
+                    .retrieveShareAccount(shareAccountId, requestSpec, responseSpec);
+            Assert.assertNotNull(shareAccountData);    
+         // Approve share Account
+            Map<String, Object> approveMap = new HashMap<>();
+            approveMap.put("note", "Share Account Approval Note");
+            approveMap.put("dateFormat", "dd MMMM yyyy");
+            approveMap.put("approvedDate", "01 Jan 2016");
+            approveMap.put("locale", "en");
+            String approve = new Gson().toJson(approveMap);
+            ShareAccountTransactionHelper.postCommand("approve", shareAccountId, approve,
requestSpec, responseSpec);
+            //Activate Share Account
+            Map<String, Object> activateMap = new HashMap<>();
+            activateMap.put("dateFormat", "dd MMMM yyyy");
+            activateMap.put("activatedDate", "01 Jan 2016");
+            activateMap.put("locale", "en");
+            String activateJson = new Gson().toJson(activateMap);
+            ShareAccountTransactionHelper.postCommand("activate", shareAccountId, activateJson,
requestSpec, responseSpec);
+        }
+        
+        Map<String, Object> dividendsMap = new HashMap<>() ;
+        dividendsMap.put("dividendPeriodStartDate", "01 Jan 2015") ;
+        dividendsMap.put("dividendPeriodEndDate", "01 Apr 2016") ;
+        dividendsMap.put("dividendAmount", "50000") ;
+        dividendsMap.put("dateFormat", "dd MMMM yyyy");
+        dividendsMap.put("locale", "en");
+        String createDividendsJson = new Gson().toJson(dividendsMap);
+        final Integer dividendId = ShareDividendsTransactionHelper.createShareProductDividends(productId,
createDividendsJson, requestSpec, responseSpec) ;
+        
+        Map<String, Object> productdividends = ShareDividendsTransactionHelper.retrieveAllDividends(productId,
requestSpec, responseSpec);
+        Assert.assertEquals("1", String.valueOf(productdividends.get("totalFilteredRecords")));
+        Map<String,Object> dividend = ((List<Map<String,Object>>)productdividends.get("pageItems")).get(0)
;
+        Assert.assertEquals("50000.0", String.valueOf(dividend.get("amount"))) ;
+        Map<String, Object> status = (Map<String, Object>)dividend.get("status")
;
+        Assert.assertEquals("shareAccountDividendStatusType.initiated", String.valueOf(status.get("code")));
+        List<Integer> startdateList = (List<Integer>) dividend.get("dividendPeriodStartDate");
+        Calendar cal = Calendar.getInstance();
+        cal.set(startdateList.get(0), startdateList.get(1) - 1, startdateList.get(2));
+        Date startDate = cal.getTime();
+        Assert.assertEquals("01 Jan 2015", simple.format(startDate));
+        List<Integer> enddateList = (List<Integer>) dividend.get("dividendPeriodEndDate");
+        cal = Calendar.getInstance();
+        cal.set(enddateList.get(0), enddateList.get(1) - 1, enddateList.get(2));
+        Date endDate = cal.getTime();
+        Assert.assertEquals("01 Apr 2016", simple.format(endDate));
+        
+        
+        
+        Map<String, Object> dividenddetails = ShareDividendsTransactionHelper.retrieveDividendDetails(productId,
dividendId, requestSpec, responseSpec) ;
+        Assert.assertEquals("5", String.valueOf(dividenddetails.get("totalFilteredRecords")));
+        List<Map<String, Object>> pageItems = (List<Map<String, Object>>)dividenddetails.get("pageItems")
;
+        for(Map<String, Object> dividendData: pageItems) {
+            Map<String, Object> accountData = (Map<String, Object>) dividendData.get("accountData")
; 
+            String accountId = String.valueOf(accountData.get("id")) ;
+            if(String.valueOf(shareAccounts.get(0)).equals(accountId)) {
+                Assert.assertEquals("11320.755", String.valueOf(dividendData.get("amount")));
+            }else if(String.valueOf(shareAccounts.get(1)).equals(accountId)) {
+                Assert.assertEquals("18172.791", String.valueOf(dividendData.get("amount")));
+            }else if(String.valueOf(shareAccounts.get(2)).equals(accountId)) {
+                Assert.assertEquals("13629.593", String.valueOf(dividendData.get("amount")));
+            }else if(String.valueOf(shareAccounts.get(3)).equals(accountId)) {
+                Assert.assertEquals("3028.7983", String.valueOf(dividendData.get("amount")));
+            }else if(String.valueOf(shareAccounts.get(4)).equals(accountId)) {
+                Assert.assertEquals("3848.0637", String.valueOf(dividendData.get("amount")));
+            }
+            Map<String, Object> statusMap = (Map<String, Object>) dividendData.get("status")
;
+            Assert.assertEquals("shareAccountDividendStatusType.initiated", String.valueOf(statusMap.get("code")))
;
+        }
+        
+        String jsonString = "" ;
+        ShareDividendsTransactionHelper.postCommand("approve", productId, dividendId, jsonString,
requestSpec, responseSpec) ;
+        
+        productdividends = ShareDividendsTransactionHelper.retrieveAllDividends(productId,
requestSpec, responseSpec);
+        Assert.assertEquals("1", String.valueOf(productdividends.get("totalFilteredRecords")));
+        dividend = ((List<Map<String,Object>>)productdividends.get("pageItems")).get(0)
;
+        Assert.assertEquals("50000.0", String.valueOf(dividend.get("amount"))) ;
+        status = (Map<String, Object>)dividend.get("status") ;
+        Assert.assertEquals("shareAccountDividendStatusType.approved", String.valueOf(status.get("code")));
+        startdateList = (List<Integer>) dividend.get("dividendPeriodStartDate");
+        cal = Calendar.getInstance();
+        cal.set(startdateList.get(0), startdateList.get(1) - 1, startdateList.get(2));
+        startDate = cal.getTime();
+        Assert.assertEquals("01 Jan 2015", simple.format(startDate));
+        enddateList = (List<Integer>) dividend.get("dividendPeriodEndDate");
+        cal = Calendar.getInstance();
+        cal.set(enddateList.get(0), enddateList.get(1) - 1, enddateList.get(2));
+        endDate = cal.getTime();
+        Assert.assertEquals("01 Apr 2016", simple.format(endDate));
+        
+        dividenddetails = ShareDividendsTransactionHelper.retrieveDividendDetails(productId,
dividendId, requestSpec, responseSpec) ;
+        Assert.assertEquals("5", String.valueOf(dividenddetails.get("totalFilteredRecords")));
+        pageItems = (List<Map<String, Object>>)dividenddetails.get("pageItems")
;
+        for(Map<String, Object> dividendData: pageItems) {
+            Map<String, Object> accountData = (Map<String, Object>) dividendData.get("accountData")
; 
+            String accountId = String.valueOf(accountData.get("id")) ;
+            if(String.valueOf(shareAccounts.get(0)).equals(accountId)) {
+                Assert.assertEquals("11320.755", String.valueOf(dividendData.get("amount")));
+            }else if(String.valueOf(shareAccounts.get(1)).equals(accountId)) {
+                Assert.assertEquals("18172.791", String.valueOf(dividendData.get("amount")));
+            }else if(String.valueOf(shareAccounts.get(2)).equals(accountId)) {
+                Assert.assertEquals("13629.593", String.valueOf(dividendData.get("amount")));
+            }else if(String.valueOf(shareAccounts.get(3)).equals(accountId)) {
+                Assert.assertEquals("3028.7983", String.valueOf(dividendData.get("amount")));
+            }else if(String.valueOf(shareAccounts.get(4)).equals(accountId)) {
+                Assert.assertEquals("3848.0637", String.valueOf(dividendData.get("amount")));
+            }
+            Map<String, Object> statusMap = (Map<String, Object>) dividendData.get("status")
;
+            Assert.assertEquals("shareAccountDividendStatusType.initiated", String.valueOf(statusMap.get("code")))
;
+        }
+        
+    }
+    
+    private Integer createShareProduct() {
+        String shareProductJson = new ShareProductHelper().build();
+        return ShareProductTransactionHelper.createShareProduct(shareProductJson, requestSpec,
responseSpec);
+    }
+    
+    private Integer createShareAccount(final Integer clientId, final Integer productId, final
Integer savingsAccountId,
+            String applicationDate, String requestedShares) {
+        String josn = new ShareAccountHelper().withClientId(String.valueOf(clientId)).withProductId(String.valueOf(productId))
+                .withExternalId("External1").withSavingsAccountId(String.valueOf(savingsAccountId)).withSubmittedDate("01
Jan 2016")
+                .withApplicationDate(applicationDate).withRequestedShares(requestedShares).build();
+        return ShareAccountTransactionHelper.createShareAccount(josn, requestSpec, responseSpec);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/7ae9b67d/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountHelper.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountHelper.java
b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountHelper.java
new file mode 100644
index 0000000..9984656
--- /dev/null
+++ b/fineract-provider/src/integrationTest/java/org/apache/fineract/integrationtests/common/shares/ShareAccountHelper.java
@@ -0,0 +1,144 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.integrationtests.common.shares;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.google.gson.Gson;
+
+
+public class ShareAccountHelper {
+
+    private static final String LOCALE = "en_GB";
+    
+    private String clientId ;
+    
+    private String productId ;
+    
+    private String submittedDate ;
+    
+    private String externalId ;
+    
+    private String savingsAccountId ;
+    
+    private String requestedShares ;
+    
+    private String applicationDate ;
+    
+    private String allowDividendCalculationForInactiveClients ;
+    
+    private String minimumActivePeriod ;
+    
+    private String minimumActivePeriodFrequencyType ;
+    
+    private String lockinPeriodFrequency ;
+    
+    private String lockinPeriodFrequencyType ;
+    
+    private List<Map<String, Object>> charges = null ;
+            //chargeId , amount
+    
+    public String build() {
+        final HashMap<String, Object> map = new HashMap<>();
+        map.put("locale", LOCALE);
+        if(this.clientId != null) {
+            map.put("clientId", this.clientId) ;    
+        }
+        if(this.productId != null) {
+            map.put("productId", this.productId) ;
+        }
+        map.put("dateFormat", "dd MMMM yyyy");
+        
+        if(this.savingsAccountId != null) {
+            map.put("savingsAccountId", savingsAccountId) ;
+        }
+ 
+        if(externalId != null) {
+            map.put("externalId", this.externalId) ;
+        }
+        
+        if(submittedDate != null) {
+            map.put("submittedDate", this.submittedDate) ;
+        }
+        
+        if(applicationDate != null) {
+            map.put("applicationDate", this.applicationDate) ;
+        }
+        
+        if(this.requestedShares != null) {
+            map.put("requestedShares", this.requestedShares) ;
+        }
+        
+        if(this.allowDividendCalculationForInactiveClients != null) {
+            map.put("allowDividendCalculationForInactiveClients", this.allowDividendCalculationForInactiveClients)
;
+        }
+        
+        if(this.charges != null) {
+           map.put("charges", this.charges) ;
+        }
+        
+        String shareAccountCreateJson = new Gson().toJson(map);
+        System.out.println(shareAccountCreateJson);
+        return shareAccountCreateJson;
+    }
+    
+    public ShareAccountHelper withClientId(final String clientId) {
+        this.clientId = clientId ;
+        return this ;
+    }
+    
+    public ShareAccountHelper withProductId(final String productId) {
+        this.productId = productId ;
+        return this ;
+    }
+    
+    public ShareAccountHelper withSavingsAccountId(final String savingsAccountId) {
+        this.savingsAccountId = savingsAccountId ;
+        return this ;
+    }
+    
+    public ShareAccountHelper withSubmittedDate(final String submittedDate) {
+        this.submittedDate = submittedDate ;
+        return this ;
+    }
+    
+    public ShareAccountHelper withRequestedShares(final String requestedShares) {
+        this.requestedShares = requestedShares ;
+        return this ;
+    }
+    
+    public ShareAccountHelper withApplicationDate(final String applicationDate) {
+        this.applicationDate = applicationDate ;
+        return this ;
+    }
+    
+    public ShareAccountHelper withExternalId(final String externalId) {
+        this.externalId = externalId ;
+        return this ;
+    }
+    
+    public ShareAccountHelper withCharges(final List<Map<String,Object>> charges)
{
+        this.charges = new ArrayList<>() ;
+        this.charges.addAll(charges) ;
+        return this ;
+    }
+}


Mime
View raw message