fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject [10/12] incubator-fineract git commit: Shares And Dividends Implementation
Date Wed, 13 Apr 2016 14:35:22 GMT
http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/data/ShareAccountData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/data/ShareAccountData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/data/ShareAccountData.java
deleted file mode 100644
index a7cc0e0..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/data/ShareAccountData.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * 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.portfolio.accounts.data;
-
-import java.util.Collection;
-import java.util.Date;
-
-import org.apache.fineract.accounting.glaccount.data.GLAccountData;
-import org.apache.fineract.infrastructure.core.data.EnumOptionData;
-import org.apache.fineract.organisation.monetary.data.CurrencyData;
-
-public class ShareAccountData implements AccountData{
-
-    private Long id;
-    
-    private String accountNo;
-    
-    private String externalId;
-
-    private Long productId;
-    
-    private String productName;
-    
-    private String loanProductDescription;
-    
-    private Long fieldOfficerId;
-    
-    private String fieldOfficerName;
-
-    private Long clientId;
-    
-    private String clientName;
-
-    private Long clientOfficeId;
-
-    private CurrencyData currency;
-
-    private Date submittedDate;
-
-    private Date approvedDate;
-
-    private Collection<PurchasedSharesData> purchasedShares;
-
-    private GLAccountData suspenseAccount;
-
-    private GLAccountData equityAccount;
-
-    private Long savingsAccountId;
-
-    private EnumOptionData lockPeriod;
-
-    private EnumOptionData minimumActivePeriodForDividends;
-    
-    private Boolean allowDividendCalculationForInactiveClients;
-    
-    private Collection<ShareChargeData> charges ;
-    
-    private String status ;
-    
-    public ShareAccountData(final Long id, final String accountNo, final Long clientId, final String clientName, final Long productId, final String productName,
-            final Long fieldOfficerId, final String externalId, final Date submittedDate, final Collection<PurchasedSharesData> purchasedShares, final GLAccountData suspenseAccount,
-            final GLAccountData equityAccount, final EnumOptionData lockPeriod, final EnumOptionData minimumActivePeriodForDividends,
-            final Boolean allowDividendCalculationForInactiveClients, final Collection<ShareChargeData> charges, final String status) {
-        this.id = id ;
-        this.accountNo = accountNo ;
-        this.clientId = clientId ;
-        this.clientName = clientName ;
-        this.productId = productId ;
-        this.productName = productName ;
-        this.fieldOfficerId = fieldOfficerId ;
-        this.externalId = externalId ;
-        this.submittedDate = submittedDate ;
-        this.purchasedShares = purchasedShares ;
-        this.suspenseAccount = suspenseAccount ;
-        this.equityAccount = equityAccount ;
-        this.lockPeriod = lockPeriod ;
-        this.minimumActivePeriodForDividends = minimumActivePeriodForDividends ;
-        this.allowDividendCalculationForInactiveClients = allowDividendCalculationForInactiveClients ;
-        this.charges = charges ;
-        this.status = status ;
-        
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/data/ShareChargeData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/data/ShareChargeData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/data/ShareChargeData.java
deleted file mode 100644
index ef302bd..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/data/ShareChargeData.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * 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.portfolio.accounts.data;
-
-
-public class ShareChargeData {
-
-    private Long accountId ;
-    
-    private Long chargeId ;
-    
-    public ShareChargeData(final Long accountId, final Long chargeId) {
-        this.accountId = accountId ;
-        this.chargeId = chargeId ;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/PurchasedShares.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/PurchasedShares.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/PurchasedShares.java
deleted file mode 100644
index afa4f4f..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/PurchasedShares.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/**
- * 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.portfolio.accounts.domain;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import org.apache.fineract.portfolio.accounts.data.PurchasedSharesData;
-import org.springframework.data.jpa.domain.AbstractPersistable;
-
-@Entity
-@Table(name = "m_purchasedshares")
-public class PurchasedShares extends AbstractPersistable<Long> {
-
-    @ManyToOne(optional = false)
-    @JoinColumn(name = "account_id", referencedColumnName = "id", nullable = false)
-    private ShareAccount shareAccount ;
-    
-    @Column(name = "purchased_date")
-    @Temporal(TemporalType.DATE)
-    private Date purchasedDate ;
-    
-    @Column(name = "share_count")
-    private Long totalShares ;
-    
-    @Column(name = "share_price")
-    private BigDecimal shareValue ; 
-    
-    @Column(name ="status")
-    private String status = "Submitted";
-    
-    protected PurchasedShares() {
-        
-    }
-    
-    public void setShareAccount(final ShareAccount shareAccount) {
-        this.shareAccount = shareAccount ;
-    }
-    
-    public PurchasedShares(final Date purchasedDate, final Long totalShares, final BigDecimal shareValue) {
-        this.purchasedDate = purchasedDate ;
-        this.totalShares = totalShares ;
-        this.shareValue = shareValue ;
-    }
-    
-    public PurchasedSharesData toData() {
-        return new PurchasedSharesData(this.purchasedDate, this.totalShares, this.shareValue, this.status) ;
-    }
-    
-    public Date getPurchasedDate() {
-        return this.purchasedDate ;
-    }
-    
-    public Long getTotalShares() {
-        return this.totalShares ;
-    }
-    
-    public BigDecimal getPurchasePrice() {
-        return this.shareValue ;
-    }
-    
-    public String getStatus() {
-        return this.status ;
-    }
-    
-    public void setStatus(String status) {
-        this.status = status ;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccount.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccount.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccount.java
deleted file mode 100644
index 55d4435..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccount.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/**
- * 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.portfolio.accounts.domain;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Set;
-
-import javax.persistence.CascadeType;
-import javax.persistence.Column;
-import javax.persistence.Embedded;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.OneToMany;
-import javax.persistence.Table;
-import javax.persistence.Temporal;
-import javax.persistence.TemporalType;
-
-import org.apache.fineract.accounting.glaccount.data.GLAccountData;
-import org.apache.fineract.accounting.glaccount.domain.GLAccount;
-import org.apache.fineract.infrastructure.core.data.EnumOptionData;
-import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom;
-import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
-import org.apache.fineract.portfolio.accounts.data.PurchasedSharesData;
-import org.apache.fineract.portfolio.accounts.data.ShareAccountData;
-import org.apache.fineract.portfolio.accounts.data.ShareChargeData;
-import org.apache.fineract.portfolio.client.domain.Client;
-import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
-import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
-import org.apache.fineract.portfolio.shares.domain.ShareProduct;
-import org.apache.fineract.useradministration.domain.AppUser;
-import org.hibernate.annotations.LazyCollection;
-import org.hibernate.annotations.LazyCollectionOption;
-import org.joda.time.DateTime;
-
-@Entity
-@Table(name = "m_shareaccounts")
-public class ShareAccount extends AbstractAuditableCustom<AppUser, Long> {
-
-    @ManyToOne
-    @JoinColumn(name = "client_id", nullable = true)
-    private Client client ;
-    
-    @ManyToOne
-    @JoinColumn(name = "product_id", nullable = true)
-    private ShareProduct shareProduct ;
-    
-    @Column(name = "submitted_date")
-    @Temporal(TemporalType.TIMESTAMP)
-    private Date submittedDate ;
-    
-    @Column(name = "approved_date")
-    @Temporal(TemporalType.TIMESTAMP)
-    private Date approvedDate ;
-    
-    @Column(name = "field_officer")
-    private Long fieldOfficerId ;
-    
-    @Column(name = "external_id")
-    private String externalId ;
-    
-    @Embedded
-    private MonetaryCurrency currency;
-    
-    @ManyToOne
-    @JoinColumn(name = "suspense_account", nullable = true)
-    private GLAccount suspenseAccount ;
-    
-    @ManyToOne
-    @JoinColumn(name = "equity_account", nullable = true)
-    private GLAccount equityAccount ;
-    
-    @ManyToOne
-    @JoinColumn(name = "savings_id", nullable = true)
-    private SavingsAccount savingsAccount ;
-    
-    @LazyCollection(LazyCollectionOption.FALSE)
-    @OneToMany(cascade = CascadeType.ALL, mappedBy = "shareAccount", orphanRemoval = true)
-    private Set<PurchasedShares> purchasedShares ;
-    
-    @Column(name = "allow_dividends_inactive_clients")
-    private Boolean allowDividendCalculationForInactiveClients;
-
-    @Enumerated(EnumType.ORDINAL)
-    @Column(name = "lock_period", nullable = true)
-    private PeriodFrequencyType lockPeriod;
-
-    @Enumerated(EnumType.ORDINAL)
-    @Column(name = "dividend_active_period", nullable = true)
-    private PeriodFrequencyType minimumActivePeriodForDividends;
-    
-    @Column(name = "status")
-    private String status = "Submitted"; //change it to enum
-    
-    @LazyCollection(LazyCollectionOption.FALSE)
-    @OneToMany(cascade = CascadeType.ALL, mappedBy = "shareAccount", orphanRemoval = true)
-    private Set<ShareAccountCharge> charges ;
-    
-    protected ShareAccount() {
-        
-    }
-    
-    public ShareAccount(final Client client, final ShareProduct shareProduct, final Date submittedDate, final Date approvedDate,
-            final Long fieldOfficerId , final String externalId, final MonetaryCurrency currency, GLAccount suspenseAccount, 
-            final GLAccount equityAccount, final SavingsAccount savingsAccount, final Set<PurchasedShares> purchasedShares,
-            final Boolean allowDividendCalculationForInactiveClients, final PeriodFrequencyType lockPeriod, 
-            final PeriodFrequencyType minimumActivePeriodForDividends, Set<ShareAccountCharge> charges,
-            AppUser createdBy, DateTime createdDate, AppUser lastModifiedBy, DateTime lastModifiedDate) {
-        this.client = client ;
-        this.shareProduct = shareProduct ;
-        this.submittedDate = submittedDate ;
-        this.approvedDate =  approvedDate ;
-        this.fieldOfficerId = fieldOfficerId ;
-        this.externalId = externalId ;
-        this.currency = currency ;
-        this.suspenseAccount = suspenseAccount ;
-        this.equityAccount = equityAccount ;
-        this.savingsAccount = savingsAccount ;
-        this.purchasedShares = purchasedShares ;
-        this.allowDividendCalculationForInactiveClients = allowDividendCalculationForInactiveClients ;
-        this.lockPeriod = lockPeriod ;
-        this.minimumActivePeriodForDividends = minimumActivePeriodForDividends ; 
-        this.charges = charges ;
-        setCreatedBy(createdBy) ;
-        setCreatedDate(createdDate) ;
-        setLastModifiedBy(lastModifiedBy) ;
-        setLastModifiedDate(lastModifiedDate) ;
-    }
-    
-    public boolean setShareProduct(final ShareProduct shareProduct) {
-        boolean toReturn = false ;
-        if(!this.shareProduct.getId().equals(shareProduct.getId())) {
-            this.shareProduct = shareProduct ;
-            toReturn = true ;
-        }
-        return toReturn ;
-    }
-    
-    public ShareProduct getShareProduct() {
-        return this.shareProduct ;
-    }
-    
-    public boolean setSubmittedDate(final Date submittedDate) {
-        boolean toReturn = false ;
-        if(!this.submittedDate.equals(submittedDate)) {
-            this.submittedDate = submittedDate ;
-            toReturn = true ;
-        }
-        return toReturn ;
-    }
-    
-    public boolean setApprovedDate(final Date approvedDate) {
-        boolean toReturn = false ;
-        if(!this.approvedDate.equals(approvedDate)) {
-            this.approvedDate = approvedDate ;
-            toReturn = true ;
-        }
-        return toReturn ;
-    }
-    
-    public boolean setFieldOfficer(final Long fieldOfficerId) {
-        boolean toReturn = false ;
-        if(!this.fieldOfficerId.equals(fieldOfficerId)) {
-            this.fieldOfficerId = fieldOfficerId ;
-            toReturn = true ;
-        }
-        return toReturn ;
-    }
-    
-    public boolean setExternalId(final String externalId) {
-        boolean toReturn = false ;
-        if(!this.externalId.equals(externalId)) {
-            this.externalId = externalId ;
-            toReturn = true ;
-        }
-        return toReturn ;
-    }
-    
-    public boolean setSuspenseAccount(GLAccount suspenseAccount) {
-        boolean returnValue = false;
-        if (!this.suspenseAccount.getId().equals(suspenseAccount.getId())) {
-            this.suspenseAccount = suspenseAccount;
-            returnValue = true;
-        }
-        return returnValue;
-    }
-
-    public boolean setEquityAccount(GLAccount equityAccount) {
-        boolean returnValue = false;
-        if (!this.equityAccount.getId().equals(equityAccount.getId())) {
-            this.equityAccount = equityAccount;
-            returnValue = true;
-        }
-        return returnValue;
-    }
-
-    public boolean setSavingsAccount(final SavingsAccount savingsAccount) {
-        boolean returnValue = false;
-        if (!this.savingsAccount.getId().equals(savingsAccount.getId())) {
-            this.savingsAccount = savingsAccount;
-            returnValue = true;
-        }
-        return returnValue;
-    }
-    
-    public boolean setPurchasedShares(Set<PurchasedShares> purchasedShares) {
-        this.purchasedShares = purchasedShares ;
-        return true ;
-    }
-    
-    public boolean setAllowDividendCalculationForInactiveClients(Boolean allowDividendCalculationForInactiveClients) {
-        boolean returnValue = false;
-        if (!this.allowDividendCalculationForInactiveClients.equals(allowDividendCalculationForInactiveClients)) {
-            this.allowDividendCalculationForInactiveClients = allowDividendCalculationForInactiveClients;
-            returnValue = true;
-        }
-        return returnValue;
-    }
-
-    public boolean setLockPeriod(final PeriodFrequencyType lockPeriod) {
-        boolean returnValue = false;
-        if (!this.lockPeriod.equals(lockPeriod)) {
-            this.lockPeriod = lockPeriod;
-            returnValue = true;
-        }
-        return returnValue;
-    }
-
-    public boolean setminimumActivePeriodForDividends(final PeriodFrequencyType minimumActivePeriodForDividends) {
-        boolean returnValue = false;
-        if (!this.minimumActivePeriodForDividends.equals(minimumActivePeriodForDividends)) {
-            this.minimumActivePeriodForDividends = minimumActivePeriodForDividends;
-            returnValue = true;
-        }
-        return returnValue;
-    }
-    
-    public boolean setCharges(final Set<ShareAccountCharge> charges) {
-        this.charges = charges ;
-        return true ;
-    }
-    //FIXME: Remove this
-    public void setTempId(Long id) {
-        setId(id) ;
-    }
-    
-    public ShareAccountData toData() {
-        String accountNo = "000025900"+getId() ;
-        Collection<PurchasedSharesData> purchasedSharesdata = new ArrayList<>();
-        for(PurchasedShares val: purchasedShares) {
-            purchasedSharesdata.add(new PurchasedSharesData(val.getPurchasedDate(), val.getTotalShares(), val.getPurchasePrice(), val.getStatus())) ;
-        }
-        Collection<ShareChargeData> chargesdata =  new ArrayList<>();
-        for(ShareAccountCharge charge: charges) {
-            chargesdata.add(new ShareChargeData(charge.getAccountId(), charge.getChargeId())) ;
-        }
-        
-        GLAccountData suspenseAccount1 = new GLAccountData(suspenseAccount.getId(), suspenseAccount.getName(), suspenseAccount.getGlCode());
-        GLAccountData equityAccount1 = new GLAccountData(equityAccount.getId(), equityAccount.getName(), equityAccount.getGlCode());
-        EnumOptionData lock = new EnumOptionData(this.lockPeriod.getValue().longValue(), this.lockPeriod.getCode(),
-                this.lockPeriod.toString());
-        EnumOptionData mini = new EnumOptionData(this.minimumActivePeriodForDividends.getValue().longValue(), this.minimumActivePeriodForDividends.getCode(),
-                this.minimumActivePeriodForDividends.toString());;
-                
-        ShareAccountData data = new ShareAccountData(getId(), accountNo, this.client.getId(), this.client.getDisplayName(), this.shareProduct.getId(), 
-                this.shareProduct.getProductName(), fieldOfficerId, externalId,
-                submittedDate, purchasedSharesdata, suspenseAccount1, equityAccount1, lock, mini, 
-                allowDividendCalculationForInactiveClients, chargesdata, status) ;
-        return data ;
-    }
-    
-    public Long getClientId() {
-        return this.client.getId() ;
-    }
-    
-    public String getClientName() {
-        return this.client.getDisplayName() ;
-    }
-    
-    public Long getTotalShares() {
-        long value = 0 ;
-        for(PurchasedShares val: purchasedShares) {
-            if(val.getStatus().equals("Approved")) {
-                value += val.getTotalShares().longValue() ;    
-            }
-        }
-        return new Long(value) ;
-    }
-    
-    public String getShareAccountNo() {
-        return "000025900"+getId() ; 
-    }
-    
-    public String getSavingsAccountNo() {
-        return this.savingsAccount.getAccountNumber() ;
-    }
-    
-    public void setStatus(String status) {
-        this.status = status ;
-    }
-    
-    public String getStatus() {
-        return this.status ;
-    }
-    
-    public void addAddtionalShares(Set<PurchasedShares> additionalShares) {
-        this.purchasedShares.addAll(additionalShares) ;
-    }
-    
-    public Set<PurchasedShares> getPurchasedShares() {
-        return this.purchasedShares ;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountCharge.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountCharge.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountCharge.java
deleted file mode 100644
index 73fbfa5..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountCharge.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * 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.portfolio.accounts.domain;
-
-import javax.persistence.Entity;
-import javax.persistence.JoinColumn;
-import javax.persistence.ManyToOne;
-import javax.persistence.Table;
-
-import org.apache.fineract.portfolio.charge.domain.Charge;
-import org.springframework.data.jpa.domain.AbstractPersistable;
-
-@Entity
-@Table(name = "m_shareaccounts_charges")
-public class ShareAccountCharge extends AbstractPersistable<Long> {
-
-    @ManyToOne(optional = false)
-    @JoinColumn(name = "account_id", referencedColumnName = "id", nullable = false)
-    private ShareAccount shareAccount;
-
-    @ManyToOne(optional = false)
-    @JoinColumn(name = "charge_id", referencedColumnName = "id", nullable = false)
-    private Charge charge;
-
-    protected ShareAccountCharge() {
-
-    }
-
-    public ShareAccountCharge(final ShareAccount shareAccount, final Charge charge) {
-        this.shareAccount = shareAccount;
-        this.charge = charge;
-    }
-
-    public ShareAccountCharge(final Charge charge) {
-        this.charge = charge;
-    }
-
-    public void setShareAccount(ShareAccount shareAccount) {
-        this.shareAccount = shareAccount;
-    }
-    
-    public Long getAccountId() {
-        return this.shareAccount.getId() ;
-    }
-    
-    public Long getChargeId() {
-        return this.charge.getId() ;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountRepository.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountRepository.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountRepository.java
deleted file mode 100644
index 4867bf4..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountRepository.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/**
- * 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.portfolio.accounts.domain;
-
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
-
-
-public interface ShareAccountRepository extends JpaRepository<ShareAccount, Long>, JpaSpecificationExecutor<ShareAccount> {
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountTempRepository.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountTempRepository.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountTempRepository.java
deleted file mode 100644
index 91602ff..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/domain/ShareAccountTempRepository.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * 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.portfolio.accounts.domain;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.fineract.portfolio.shares.domain.ShareProductTempRepository;
-
-
-public class ShareAccountTempRepository {
-    
-    private final static ShareAccountTempRepository instance = new ShareAccountTempRepository() ;
-    
-    private Map<Long, ShareAccount> cache = new HashMap<>() ;
-    
-    private ShareAccountTempRepository() {
-        
-    }
-    
-    public static ShareAccountTempRepository getInstance() {
-        return instance ;
-    }
-    
-    public void save(ShareAccount account) {
-        Long id = new Long(cache.size()+1) ;
-        account.setTempId(id) ;
-        cache.put(id, account) ;
-        ShareProductTempRepository.getInstance().addAccount(account.getShareProduct().getId(), account) ;
-    }
-    
-    public ShareAccount findOne(Long id) {
-        return cache.get(id) ;
-    }
-    
-    public Collection<ShareAccount> findAll() {
-        return cache.values() ;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/handler/CreateShareAccountCommandHandler.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/handler/CreateShareAccountCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/handler/CreateShareAccountCommandHandler.java
deleted file mode 100644
index ce4ca75..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/handler/CreateShareAccountCommandHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.portfolio.accounts.handler;
-
-import org.apache.fineract.commands.annotation.CommandType;
-import org.apache.fineract.commands.handler.NewCommandSourceHandler;
-import org.apache.fineract.infrastructure.core.api.JsonCommand;
-import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
-import org.apache.fineract.portfolio.accounts.service.ShareAccountWritePlatformService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-@Service
-@CommandType(entity = "SHAREACCOUNT", action = "CREATE")
-public class CreateShareAccountCommandHandler implements NewCommandSourceHandler{
-
-
-    private final ShareAccountWritePlatformService shareAccountWritePlatformService ;
-    
-    @Autowired
-    public CreateShareAccountCommandHandler(final ShareAccountWritePlatformService shareAccountWritePlatformService) {
-        this.shareAccountWritePlatformService = shareAccountWritePlatformService ;
-    }
-    @Transactional
-    @Override
-    public CommandProcessingResult processCommand(JsonCommand jsonCommand) {
-        return this.shareAccountWritePlatformService.createShareAccount(jsonCommand);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/handler/UpdateShareAccountCommandHandler.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/handler/UpdateShareAccountCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/handler/UpdateShareAccountCommandHandler.java
deleted file mode 100644
index 5945d0b..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/handler/UpdateShareAccountCommandHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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.portfolio.accounts.handler;
-
-import org.apache.fineract.commands.annotation.CommandType;
-import org.apache.fineract.commands.handler.NewCommandSourceHandler;
-import org.apache.fineract.infrastructure.core.api.JsonCommand;
-import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
-import org.apache.fineract.portfolio.accounts.service.ShareAccountWritePlatformService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-@Service
-@CommandType(entity = "SHAREACCOUNT", action = "UPDATE")
-public class UpdateShareAccountCommandHandler implements NewCommandSourceHandler {
-
-    private final ShareAccountWritePlatformService shareAccountWritePlatformService ;
-    
-    @Autowired
-    public UpdateShareAccountCommandHandler(final ShareAccountWritePlatformService shareAccountWritePlatformService) {
-        this.shareAccountWritePlatformService = shareAccountWritePlatformService ;
-    }
-
-    @Transactional
-    @Override
-    public CommandProcessingResult processCommand(JsonCommand jsonCommand) {
-        return this.shareAccountWritePlatformService.updateShareAccount(jsonCommand.entityId(), jsonCommand);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/serialization/ShareAccountDataSerializer.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/serialization/ShareAccountDataSerializer.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/serialization/ShareAccountDataSerializer.java
deleted file mode 100644
index 815f369..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/serialization/ShareAccountDataSerializer.java
+++ /dev/null
@@ -1,333 +0,0 @@
-/**
- * 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.portfolio.accounts.serialization;
-
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.fineract.accounting.glaccount.domain.GLAccount;
-import org.apache.fineract.accounting.glaccount.domain.GLAccountRepositoryWrapper;
-import org.apache.fineract.infrastructure.core.api.JsonCommand;
-import org.apache.fineract.infrastructure.core.data.ApiParameterError;
-import org.apache.fineract.infrastructure.core.data.DataValidatorBuilder;
-import org.apache.fineract.infrastructure.core.exception.InvalidJsonException;
-import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
-import org.apache.fineract.infrastructure.core.service.DateUtils;
-import org.apache.fineract.infrastructure.security.service.PlatformSecurityContext;
-import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency;
-import org.apache.fineract.portfolio.accounts.constants.ShareAccountApiConstants;
-import org.apache.fineract.portfolio.accounts.domain.PurchasedShares;
-import org.apache.fineract.portfolio.accounts.domain.ShareAccount;
-import org.apache.fineract.portfolio.accounts.domain.ShareAccountCharge;
-import org.apache.fineract.portfolio.charge.domain.Charge;
-import org.apache.fineract.portfolio.charge.domain.ChargeRepositoryWrapper;
-import org.apache.fineract.portfolio.client.domain.Client;
-import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
-import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
-import org.apache.fineract.portfolio.loanproduct.exception.InvalidCurrencyException;
-import org.apache.fineract.portfolio.products.exception.ProductNotFoundException;
-import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
-import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepositoryWrapper;
-import org.apache.fineract.portfolio.shares.domain.ShareProduct;
-import org.apache.fineract.portfolio.shares.domain.ShareProductTempRepository;
-import org.apache.fineract.useradministration.domain.AppUser;
-import org.joda.time.DateTime;
-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;
-import com.google.gson.reflect.TypeToken;
-
-@Service
-public class ShareAccountDataSerializer {
-
-    private final Set<String> supportedParameters = new HashSet<>(Arrays.asList(""));
-
-    private final PlatformSecurityContext platformSecurityContext;
-
-    private final FromJsonHelper fromApiJsonHelper;
-
-    private final ChargeRepositoryWrapper chargeRepository;
-
-    private final GLAccountRepositoryWrapper glAccountRepository;
-
-    private final SavingsAccountRepositoryWrapper savingsAccountRepositoryWrapper;
-
-    private final ClientRepositoryWrapper clientRepositoryWrapper;
-
-    @Autowired
-    public ShareAccountDataSerializer(final PlatformSecurityContext platformSecurityContext, final FromJsonHelper fromApiJsonHelper,
-            final ChargeRepositoryWrapper chargeRepository, GLAccountRepositoryWrapper glAccountRepository,
-            final SavingsAccountRepositoryWrapper savingsAccountRepositoryWrapper, final ClientRepositoryWrapper clientRepositoryWrapper) {
-        this.platformSecurityContext = platformSecurityContext;
-        this.fromApiJsonHelper = fromApiJsonHelper;
-        this.chargeRepository = chargeRepository;
-        this.glAccountRepository = glAccountRepository;
-        this.savingsAccountRepositoryWrapper = savingsAccountRepositoryWrapper;
-        this.clientRepositoryWrapper = clientRepositoryWrapper;
-    }
-
-    public ShareAccount validateAndCreate(JsonCommand jsonCommand) {
-
-        if (StringUtils.isBlank(jsonCommand.json())) { throw new InvalidJsonException(); }
-        final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
-        //this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, jsonCommand.json(), supportedParameters);
-
-        final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
-        final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("sharesaccount");
-        JsonElement element = jsonCommand.parsedJson();
-
-        final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(element.getAsJsonObject());
-        final Long clientId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.clientid_paramname, element);
-        final Long productId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.productid_paramname, element);
-        final Date submittedDate = this.fromApiJsonHelper.extractLocalDateNamed(ShareAccountApiConstants.submitteddate_paramname, element)
-                .toDate();
-        // On creation submitted date will not be there.
-        final Long fieldOfficerId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.fieldofferid_paramname, element);
-        final String externalId = this.fromApiJsonHelper.extractStringNamed(ShareAccountApiConstants.externalid_paramname, element);
-
-        Long suspenseAccountId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.suspenseaccount_paramname, element);
-        Long equityAccountId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.equityaccount_paramname, element);
-        Long savingsAccountId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.savingsaccountid_paramname, element);
-        Set<PurchasedShares> sharesPurchased = asemblePurchasedShares(element);
-        
-        Boolean allowdividendsForInactiveClients = this.fromApiJsonHelper.extractBooleanNamed(
-                ShareAccountApiConstants.allowdividendcalculationforinactiveclients_paramname, element);
-        PeriodFrequencyType lockPeriod = extractPeriodType(ShareAccountApiConstants.lockperiod_paramname, element);
-        PeriodFrequencyType minimumActivePeriod = extractPeriodType(ShareAccountApiConstants.minimumactiveperiodfordividends_paramname,
-                element);
-
-        Client client = this.clientRepositoryWrapper.findOneWithNotFoundDetection(clientId);
-        GLAccount suspenseAccount = glAccountRepository.findOneWithNotFoundDetection(suspenseAccountId);
-        GLAccount equityAccount = glAccountRepository.findOneWithNotFoundDetection(equityAccountId);
-        SavingsAccount savingsAccount = this.savingsAccountRepositoryWrapper.findOneWithNotFoundDetection(savingsAccountId);
-        ShareProduct shareProduct = ShareProductTempRepository.getInstance().fineOne(productId);
-        if(shareProduct == null) {
-            throw new ProductNotFoundException(productId, "Share") ;
-        }
-        final MonetaryCurrency currency = shareProduct.getCurrency() ;
-        Set<ShareAccountCharge> charges = assembleListOfAccountCharges(element, currency.getCode());
-        AppUser modifiedBy = null;
-        DateTime modifiedOn = null;
-        Date approvedDate = null;
-        AppUser createdBy = platformSecurityContext.authenticatedUser();
-        DateTime createdDate = DateUtils.getLocalDateTimeOfTenant().toDateTime();
-        ShareAccount account = new ShareAccount(client, shareProduct, submittedDate, approvedDate, fieldOfficerId, externalId, currency,
-                suspenseAccount, equityAccount, savingsAccount, sharesPurchased, allowdividendsForInactiveClients, lockPeriod,
-                minimumActivePeriod, charges, createdBy, createdDate, modifiedBy, modifiedOn);
-        
-        for(PurchasedShares pur: sharesPurchased) {
-            pur.setShareAccount(account) ;
-        }
-        
-        for(ShareAccountCharge charge: charges) {
-            charge.setShareAccount(account) ;
-        }
-        return account;
-    }
-
-    public Map<String, Object> validateAndUpdate(JsonCommand jsonCommand, ShareAccount account) {
-        Map<String, Object> actualChanges = new HashMap<>();
-        if (StringUtils.isBlank(jsonCommand.json())) { throw new InvalidJsonException(); }
-        final Type typeOfMap = new TypeToken<Map<String, Object>>() {}.getType();
-        //this.fromApiJsonHelper.checkForUnsupportedParameters(typeOfMap, jsonCommand.json(), supportedParameters);
-
-        final List<ApiParameterError> dataValidationErrors = new ArrayList<>();
-        final DataValidatorBuilder baseDataValidator = new DataValidatorBuilder(dataValidationErrors).resource("sharesaccount");
-        JsonElement element = jsonCommand.parsedJson();
-
-        final Locale locale = this.fromApiJsonHelper.extractLocaleParameter(element.getAsJsonObject());
-        
-        if(this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.productid_paramname, element)) {
-            final Long productId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.productid_paramname, element);
-            ShareProduct shareProduct = ShareProductTempRepository.getInstance().fineOne(productId);
-            if(account.setShareProduct(shareProduct)) {
-                actualChanges.put(ShareAccountApiConstants.productid_paramname, shareProduct) ;    
-            }
-            
-        }
-        
-        if(this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.submitteddate_paramname, element)) {
-            final Date submittedDate = this.fromApiJsonHelper.extractLocalDateNamed(ShareAccountApiConstants.submitteddate_paramname, element)
-                    .toDate();
-            if(account.setSubmittedDate(submittedDate)) {
-                actualChanges.put(ShareAccountApiConstants.submitteddate_paramname, submittedDate) ;    
-            }
-        }
-        
-        if(this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.fieldofferid_paramname, element)) {
-            final Long fieldOfficerId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.fieldofferid_paramname, element);
-            if(account.setFieldOfficer(fieldOfficerId)){
-                actualChanges.put(ShareAccountApiConstants.fieldofferid_paramname, fieldOfficerId) ;    
-            }
-        }
-        
-        if(this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.externalid_paramname, element)) {
-            final String externalId = this.fromApiJsonHelper.extractStringNamed(ShareAccountApiConstants.externalid_paramname, element);
-            if(account.setExternalId(externalId)) {
-                actualChanges.put(ShareAccountApiConstants.externalid_paramname, externalId) ;
-            }
-        }
-
-        if(this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.suspenseaccount_paramname, element)) {
-            Long suspenseAccountId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.suspenseaccount_paramname, element);
-            GLAccount suspenseAccount = glAccountRepository.findOneWithNotFoundDetection(suspenseAccountId);
-            if(account.setSuspenseAccount(suspenseAccount)) {
-                actualChanges.put(ShareAccountApiConstants.suspenseaccount_paramname, suspenseAccount) ;
-            }
-        }
-        
-        if(this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.equityaccount_paramname, element)) {
-            Long equityAccountId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.equityaccount_paramname, element);
-            GLAccount equityAccount = glAccountRepository.findOneWithNotFoundDetection(equityAccountId);
-            if(account.setEquityAccount(equityAccount)) {
-                actualChanges.put(ShareAccountApiConstants.equityaccount_paramname, equityAccount) ;
-            }
-        }
-        
-        if(this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.savingsaccountid_paramname, element)) {
-            Long savingsAccountId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.savingsaccountid_paramname, element);
-            SavingsAccount savingsAccount = this.savingsAccountRepositoryWrapper.findOneWithNotFoundDetection(savingsAccountId);
-            if(account.setSavingsAccount(savingsAccount)) {
-                actualChanges.put(ShareAccountApiConstants.savingsaccountid_paramname, savingsAccount) ;
-            }
-        }
-        
-        if(this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.purchasedshares_paramname, element)) {
-            Set<PurchasedShares> sharesPurchased = asemblePurchasedShares(element);
-            account.setPurchasedShares(sharesPurchased) ;
-            actualChanges.put(ShareAccountApiConstants.purchasedshares_paramname, sharesPurchased) ;
-        }
-        
-        if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.allowdividendcalculationforinactiveclients_paramname, element)) {
-            Boolean allowdividendsForInactiveClients = this.fromApiJsonHelper.extractBooleanNamed(
-                    ShareAccountApiConstants.allowdividendcalculationforinactiveclients_paramname, element);
-            if (account.setAllowDividendCalculationForInactiveClients(allowdividendsForInactiveClients)) {
-                actualChanges.put(ShareAccountApiConstants.allowdividendcalculationforinactiveclients_paramname,
-                        allowdividendsForInactiveClients);
-            }
-        }
-
-        if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.lockperiod_paramname, element)) {
-            PeriodFrequencyType lockPeriod = extractPeriodType(ShareAccountApiConstants.lockperiod_paramname, element);
-            if (account.setLockPeriod(lockPeriod)) {
-                actualChanges.put(ShareAccountApiConstants.lockperiod_paramname, lockPeriod);
-            }
-        }
-
-        if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.minimumactiveperiodfordividends_paramname, element)) {
-            PeriodFrequencyType minimumActivePeriod = extractPeriodType(ShareAccountApiConstants.minimumactiveperiodfordividends_paramname,
-                    element);
-            if (account.setminimumActivePeriodForDividends(minimumActivePeriod)) {
-                actualChanges.put(ShareAccountApiConstants.minimumactiveperiodfordividends_paramname, minimumActivePeriod);
-            }
-        }
-        if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.charges_paramname, element)) {
-            ShareProduct shareProduct = account.getShareProduct() ;
-            Set<ShareAccountCharge> charges = assembleListOfAccountCharges(element, shareProduct.getCurrency().getCode());
-            if(account.setCharges(charges)) {
-                actualChanges.put(ShareAccountApiConstants.charges_paramname, charges);
-            }
-        }
-        AppUser modifiedBy = platformSecurityContext.authenticatedUser();
-        DateTime modifiedOn = DateUtils.getLocalDateTimeOfTenant().toDateTime();
-       
-        return actualChanges;
-    }
-
-    private Set<ShareAccountCharge> assembleListOfAccountCharges(final JsonElement element, final String currencyCode) {
-        final Set<ShareAccountCharge> charges = new HashSet<>();
-        if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.charges_paramname, element)) {
-            JsonArray chargesArray = this.fromApiJsonHelper.extractJsonArrayNamed(ShareAccountApiConstants.charges_paramname, element);
-            if (chargesArray != null) {
-                for (int i = 0; i < chargesArray.size(); i++) {
-                    final JsonObject jsonObject = chargesArray.get(i).getAsJsonObject();
-                    if (jsonObject.has("id")) {
-                        final Long id = jsonObject.get("id").getAsLong();
-                        final Charge charge = this.chargeRepository.findOneWithNotFoundDetection(id);
-                        if (!currencyCode.equals(charge.getCurrencyCode())) {
-                            final String errorMessage = "Charge and Share Account must have the same currency.";
-                            throw new InvalidCurrencyException("charge", "attach.to.share.account", errorMessage);
-                        }
-                        ShareAccountCharge accountCharge = new ShareAccountCharge(charge);
-                        charges.add(accountCharge);
-                    }
-                }
-            }
-        }
-        return charges;
-    }
-
-    private PeriodFrequencyType extractPeriodType(String paramName, final JsonElement element) {
-        PeriodFrequencyType frequencyType = PeriodFrequencyType.INVALID;
-        frequencyType = PeriodFrequencyType.fromInt(this.fromApiJsonHelper.extractIntegerWithLocaleNamed(paramName, element));
-        return frequencyType;
-    }
-
-    private Set<PurchasedShares> asemblePurchasedShares(final JsonElement element) {
-        Set<PurchasedShares> set = null;
-        if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.purchasedshares_paramname, element)) {
-            set = new HashSet<>();
-            JsonArray array = this.fromApiJsonHelper.extractJsonArrayNamed(ShareAccountApiConstants.purchasedshares_paramname, element);
-            for (JsonElement arrayElement : array) {
-                LocalDate localDate = this.fromApiJsonHelper.extractLocalDateNamed(ShareAccountApiConstants.purchaseddate_paramname,
-                        arrayElement);
-                final Long shares = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.numberofshares_paramname, arrayElement);
-                final BigDecimal shareValue = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(
-                        ShareAccountApiConstants.purchasedprice_paramname, arrayElement);
-
-                PurchasedShares obj = new PurchasedShares(localDate.toDate(), shares, shareValue);
-                set.add(obj);
-            }
-        }
-        return set;
-    }
-    
-    public Set<PurchasedShares> asembleAdditionalShares(final JsonElement element) {
-        Set<PurchasedShares> set = null;
-        if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.additionalshares_paramname, element)) {
-            set = new HashSet<>();
-            JsonArray array = this.fromApiJsonHelper.extractJsonArrayNamed(ShareAccountApiConstants.additionalshares_paramname, element);
-            for (JsonElement arrayElement : array) {
-                LocalDate localDate = this.fromApiJsonHelper.extractLocalDateNamed(ShareAccountApiConstants.purchaseddate_paramname,
-                        arrayElement);
-                final Long shares = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.numberofshares_paramname, arrayElement);
-                final BigDecimal shareValue = this.fromApiJsonHelper.extractBigDecimalWithLocaleNamed(
-                        ShareAccountApiConstants.purchasedprice_paramname, arrayElement);
-
-                PurchasedShares obj = new PurchasedShares(localDate.toDate(), shares, shareValue);
-                set.add(obj);
-            }
-        }
-        return set;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/AccountReadPlatformService.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/AccountReadPlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/AccountReadPlatformService.java
index 9274284..42ef5e3 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/AccountReadPlatformService.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/AccountReadPlatformService.java
@@ -23,12 +23,14 @@ import java.util.Set;
 
 import org.apache.fineract.portfolio.accounts.data.AccountData;
 
-
 public interface AccountReadPlatformService {
 
-    public AccountData retrieveOne(Long id) ;
-    
-    public Collection<AccountData> retrieveAll() ;
-    
+    public AccountData retrieveTemplate(final Long clientId, final Long productId);
+
+    public AccountData retrieveOne(Long id, boolean includeTemplate);
+
+    public Collection<AccountData> retrieveAll();
+
     public Set<String> getResponseDataParams();
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountCommandsServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountCommandsServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountCommandsServiceImpl.java
deleted file mode 100644
index 14a1b37..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountCommandsServiceImpl.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/**
- * 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.portfolio.accounts.service;
-
-import java.util.Set;
-
-import org.apache.fineract.infrastructure.core.api.JsonCommand;
-import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
-import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
-import org.apache.fineract.infrastructure.core.serialization.FromJsonHelper;
-import org.apache.fineract.portfolio.accounts.constants.ShareAccountApiConstants;
-import org.apache.fineract.portfolio.accounts.domain.PurchasedShares;
-import org.apache.fineract.portfolio.accounts.domain.ShareAccount;
-import org.apache.fineract.portfolio.accounts.domain.ShareAccountTempRepository;
-import org.apache.fineract.portfolio.accounts.serialization.ShareAccountDataSerializer;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import com.google.gson.JsonElement;
-
-@Service(value = "SHAREACCOUNT_COMMANDSERVICE")
-public class ShareAccountCommandsServiceImpl implements AccountsCommandsService {
-
-    private final FromJsonHelper fromApiJsonHelper;
-    
-    private final ShareAccountDataSerializer shareAccountDataSerializer ;
-    
-    @Autowired
-    public ShareAccountCommandsServiceImpl(final FromJsonHelper fromApiJsonHelper,
-            final ShareAccountDataSerializer shareAccountDataSerializer) {
-        this.fromApiJsonHelper = fromApiJsonHelper;
-        this.shareAccountDataSerializer = shareAccountDataSerializer ;
-    }
-
-    @Override
-    public Object handleCommand(Long accountId, String command, String jsonBody) {
-        final JsonElement parsedCommand = this.fromApiJsonHelper.parse(jsonBody);
-        final JsonCommand jsonCommand = JsonCommand.from(jsonBody, parsedCommand, this.fromApiJsonHelper, null, null, null, null, null,
-                null, null, null, null, null);
-        if(ShareAccountApiConstants.APPROVE_COMMAND.equals(command)){
-            return approveShareAccount(accountId, jsonCommand) ;
-        }if(ShareAccountApiConstants.REJECT_COMMAND.equals(command)){
-            return rejectShareAccount(accountId, jsonCommand) ;
-        }else if(ShareAccountApiConstants.APPLY_ADDITIONALSHARES_COMMAND.equals(command)) {
-            return applyAdditionalShares(accountId, jsonCommand) ;
-        }else if(ShareAccountApiConstants.APPROVE_ADDITIONSHARES_COMMAND.equals(command)) {
-            return approveAdditionalShares(accountId, jsonCommand) ;
-        }else if(ShareAccountApiConstants.REJECT_ADDITIONSHARES_COMMAND.equals(command)) {
-            return rejectAdditionalShares(accountId, jsonCommand) ;
-        }
-        
-        return CommandProcessingResult.empty();
-    }
-
-    public Object approveShareAccount(Long accountId, JsonCommand jsonCommand) {
-        //We need to add approval date also
-        ShareAccount account = ShareAccountTempRepository.getInstance().findOne(accountId);
-        account.setStatus("Approved");
-        Set<PurchasedShares> purchasedShares = account.getPurchasedShares() ;
-        for(PurchasedShares pur: purchasedShares) {
-            pur.setStatus("Approved") ;    
-        }
-        return new CommandProcessingResultBuilder() //
-                .withCommandId(jsonCommand.commandId()) //
-                .withEntityId(account.getId()) //
-                .build();
-    }
-
-    public Object rejectShareAccount(Long accountId, JsonCommand jsonCommand) {
-        ShareAccount account = ShareAccountTempRepository.getInstance().findOne(accountId);
-        account.setStatus("Rejected");
-        //rejection date we need to capture
-        return new CommandProcessingResultBuilder() //
-                .withCommandId(jsonCommand.commandId()) //
-                .withEntityId(account.getId()) //
-                .build();
-    }
-
-    public Object applyAdditionalShares(Long accountId, JsonCommand jsonCommand) {
-        ShareAccount account = ShareAccountTempRepository.getInstance().findOne(accountId);
-        Set<PurchasedShares> additionalShares = this.shareAccountDataSerializer.asembleAdditionalShares(jsonCommand.parsedJson()) ;
-        account.addAddtionalShares(additionalShares) ;
-        return new CommandProcessingResultBuilder() //
-                .withCommandId(jsonCommand.commandId()) //
-                .withEntityId(account.getId()) //
-                .build();
-    }
-
-    public Object approveAdditionalShares(Long accountId, JsonCommand jsonCommand) {
-        //user might have requested for different dates.
-        //we need to capture either purchase date or ids []
-        ShareAccount account = ShareAccountTempRepository.getInstance().findOne(accountId);
-        Set<PurchasedShares> purchasedShares = account.getPurchasedShares() ;
-        for(PurchasedShares pur: purchasedShares) {
-            if(pur.getStatus().equals("Submitted") && !pur.getStatus().equals("Rejected")) {
-                pur.setStatus("Approved") ;    
-            }
-        }
-        return new CommandProcessingResultBuilder() //
-                .withCommandId(jsonCommand.commandId()) //
-                .withEntityId(account.getId()) //
-                .build();
-    }
-
-    public Object rejectAdditionalShares(Long accountId, JsonCommand jsonCommand) {
-        //user might have requested for different dates.
-        //we need to capture either purchase date or ids []
-        ShareAccount account = ShareAccountTempRepository.getInstance().findOne(accountId);
-        Set<PurchasedShares> purchasedShares = account.getPurchasedShares() ;
-        for(PurchasedShares pur: purchasedShares) {
-            if(pur.getStatus().equals("Submitted")) {
-                pur.setStatus("Rejected") ;    
-            }
-        }
-        return new CommandProcessingResultBuilder() //
-                .withCommandId(jsonCommand.commandId()) //
-                .withEntityId(account.getId()) //
-                .build();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountReadPlatformServiceImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountReadPlatformServiceImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountReadPlatformServiceImpl.java
deleted file mode 100644
index 971d3fb..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountReadPlatformServiceImpl.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.portfolio.accounts.service;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.fineract.portfolio.accounts.constants.AccountsApiConstants;
-import org.apache.fineract.portfolio.accounts.data.AccountData;
-import org.apache.fineract.portfolio.accounts.domain.ShareAccount;
-import org.apache.fineract.portfolio.accounts.domain.ShareAccountTempRepository;
-import org.springframework.stereotype.Service;
-
-@Service(value = "share"+AccountsApiConstants.READPLATFORM_NAME)
-public class ShareAccountReadPlatformServiceImpl implements AccountReadPlatformService{
-
-    @Override
-    public AccountData retrieveOne(Long id) {
-        return ShareAccountTempRepository.getInstance().findOne(id).toData();
-    }
-
-    @Override
-    public Collection<AccountData> retrieveAll() {
-        Collection<ShareAccount> collection = ShareAccountTempRepository.getInstance().findAll() ;
-        Set<AccountData> set = new HashSet<>() ;
-        for(ShareAccount data: collection) {
-            set.add(data.toData()) ;
-        }
-        return set;
-    }
-
-    @Override
-    public Set<String> getResponseDataParams() {
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountWritePlatformService.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountWritePlatformService.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountWritePlatformService.java
deleted file mode 100644
index feb754b..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountWritePlatformService.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * 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.portfolio.accounts.service;
-
-import org.apache.fineract.infrastructure.core.api.JsonCommand;
-import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
-
-
-public interface ShareAccountWritePlatformService {
-
-    public CommandProcessingResult createShareAccount(JsonCommand jsonCommand) ;
-    
-    public CommandProcessingResult updateShareAccount(Long accountId, JsonCommand jsonCommand) ;
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountWritePlatformServiceJpaRepositoryImpl.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountWritePlatformServiceJpaRepositoryImpl.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountWritePlatformServiceJpaRepositoryImpl.java
deleted file mode 100644
index d3afa5d..0000000
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/accounts/service/ShareAccountWritePlatformServiceJpaRepositoryImpl.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * 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.portfolio.accounts.service;
-
-import java.util.Map;
-
-import org.apache.fineract.infrastructure.core.api.JsonCommand;
-import org.apache.fineract.infrastructure.core.data.CommandProcessingResult;
-import org.apache.fineract.infrastructure.core.data.CommandProcessingResultBuilder;
-import org.apache.fineract.portfolio.accounts.domain.ShareAccount;
-import org.apache.fineract.portfolio.accounts.domain.ShareAccountTempRepository;
-import org.apache.fineract.portfolio.accounts.exceptions.ShareAccountNotFoundException;
-import org.apache.fineract.portfolio.accounts.serialization.ShareAccountDataSerializer;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.dao.DataIntegrityViolationException;
-import org.springframework.stereotype.Service;
-
-@Service
-public class ShareAccountWritePlatformServiceJpaRepositoryImpl implements ShareAccountWritePlatformService {
-
-    private final ShareAccountDataSerializer accountDataSerializer;
-
-    @Autowired
-    public ShareAccountWritePlatformServiceJpaRepositoryImpl(final ShareAccountDataSerializer accountDataSerializer) {
-        this.accountDataSerializer = accountDataSerializer;
-    }
-
-    @Override
-    public CommandProcessingResult createShareAccount(JsonCommand jsonCommand) {
-        try {
-            ShareAccount account = this.accountDataSerializer.validateAndCreate(jsonCommand);
-            ShareAccountTempRepository.getInstance().save(account);
-            return new CommandProcessingResultBuilder() //
-                    .withCommandId(jsonCommand.commandId()) //
-                    .withEntityId(account.getId()) //
-                    .build();
-        } catch (final DataIntegrityViolationException dve) {
-            handleDataIntegrityIssues(jsonCommand, dve);
-            return CommandProcessingResult.empty();
-        }
-    }
-
-    @Override
-    public CommandProcessingResult updateShareAccount(Long accountId, JsonCommand jsonCommand) {
-        try {
-            ShareAccount account = ShareAccountTempRepository.getInstance().findOne(accountId);
-            if (account == null) {
-                throw new ShareAccountNotFoundException(accountId) ;
-            }
-            Map<String, Object> changes = this.accountDataSerializer.validateAndUpdate(jsonCommand, account);
-            if (!changes.isEmpty()) {
-                // Save the data here
-            }
-            return new CommandProcessingResultBuilder() //
-                    .withCommandId(jsonCommand.commandId()) //
-                    .withEntityId(accountId) //
-                    .with(changes) //
-                    .build();
-        } catch (DataIntegrityViolationException dve) {
-            handleDataIntegrityIssues(jsonCommand, dve);
-            return CommandProcessingResult.empty();
-        }
-    }
-
-    private void handleDataIntegrityIssues(final JsonCommand command, final DataIntegrityViolationException dve) {
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/data/ChargeData.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/data/ChargeData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/data/ChargeData.java
index 28bcd74..627eaf9 100755
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/data/ChargeData.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/data/ChargeData.java
@@ -31,6 +31,7 @@ import org.apache.fineract.portfolio.charge.domain.ChargeTimeType;
 import org.apache.fineract.portfolio.loanaccount.data.LoanChargeData;
 import org.apache.fineract.portfolio.savings.data.SavingsAccountChargeData;
 import org.apache.fineract.portfolio.tax.data.TaxGroupData;
+import org.apache.fineract.portfolio.shareaccounts.data.ShareAccountChargeData;
 import org.joda.time.LocalDate;
 import org.joda.time.MonthDay;
 
@@ -69,6 +70,9 @@ public class ChargeData implements Comparable<ChargeData>, Serializable {
     private final List<EnumOptionData> savingsChargeTimeTypeOptions;
     private final List<EnumOptionData> clientChargeCalculationTypeOptions;
     private final List<EnumOptionData> clientChargeTimeTypeOptions;
+    private final List<EnumOptionData> shareChargeCalculationTypeOptions;
+    private final List<EnumOptionData> shareChargeTimeTypeOptions;
+
     private final List<EnumOptionData> feeFrequencyOptions;
 
     private final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions;
@@ -81,14 +85,17 @@ public class ChargeData implements Comparable<ChargeData>, Serializable {
             final List<EnumOptionData> savingsChargeCalculationTypeOptions, final List<EnumOptionData> savingsChargeTimeTypeOptions,
             final List<EnumOptionData> clientChargeCalculationTypeOptions, final List<EnumOptionData> clientChargeTimeTypeOptions,
             final List<EnumOptionData> feeFrequencyOptions, final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions,
-            final Collection<TaxGroupData> taxGroupOptions) {
+            final Collection<TaxGroupData> taxGroupOptions, final List<EnumOptionData> shareChargeCalculationTypeOptions,
+            final List<EnumOptionData> shareChargeTimeTypeOptions) {
         final GLAccountData account = null;
         final TaxGroupData taxGroupData = null;
+
         return new ChargeData(null, null, null, null, null, null, null, null, false, false, taxGroupData, currencyOptions,
                 chargeCalculationTypeOptions, chargeAppliesToOptions, chargeTimeTypeOptions, chargePaymentModeOptions,
                 loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions, savingsChargeCalculationTypeOptions,
                 savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions, clientChargeTimeTypeOptions, null, null, null, null,
-                null, feeFrequencyOptions, account, incomeOrLiabilityAccountOptions, taxGroupOptions);
+                null, feeFrequencyOptions, account, incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions,
+                shareChargeTimeTypeOptions);
     }
 
     public static ChargeData withTemplate(final ChargeData charge, final ChargeData template) {
@@ -99,7 +106,8 @@ public class ChargeData implements Comparable<ChargeData>, Serializable {
                 template.loanChargeTimeTypeOptions, template.savingsChargeCalculationTypeOptions, template.savingsChargeTimeTypeOptions,
                 template.clientChargeCalculationTypeOptions, template.clientChargeTimeTypeOptions, charge.feeOnMonthDay,
                 charge.feeInterval, charge.minCap, charge.maxCap, charge.feeFrequency, template.feeFrequencyOptions,
-                charge.incomeOrLiabilityAccount, template.incomeOrLiabilityAccountOptions, template.taxGroupOptions);
+                charge.incomeOrLiabilityAccount, template.incomeOrLiabilityAccountOptions, template.taxGroupOptions,
+                template.shareChargeCalculationTypeOptions, template.shareChargeTimeTypeOptions);
     }
 
     public static ChargeData instance(final Long id, final String name, final BigDecimal amount, final CurrencyData currency,
@@ -121,14 +129,15 @@ public class ChargeData implements Comparable<ChargeData>, Serializable {
         final List<EnumOptionData> clientChargeCalculationTypeOptions = null;
         final List<EnumOptionData> clientChargeTimeTypeOptions = null;
         final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions = null;
+        final List<EnumOptionData> shareChargeCalculationTypeOptions = null;
+        final List<EnumOptionData> shareChargeTimeTypeOptions = null;
         final Collection<TaxGroupData> taxGroupOptions = null;
-
         return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, chargePaymentMode,
                 penalty, active, taxGroupData, currencyOptions, chargeCalculationTypeOptions, chargeAppliesToOptions,
                 chargeTimeTypeOptions, chargePaymentModeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions,
                 savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions,
                 clientChargeTimeTypeOptions, feeOnMonthDay, feeInterval, minCap, maxCap, feeFrequency, feeFrequencyOptions, accountData,
-                incomeOrLiabilityAccountOptions, taxGroupOptions);
+                incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions);
     }
 
     public static ChargeData lookup(final Long id, final String name, final boolean isPenalty) {
@@ -159,6 +168,8 @@ public class ChargeData implements Comparable<ChargeData>, Serializable {
         final List<EnumOptionData> feeFrequencyOptions = null;
         final GLAccountData account = null;
         final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions = null;
+        final List<EnumOptionData> shareChargeCalculationTypeOptions = null;
+        final List<EnumOptionData> shareChargeTimeTypeOptions = null;
         final TaxGroupData taxGroupData = null;
         final Collection<TaxGroupData> taxGroupOptions = null;
         return new ChargeData(id, name, amount, currency, chargeTimeType, chargeAppliesTo, chargeCalculationType, chargePaymentMode,
@@ -166,7 +177,7 @@ public class ChargeData implements Comparable<ChargeData>, Serializable {
                 chargeTimeTypeOptions, chargePaymentModeOptions, loansChargeCalculationTypeOptions, loansChargeTimeTypeOptions,
                 savingsChargeCalculationTypeOptions, savingsChargeTimeTypeOptions, clientChargeCalculationTypeOptions,
                 clientChargeTimeTypeOptions, feeOnMonthDay, feeInterval, minCap, maxCap, feeFrequency, feeFrequencyOptions, account,
-                incomeOrLiabilityAccountOptions, taxGroupOptions);
+                incomeOrLiabilityAccountOptions, taxGroupOptions, shareChargeCalculationTypeOptions, shareChargeTimeTypeOptions);
     }
 
     private ChargeData(final Long id, final String name, final BigDecimal amount, final CurrencyData currency,
@@ -180,7 +191,8 @@ public class ChargeData implements Comparable<ChargeData>, Serializable {
             final List<EnumOptionData> clientChargeTimeTypeOptions, final MonthDay feeOnMonthDay, final Integer feeInterval,
             final BigDecimal minCap, final BigDecimal maxCap, final EnumOptionData feeFrequency,
             final List<EnumOptionData> feeFrequencyOptions, final GLAccountData account,
-            final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions, final Collection<TaxGroupData> taxGroupOptions) {
+            final Map<String, List<GLAccountData>> incomeOrLiabilityAccountOptions, final Collection<TaxGroupData> taxGroupOptions,
+            final List<EnumOptionData> shareChargeCalculationTypeOptions, final List<EnumOptionData> shareChargeTimeTypeOptions) {
         this.id = id;
         this.name = name;
         this.amount = amount;
@@ -212,6 +224,8 @@ public class ChargeData implements Comparable<ChargeData>, Serializable {
         this.incomeOrLiabilityAccountOptions = incomeOrLiabilityAccountOptions;
         this.taxGroup = taxGroupData;
         this.taxGroupOptions = taxGroupOptions;
+        this.shareChargeCalculationTypeOptions = shareChargeCalculationTypeOptions;
+        this.shareChargeTimeTypeOptions = shareChargeTimeTypeOptions;
     }
 
     @Override
@@ -264,6 +278,23 @@ public class ChargeData implements Comparable<ChargeData>, Serializable {
                 this.feeInterval, isActive, inactivationDate);
     }
 
+    public ShareAccountChargeData toShareAccountChargeData() {
+
+        final Long shareChargeId = null;
+        final Long shareAccountId = null;
+        final BigDecimal amountPaid = BigDecimal.ZERO;
+        final BigDecimal amountWaived = BigDecimal.ZERO;
+        final BigDecimal amountWrittenOff = BigDecimal.ZERO;
+        final BigDecimal amountOutstanding = BigDecimal.ZERO;
+        final BigDecimal percentage = BigDecimal.ZERO;
+        final BigDecimal amountPercentageAppliedTo = BigDecimal.ZERO;
+        final Collection<ChargeData> chargeOptions = null;
+        final Boolean isActive = null;
+        return new ShareAccountChargeData(shareChargeId, this.id, shareAccountId, this.name, this.currency, this.amount, amountPaid,
+                amountWaived, amountWrittenOff, amountOutstanding, this.chargeTimeType, this.chargeCalculationType, percentage,
+                amountPercentageAppliedTo, chargeOptions, isActive);
+    }
+
     public boolean isPenalty() {
         return this.penalty;
     }

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/ChargeAppliesTo.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/ChargeAppliesTo.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/ChargeAppliesTo.java
index 76f5742..bc4cef0 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/ChargeAppliesTo.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/ChargeAppliesTo.java
@@ -23,8 +23,9 @@ public enum ChargeAppliesTo {
     INVALID(0, "chargeAppliesTo.invalid"), //
     LOAN(1, "chargeAppliesTo.loan"), //
     SAVINGS(2, "chargeAppliesTo.savings"), //
-    CLIENT(3, "chargeAppliesTo.client");
-
+    CLIENT(3, "chargeAppliesTo.client"),
+    SHARES(4, "chargeAppliesTo.shares");
+    
     private final Integer value;
     private final String code;
 
@@ -55,6 +56,9 @@ public enum ChargeAppliesTo {
                 case 3:
                     chargeAppliesToType = CLIENT;
                 break;
+                case 4:
+                	chargeAppliesToType = SHARES ;
+                	break ;
                 default:
                     chargeAppliesToType = INVALID;
                 break;
@@ -76,7 +80,10 @@ public enum ChargeAppliesTo {
         return this.value.equals(ChargeAppliesTo.CLIENT.getValue());
     }
 
+    public boolean isSharesCharge() {
+    	return this.value.equals(SHARES.getValue()) ;
+    }
     public static Object[] validValues() {
-        return new Object[] { ChargeAppliesTo.LOAN.getValue(), ChargeAppliesTo.SAVINGS.getValue(), ChargeAppliesTo.CLIENT.getValue() };
+        return new Object[] { ChargeAppliesTo.LOAN.getValue(), ChargeAppliesTo.SAVINGS.getValue(), ChargeAppliesTo.CLIENT.getValue(), ChargeAppliesTo.SHARES.getValue() };
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/ChargeCalculationType.java
----------------------------------------------------------------------
diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/ChargeCalculationType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/ChargeCalculationType.java
index cd7fe36..c3379e3 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/ChargeCalculationType.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/charge/domain/ChargeCalculationType.java
@@ -53,10 +53,18 @@ public enum ChargeCalculationType {
         return new Integer[] { ChargeCalculationType.FLAT.getValue(), ChargeCalculationType.PERCENT_OF_AMOUNT.getValue() };
     }
 
+    public static Object[] validValuesForShares() {
+        return new Integer[] { ChargeCalculationType.FLAT.getValue(), ChargeCalculationType.PERCENT_OF_AMOUNT.getValue() };
+    }
+    
     public static Object[] validValuesForClients() {
         return new Integer[] { ChargeCalculationType.FLAT.getValue() };
     }
     
+    public static Object[] validValuesForShareAccountActivation() {
+        return new Integer[] { ChargeCalculationType.FLAT.getValue() };
+    }
+    
     public static Object[] validValuesForTrancheDisbursement(){
     	return new Integer[] { ChargeCalculationType.FLAT.getValue(), ChargeCalculationType.PERCENT_OF_DISBURSEMENT_AMOUNT.getValue()};
     }



Mime
View raw message