http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/constants/ShareProductApiConstants.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/constants/ShareProductApiConstants.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/constants/ShareProductApiConstants.java new file mode 100644 index 0000000..4a0725e --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/constants/ShareProductApiConstants.java @@ -0,0 +1,83 @@ +/** + * 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.shareproducts.constants; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import org.apache.fineract.accounting.common.AccountingConstants; + +public interface ShareProductApiConstants { + + // Command Strings + public final String PREIEW_DIVIDENDS_COMMAND_STRING = "previewdividends"; + public final String POST_DIVIDENdS_COMMAND_STRING = "postdividends"; + public final String SHARE_PRODUCT_RESOURCE_NAME = "shareproduct"; + + String locale_paramname = "locale"; + String dateFormatParamName = "dateFormat"; + String id_paramname = "id"; + String name_paramname = "name"; + String shortname_paramname = "shortName"; + String description_paramname = "description"; + String externalid_paramname = "externalId"; + String totalshares_paramname = "totalShares"; + String currency_paramname = "currencyCode"; + String digitsafterdecimal_paramname = "digitsAfterDecimal"; + String inmultiplesof_paramname = "inMultiplesOf"; + String totalsharesissued_paramname = "sharesIssued"; + String unitprice_paramname = "unitPrice"; + String sharecapital_paramname = "shareCapital"; + String minimumshares_paramname = "minimumShares"; + String nominaltshares_paramname = "nominalShares"; + String maximumshares_paramname = "maximumShares"; + String marketprice_paramname = "marketPricePeriods"; + String charges_paramname = "chargesSelected"; + String allowdividendcalculationforinactiveclients_paramname = "allowDividendCalculationForInactiveClients"; + String lockperiod_paramname = "lockinPeriodFrequency"; + String lockinperiodfrequencytype_paramname = "lockinPeriodFrequencyType"; + + String minimumactiveperiodfordividends_paramname = "minimumActivePeriodForDividends"; + String minimumactiveperiodfrequencytype_paramname = "minimumactiveperiodFrequencyType"; + + String startdate_paramname = "fromDate"; + String sharevalue_paramname = "shareValue"; + String dividendPeriodStartDateParamName = "dividendPeriodStartDate"; + String dividendPeriodEndDateParamName = "dividendPeriodEndDate"; + String dividendAmountParamName = "dividendAmount"; + + String accountingRuleParamName = "accountingRule"; + + Set<String> supportedParametersForCreate = new HashSet<>(Arrays.asList(locale_paramname, name_paramname, shortname_paramname, + shortname_paramname, description_paramname, externalid_paramname, totalshares_paramname, currency_paramname, + digitsafterdecimal_paramname, digitsafterdecimal_paramname, inmultiplesof_paramname, totalsharesissued_paramname, + unitprice_paramname, minimumshares_paramname, nominaltshares_paramname, maximumshares_paramname, marketprice_paramname, + charges_paramname, allowdividendcalculationforinactiveclients_paramname, lockperiod_paramname, + lockinperiodfrequencytype_paramname, minimumactiveperiodfordividends_paramname, minimumactiveperiodfrequencytype_paramname, + sharecapital_paramname, accountingRuleParamName, + AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS.INCOME_FROM_FEES.getValue(), + AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_EQUITY.getValue(), + AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_REFERENCE.getValue(), + AccountingConstants.SHARES_PRODUCT_ACCOUNTING_PARAMS.SHARES_SUSPENSE.getValue())); + + Set<String> supportedParametersForDivident = new HashSet<>(Arrays.asList(locale_paramname, dateFormatParamName, + dividendPeriodStartDateParamName, dividendPeriodEndDateParamName, dividendAmountParamName)); + +}
http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/data/ShareProductData.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/data/ShareProductData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/data/ShareProductData.java new file mode 100644 index 0000000..0deb6e2 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/data/ShareProductData.java @@ -0,0 +1,339 @@ +/** + * 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.shareproducts.data; + +import java.math.BigDecimal; +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import org.apache.fineract.accounting.common.AccountingRuleType; +import org.apache.fineract.accounting.glaccount.data.GLAccountData; +import org.apache.fineract.accounting.producttoaccountmapping.data.ChargeToGLAccountMapper; +import org.apache.fineract.accounting.producttoaccountmapping.data.PaymentTypeToGLAccountMapper; +import org.apache.fineract.infrastructure.core.data.EnumOptionData; +import org.apache.fineract.organisation.monetary.data.CurrencyData; +import org.apache.fineract.portfolio.charge.data.ChargeData; +import org.apache.fineract.portfolio.products.data.ProductData; + +public class ShareProductData implements ProductData { + + private final Long id; + private final String name; + private final String shortName; + private final String description; + private final String externalId; + private final CurrencyData currency; + private final Long totalShares; + private final Long totalSharesIssued; + private final BigDecimal unitPrice; + private final BigDecimal shareCapital; + private final Long minimumShares; + private final Long nominalShares; + private final Long maximumShares; + private final Collection<ShareProductMarketPriceData> marketPrice; + private final Collection<ChargeData> charges; + private final Boolean allowDividendCalculationForInactiveClients; + + private final Integer lockinPeriod; + private final EnumOptionData lockPeriodTypeEnum; + + private final Integer minimumActivePeriod; + private final EnumOptionData minimumActivePeriodForDividendsTypeEnum; + + // accounting + private final EnumOptionData accountingRule; + private final Map<String, Object> accountingMappings; + private final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings; + private final Collection<ChargeToGLAccountMapper> feeToGLAccountMappings; + + private final Collection<CurrencyData> currencyOptions; + private final Collection<ChargeData> chargeOptions; + final Collection<EnumOptionData> minimumActivePeriodFrequencyTypeOptions; + final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions; + private final Map<String, List<GLAccountData>> accountingMappingOptions; + + private ShareProductData(final Long id, final String name, final String shortName, final String description, final String externalId, + final CurrencyData currency, final Long totalShares, final Long totalSharesIssued, final BigDecimal unitPrice, + final BigDecimal shareCapital, final Long minimumShares, final Long nominaltShares, final Long maximumShares, + Collection<ShareProductMarketPriceData> marketPrice, final Collection<ChargeData> charges, + final Boolean allowDividendCalculationForInactiveClients, final Integer lockinPeriod, final EnumOptionData lockPeriodEnum, + final Integer minimumActivePeriod, final EnumOptionData minimumActivePeriodForDividendsTypeEnum, EnumOptionData accountingRule, + Map<String, Object> accountingMappings, Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings, + Collection<ChargeToGLAccountMapper> feeToGLAccountMappings, final Collection<CurrencyData> currencyOptions, + final Collection<ChargeData> chargeOptions, final Collection<EnumOptionData> minimumActivePeriodFrequencyTypeOptions, + final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, Map<String, List<GLAccountData>> accountingMappingOptions) { + this.id = id; + this.name = name; + this.shortName = shortName; + this.description = description; + this.externalId = externalId; + this.currency = currency; + this.totalShares = totalShares; + this.totalSharesIssued = totalSharesIssued; + this.unitPrice = unitPrice; + this.shareCapital = shareCapital; + this.minimumShares = minimumShares; + this.nominalShares = nominaltShares; + this.maximumShares = maximumShares; + this.marketPrice = marketPrice; + this.charges = charges; + this.allowDividendCalculationForInactiveClients = allowDividendCalculationForInactiveClients; + this.lockinPeriod = lockinPeriod; + this.lockPeriodTypeEnum = lockPeriodEnum; + this.minimumActivePeriod = minimumActivePeriod; + this.minimumActivePeriodForDividendsTypeEnum = minimumActivePeriodForDividendsTypeEnum; + this.accountingMappings = accountingMappings; + this.accountingRule = accountingRule; + this.paymentChannelToFundSourceMappings = paymentChannelToFundSourceMappings; + this.feeToGLAccountMappings = feeToGLAccountMappings; + this.currencyOptions = currencyOptions; + this.chargeOptions = chargeOptions; + this.minimumActivePeriodFrequencyTypeOptions = minimumActivePeriodFrequencyTypeOptions; + this.lockinPeriodFrequencyTypeOptions = lockinPeriodFrequencyTypeOptions; + this.accountingMappingOptions = accountingMappingOptions; + } + + public static ShareProductData data(final Long id, final String name, final String shortName, final String description, + final String externalId, final CurrencyData currency, final Long totalShares, final Long totalSharesIssued, + final BigDecimal unitPrice, final BigDecimal shareCapital, final Long minimumShares, final Long nominaltShares, + final Long maximumShares, Collection<ShareProductMarketPriceData> marketPrice, final Collection<ChargeData> charges, + + final Boolean allowDividendCalculationForInactiveClients, final Integer lockinPeriod, final EnumOptionData lockPeriodTypeEnum, + final Integer minimumActivePeriod, final EnumOptionData minimumActivePeriodForDividendsEnum, EnumOptionData accountingRule) { + + final Map<String, Object> accountingMappings = null; + final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings = null; + final Map<String, List<GLAccountData>> accountingMappingOptions = null; + final Collection<ChargeToGLAccountMapper> feeToGLAccountMappings = null; + + final Collection<CurrencyData> currencyOptions = null; + final Collection<ChargeData> chargeOptions = null; + final Collection<EnumOptionData> minimumActivePeriodFrequencyTypeOptions = null; + final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions = null; + return new ShareProductData(id, name, shortName, description, externalId, currency, totalShares, totalSharesIssued, unitPrice, + shareCapital, minimumShares, nominaltShares, maximumShares, marketPrice, charges, + allowDividendCalculationForInactiveClients, lockinPeriod, lockPeriodTypeEnum, minimumActivePeriod, + minimumActivePeriodForDividendsEnum, accountingRule, accountingMappings, paymentChannelToFundSourceMappings, + feeToGLAccountMappings, currencyOptions, chargeOptions, minimumActivePeriodFrequencyTypeOptions, + lockinPeriodFrequencyTypeOptions, accountingMappingOptions); + + } + + private ShareProductData(final Collection<CurrencyData> currencyOptions, final Collection<ChargeData> chargeOptions, + final Collection<EnumOptionData> minimumActivePeriodFrequencyTypeOptions, + final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, + final Map<String, List<GLAccountData>> accountingMappingOptions) { + this.id = null; + this.name = null; + this.shortName = null; + this.description = null; + this.externalId = null; + this.currency = null; + this.totalShares = null; + this.totalSharesIssued = null; + this.unitPrice = null; + this.shareCapital = null; + this.minimumShares = null; + this.nominalShares = null; + this.maximumShares = null; + this.marketPrice = null; + this.charges = null; + this.allowDividendCalculationForInactiveClients = null; + this.lockPeriodTypeEnum = null; + this.minimumActivePeriodForDividendsTypeEnum = null; + this.accountingRule = null; + this.accountingMappings = null; + this.paymentChannelToFundSourceMappings = null; + this.feeToGLAccountMappings = null; + this.currencyOptions = currencyOptions; + this.chargeOptions = chargeOptions; + this.minimumActivePeriodFrequencyTypeOptions = minimumActivePeriodFrequencyTypeOptions; + this.lockinPeriodFrequencyTypeOptions = lockinPeriodFrequencyTypeOptions; + this.lockinPeriod = null; + this.minimumActivePeriod = null; + this.accountingMappingOptions = accountingMappingOptions; + } + + public static ShareProductData template(final Collection<CurrencyData> currencyOptions, final Collection<ChargeData> chargeOptions, + final Collection<EnumOptionData> minimumActivePeriodFrequencyTypeOptions, + final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, Map<String, List<GLAccountData>> accountingMappingOptions) { + return new ShareProductData(currencyOptions, chargeOptions, minimumActivePeriodFrequencyTypeOptions, + lockinPeriodFrequencyTypeOptions, accountingMappingOptions); + } + + public static ShareProductData template(final ShareProductData data, final Collection<CurrencyData> currencyOptions, + final Collection<ChargeData> chargeOptions, final Collection<EnumOptionData> minimumActivePeriodFrequencyTypeOptions, + final Collection<EnumOptionData> lockinPeriodFrequencyTypeOptions, + final Map<String, List<GLAccountData>> accountingMappingOptions) { + + return new ShareProductData(data.id, data.name, data.shortName, data.description, data.externalId, data.currency, + data.totalShares, data.totalSharesIssued, data.unitPrice, data.shareCapital, data.minimumShares, data.nominalShares, + data.maximumShares, data.marketPrice, data.charges, data.allowDividendCalculationForInactiveClients, data.lockinPeriod, + data.lockPeriodTypeEnum, data.minimumActivePeriod, data.minimumActivePeriodForDividendsTypeEnum, data.accountingRule, + data.accountingMappings, data.paymentChannelToFundSourceMappings, data.feeToGLAccountMappings, currencyOptions, + chargeOptions, minimumActivePeriodFrequencyTypeOptions, lockinPeriodFrequencyTypeOptions, accountingMappingOptions); + } + + public static ShareProductData withAccountingDetails(final ShareProductData data, final Map<String, Object> accountingMappings, + final Collection<PaymentTypeToGLAccountMapper> paymentChannelToFundSourceMappings, + final Collection<ChargeToGLAccountMapper> feeToGLAccountMappings) { + return new ShareProductData(data.id, data.name, data.shortName, data.description, data.externalId, data.currency, + data.totalShares, data.totalSharesIssued, data.unitPrice, data.shareCapital, data.minimumShares, data.nominalShares, + data.maximumShares, data.marketPrice, data.charges, data.allowDividendCalculationForInactiveClients, data.lockinPeriod, + data.lockPeriodTypeEnum, data.minimumActivePeriod, data.minimumActivePeriodForDividendsTypeEnum, data.accountingRule, + accountingMappings, paymentChannelToFundSourceMappings, feeToGLAccountMappings, data.currencyOptions, data.chargeOptions, + data.minimumActivePeriodFrequencyTypeOptions, data.lockinPeriodFrequencyTypeOptions, data.accountingMappingOptions); + } + + private ShareProductData(final Long id, final String name, final String shortName, final Long totalShares) { + this.id = id; + this.name = name; + this.shortName = shortName; + this.description = null; + this.externalId = null; + this.currency = null; + this.totalShares = totalShares; + this.totalSharesIssued = null; + this.unitPrice = null; + this.shareCapital = null; + this.minimumShares = null; + this.nominalShares = null; + this.maximumShares = null; + this.marketPrice = null; + this.charges = null; + this.allowDividendCalculationForInactiveClients = null; + this.lockPeriodTypeEnum = null; + this.minimumActivePeriodForDividendsTypeEnum = null; + this.currencyOptions = null; + this.chargeOptions = null; + this.minimumActivePeriodFrequencyTypeOptions = null; + this.lockinPeriodFrequencyTypeOptions = null; + this.lockinPeriod = null; + this.minimumActivePeriod = null; + this.accountingRule = null; + this.accountingMappings = null; + this.paymentChannelToFundSourceMappings = null; + this.feeToGLAccountMappings = null; + this.accountingMappingOptions = null; + } + + public static ShareProductData generic(final Long id, final String name, final String shortName, final Long totalShares) { + return new ShareProductData(id, name, shortName, totalShares); + } + + public static ShareProductData lookup(final Long id, final String name) { + final String shortName = null; + final Long totalShares = null; + return new ShareProductData(id, name, shortName, totalShares); + + } + + public Long getId() { + return this.id; + } + + public String getName() { + return this.name; + } + + public String getShortName() { + return this.shortName; + } + + public String getDescription() { + return this.description; + } + + public String getExternalId() { + return this.externalId; + } + + public CurrencyData getCurrency() { + return this.currency; + } + + public Long getTotalShares() { + return this.totalShares; + } + + public Long getTotalSharesIssued() { + return this.totalSharesIssued; + } + + public BigDecimal getUnitPrice() { + return this.unitPrice; + } + + public BigDecimal getShareCapital() { + return this.shareCapital; + } + + public Long getMinimumShares() { + return this.minimumShares; + } + + public Long getNominaltShares() { + return this.nominalShares; + } + + public Long getMaximumShares() { + return this.maximumShares; + } + + public Collection<ShareProductMarketPriceData> getMarketPrice() { + return this.marketPrice; + } + + public Boolean getAllowDividendCalculationForInactiveClients() { + return this.allowDividendCalculationForInactiveClients; + } + + public EnumOptionData getLockPeriod() { + return this.lockPeriodTypeEnum; + } + + public EnumOptionData getMinimumActivePeriodForDividends() { + return this.minimumActivePeriodForDividendsTypeEnum; + } + + public Collection<CurrencyData> getCurrencyOptions() { + return currencyOptions; + } + + public Collection<ChargeData> getChargeOptions() { + return chargeOptions; + } + + public Integer getMinimumActivePeriod() { + return this.minimumActivePeriod; + } + + public boolean hasAccountingEnabled() { + return this.accountingRule.getId() > AccountingRuleType.NONE.getValue(); + } + + public int accountingRuleTypeId() { + return this.accountingRule.getId().intValue(); + } + + public EnumOptionData getAccountingRule() { + return this.accountingRule; + } +} \ 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/shareproducts/data/ShareProductDividendPayOutData.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/data/ShareProductDividendPayOutData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/data/ShareProductDividendPayOutData.java new file mode 100644 index 0000000..bf2bdc5 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/data/ShareProductDividendPayOutData.java @@ -0,0 +1,56 @@ +/** + * 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.shareproducts.data; + +import java.math.BigDecimal; +import java.util.Collection; + +import org.apache.fineract.infrastructure.core.data.EnumOptionData; +import org.apache.fineract.portfolio.shareaccounts.data.ShareAccountDividendData; +import org.joda.time.LocalDate; + +public class ShareProductDividendPayOutData { + + @SuppressWarnings("unused") + private final Long id; + @SuppressWarnings("unused") + private final ShareProductData productData; + @SuppressWarnings("unused") + private final BigDecimal amount; + @SuppressWarnings("unused") + private final EnumOptionData status; + @SuppressWarnings("unused") + private final LocalDate dividendPeriodStartDate; + @SuppressWarnings("unused") + private final LocalDate dividendPeriodEndDate; + @SuppressWarnings("unused") + private final Collection<ShareAccountDividendData> accountDividendsData; + + public ShareProductDividendPayOutData(final Long id, final ShareProductData productData, final BigDecimal amount, + LocalDate dividendStartDate, final LocalDate dividendEndDate, final Collection<ShareAccountDividendData> accountDividendsData, + final EnumOptionData status) { + this.id = id; + this.productData = productData; + this.amount = amount; + this.dividendPeriodEndDate = dividendEndDate; + this.accountDividendsData = accountDividendsData; + this.dividendPeriodStartDate = dividendStartDate; + this.status = status; + } +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/data/ShareProductMarketPriceData.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/data/ShareProductMarketPriceData.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/data/ShareProductMarketPriceData.java new file mode 100644 index 0000000..97b3e1a --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/data/ShareProductMarketPriceData.java @@ -0,0 +1,49 @@ +/** + * 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.shareproducts.data; + +import java.math.BigDecimal; +import java.util.Date; + +public class ShareProductMarketPriceData { + + private final Long id ; + + private final Date fromDate; + + private final BigDecimal shareValue; + + public ShareProductMarketPriceData(final Long id, final Date fromDate, final BigDecimal shareValue) { + this.id = id ; + this.fromDate = fromDate ; + this.shareValue = shareValue ; + } + + public Long getId() { + return this.id ; + } + + public Date getStartDate() { + return this.fromDate; + } + + public BigDecimal getShareValue() { + return this.shareValue; + } +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProduct.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProduct.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProduct.java new file mode 100644 index 0000000..4fee7ef --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProduct.java @@ -0,0 +1,434 @@ +/** + * 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.shareproducts.domain; + +import java.math.BigDecimal; +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.FetchType; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.fineract.accounting.common.AccountingRuleType; +import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom; +import org.apache.fineract.infrastructure.core.service.DateUtils; +import org.apache.fineract.organisation.monetary.domain.MonetaryCurrency; +import org.apache.fineract.portfolio.charge.domain.Charge; +import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType; +import org.apache.fineract.portfolio.shareproducts.data.ShareProductMarketPriceData; +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_share_product") +public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> { + + @Column(name = "name", nullable = false, unique = true) + private String name; + + @Column(name = "short_name", nullable = false, unique = true) + private String shortName; + + @Column(name = "description") + private String description; + + @Column(name = "start_date") + @Temporal(TemporalType.DATE) + private Date startDate; + + @Column(name = "end_date") + @Temporal(TemporalType.DATE) + private Date endDate; + + @Column(name = "external_id", length = 100, nullable = true, unique = true) + private String externalId; + + @Embedded + private MonetaryCurrency currency; + + @Column(name = "total_shares", nullable = false) + private Long totalShares; + + @Column(name = "issued_shares", nullable = false) + private Long totalSharesIssued; + + @Column(name = "totalsubscribed_shares", nullable = false) + private Long totalSubscribedShares; + + @Column(name = "unit_price", nullable = false) + private BigDecimal unitPrice; + + @Column(name = "capital_amount", nullable = false) + private BigDecimal shareCapital; + + @Column(name = "minimum_client_shares") + private Long minimumShares; + + @Column(name = "nominal_client_shares", nullable = false) + private Long nominalShares; + + @Column(name = "maximum_client_shares") + private Long maximumShares; + + @LazyCollection(LazyCollectionOption.FALSE) + @OneToMany(cascade = CascadeType.ALL, mappedBy = "product", orphanRemoval = true) + Set<ShareProductMarketPrice> marketPrice; + + @ManyToMany(fetch = FetchType.EAGER) + @JoinTable(name = "m_share_product_charge", joinColumns = @JoinColumn(name = "product_id"), inverseJoinColumns = @JoinColumn(name = "charge_id")) + private Set<Charge> charges; + + @Column(name = "allow_dividends_inactive_clients") + private Boolean allowDividendCalculationForInactiveClients; + + @Column(name = "lockin_period_frequency") + private Integer lockinPeriod; + + @Enumerated(EnumType.ORDINAL) + @Column(name = "lockin_period_frequency_enum", nullable = true) + private PeriodFrequencyType lockPeriodType; + + @Column(name = "minimum_active_period_frequency") + private Integer minimumActivePeriod; + + @Enumerated(EnumType.ORDINAL) + @Column(name = "minimum_active_period_frequency_enum", nullable = true) + private PeriodFrequencyType minimumActivePeriodType; + + @Column(name = "accounting_type", nullable = false) + protected Integer accountingRule; + + protected ShareProduct() { + + } + + public ShareProduct(final String name, final String shortName, final String description, final String externalId, + final MonetaryCurrency currency, final Long totalShares, final Long totalSharesIssued, final BigDecimal unitPrice, + final BigDecimal shareCapital, final Long minimumShares, final Long nominalShares, final Long maximumShares, + Set<ShareProductMarketPrice> marketPrice, Set<Charge> charges, final Boolean allowDividendCalculationForInactiveClients, + final Integer lockinPeriod, final PeriodFrequencyType lockPeriodType, final Integer minimumActivePeriod, + final PeriodFrequencyType minimumActivePeriodForDividendsType, AppUser createdBy, DateTime createdDate, AppUser lastModifiedBy, + DateTime lastModifiedDate, final AccountingRuleType accountingRuleType) { + + this.name = name; + this.shortName = shortName; + this.description = description; + this.externalId = externalId; + this.currency = currency; + this.totalShares = totalShares; + this.totalSharesIssued = totalSharesIssued; + this.unitPrice = unitPrice; + this.shareCapital = shareCapital; + this.minimumShares = minimumShares; + this.nominalShares = nominalShares; + this.maximumShares = maximumShares; + this.marketPrice = marketPrice; + this.charges = charges; + this.allowDividendCalculationForInactiveClients = allowDividendCalculationForInactiveClients; + this.lockinPeriod = lockinPeriod; + this.lockPeriodType = lockPeriodType; + this.minimumActivePeriod = minimumActivePeriod; + this.minimumActivePeriodType = minimumActivePeriodForDividendsType; + setCreatedBy(createdBy); + setCreatedDate(createdDate); + setLastModifiedBy(lastModifiedBy); + setLastModifiedDate(lastModifiedDate); + startDate = DateUtils.getDateOfTenant(); + endDate = DateUtils.getDateOfTenant(); + if (accountingRuleType != null) { + this.accountingRule = accountingRuleType.getValue(); + } + } + + public boolean setProductName(String productName) { + boolean returnValue = false; + if (!this.name.equals(productName)) { + this.name = productName; + returnValue = true; + } + return returnValue; + } + + public String getProductName() { + return this.name; + } + + public boolean setShortName(String shortName) { + boolean returnValue = false; + if (!this.shortName.equals(shortName)) { + this.shortName = shortName; + returnValue = true; + } + return returnValue; + } + + public boolean setDescription(String description) { + boolean returnValue = false; + if (!this.description.equals(description)) { + this.description = description; + returnValue = true; + } + return returnValue; + } + + public boolean setExternalId(String externalId) { + boolean returnValue = false; + if (!this.externalId.equals(externalId)) { + this.externalId = externalId; + returnValue = true; + } + return returnValue; + } + + public boolean setTotalShares(Long totalShares) { + boolean returnValue = false; + if (!this.totalShares.equals(totalShares)) { + this.totalShares = totalShares; + returnValue = true; + } + return returnValue; + + } + + public Long getTotalShares() { + return this.totalShares; + } + + public boolean setTotalIssuedShares(Long totalSharesIssued) { + boolean returnValue = false; + if (!this.totalSharesIssued.equals(totalSharesIssued)) { + this.totalSharesIssued = totalSharesIssued; + returnValue = true; + } + return returnValue; + } + + public boolean setMonetaryCurrency(MonetaryCurrency currency) { + boolean returnValue = false; + if (!this.currency.equals(currency)) { + this.currency = currency; + returnValue = true; + } + return returnValue; + } + + public MonetaryCurrency getCurrency() { + return this.currency; + } + + public boolean setUnitPrice(BigDecimal unitPrice) { + boolean returnValue = false; + if (!this.unitPrice.equals(unitPrice)) { + this.unitPrice = unitPrice; + returnValue = true; + } + return returnValue; + } + + public boolean setMinimumShares(final Long minimumShares) { + boolean returnValue = false; + if (!this.minimumShares.equals(minimumShares)) { + this.minimumShares = minimumShares; + returnValue = true; + } + return returnValue; + } + + public boolean setNominalShares(final Long nominalShares) { + boolean returnValue = false; + if (!this.nominalShares.equals(nominalShares)) { + this.nominalShares = nominalShares; + returnValue = true; + } + return returnValue; + } + + public boolean setMaximumShares(final Long maximumShares) { + boolean returnValue = false; + if (!this.maximumShares.equals(maximumShares)) { + this.maximumShares = maximumShares; + returnValue = true; + } + return returnValue; + } + + public boolean setMarketPrice(Set<ShareProductMarketPriceData> marketPrice) { + boolean update = false; + for (ShareProductMarketPriceData data : marketPrice) { + if (data.getId() == null) { + ShareProductMarketPrice entity = new ShareProductMarketPrice(data.getStartDate(), data.getShareValue()); + entity.setShareProduct(this); + this.marketPrice.add(entity); + update = true; + } else { + for (ShareProductMarketPrice priceData : this.marketPrice) { + if (priceData.getId() == data.getId()) { + priceData.setStartDate(data.getStartDate()); + priceData.setShareValue(data.getShareValue()); + update = true; + } + } + } + } + return update; + } + + public boolean setCharges(Set<Charge> charges) { + this.charges.clear(); + this.charges.addAll(charges); + return true; + } + + public boolean setAllowDividendCalculationForInactiveClients(Boolean allowDividendCalculationForInactiveClients) { + boolean returnValue = false; + if (!this.allowDividendCalculationForInactiveClients.equals(allowDividendCalculationForInactiveClients)) { + this.allowDividendCalculationForInactiveClients = allowDividendCalculationForInactiveClients; + returnValue = true; + } + return returnValue; + } + + public boolean setLockinPeriod(final Integer lockinPeriod) { + boolean returnValue = false; + if (this.lockinPeriod == null) { + this.lockinPeriod = lockinPeriod; + returnValue = true; + } else if (!this.lockinPeriod.equals(lockinPeriod)) { + this.lockinPeriod = lockinPeriod; + returnValue = true; + } + return returnValue; + } + + public boolean setLockPeriodFrequencyType(final PeriodFrequencyType lockPeriod) { + boolean returnValue = false; + if (!this.lockPeriodType.equals(lockPeriod)) { + this.lockPeriodType = lockPeriod; + returnValue = true; + } + return returnValue; + } + + public boolean setminimumActivePeriod(final Integer minimumActivePeriod) { + boolean returnValue = false; + if (this.minimumActivePeriod == null) { + this.minimumActivePeriod = minimumActivePeriod; + returnValue = true; + } else if (!this.minimumActivePeriod.equals(minimumActivePeriod)) { + this.minimumActivePeriod = minimumActivePeriod; + returnValue = true; + } + return returnValue; + } + + public boolean setminimumActivePeriodFrequencyType(final PeriodFrequencyType minimumActivePeriodForDividends) { + boolean returnValue = false; + if (!this.minimumActivePeriodType.equals(minimumActivePeriodForDividends)) { + this.minimumActivePeriodType = minimumActivePeriodForDividends; + returnValue = true; + } + return returnValue; + } + + public String getShortName() { + return this.shortName; + } + + public boolean setshareCapitalValue(BigDecimal shareCapitalValue) { + boolean updated = false; + if (this.shareCapital == null) { + this.shareCapital = shareCapitalValue; + updated = true; + } else if (!this.shareCapital.equals(shareCapitalValue)) { + this.shareCapital = shareCapitalValue; + updated = true; + } + return updated; + } + + public boolean setAccountingRule(final Integer accountingRule) { + boolean returnValue = false; + if (!this.accountingRule.equals(accountingRule)) { + this.accountingRule = accountingRule; + returnValue = true; + } + return returnValue; + } + + public Long getSharesIssued() { + return this.totalSharesIssued; + } + + public BigDecimal getUnitPrice() { + return this.unitPrice; + } + + public Integer getAccountingType() { + return this.accountingRule; + } + + public boolean isSharesAllowed(Long requestedShares) { + boolean allowed = true; + if (minimumShares != null && maximumShares != null) { + if (requestedShares < minimumShares || requestedShares > maximumShares) { + allowed = false; + } + } + return allowed; + } + + public BigDecimal deriveMarketPrice(final Date currentDate) { + BigDecimal marketValue = this.unitPrice; + if (this.marketPrice != null && !this.marketPrice.isEmpty()) { + for (ShareProductMarketPrice data : this.marketPrice) { + Date futureDate = data.getStartDate(); + if (currentDate.after(futureDate)) { + marketValue = data.getPrice(); + } + } + } + return marketValue; + } + + public void addSubscribedShares(final Long subscribedShares) { + if(this.totalSubscribedShares == null) { + this.totalSubscribedShares = new Long(0) ; + } + this.totalSubscribedShares += subscribedShares ; + } + + public Long getSubscribedShares() { + return this.totalSubscribedShares ; + } + +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividendPayOutDetails.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividendPayOutDetails.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividendPayOutDetails.java new file mode 100644 index 0000000..d282899 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividendPayOutDetails.java @@ -0,0 +1,101 @@ +/** + * 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.shareproducts.domain; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.JoinColumn; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.fineract.infrastructure.core.domain.AbstractAuditableCustom; +import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccountDividendDetails; +import org.apache.fineract.useradministration.domain.AppUser; +import org.hibernate.annotations.LazyCollection; +import org.hibernate.annotations.LazyCollectionOption; +import org.joda.time.LocalDate; + +@Entity +@Table(name = "m_share_product_dividend_pay_out") +public class ShareProductDividendPayOutDetails extends AbstractAuditableCustom<AppUser, Long> { + + @Column(name = "product_id", nullable = true) + private Long shareProductId; + + @Column(name = "amount", scale = 6, precision = 19) + private BigDecimal amount; + + @Column(name = "dividend_period_start_date") + @Temporal(TemporalType.DATE) + private Date dividendPeriodStartDate; + + @Column(name = "dividend_period_end_date") + @Temporal(TemporalType.DATE) + private Date dividendPeriodEndDate; + + @Column(name = "status", nullable = false) + private Integer status; + + @LazyCollection(LazyCollectionOption.TRUE) + @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true) + @JoinColumn(name = "dividend_pay_out_id", referencedColumnName = "id", nullable = false) + private List<ShareAccountDividendDetails> accountDividendDetails = new ArrayList<>(); + + protected ShareProductDividendPayOutDetails() { + + } + + public ShareProductDividendPayOutDetails(final Long shareProductId, final BigDecimal amount, final Date dividendPeriodStartDate, + final Date dividendPeriodEndDate) { + this.shareProductId = shareProductId; + this.amount = amount; + this.dividendPeriodStartDate = dividendPeriodStartDate; + this.dividendPeriodEndDate = dividendPeriodEndDate; + this.status = ShareProductDividendStatusType.INITIATED.getValue(); + } + + public LocalDate getDividendPeriodEndDateAsLocalDate() { + LocalDate dividendPeriodEndDate = null; + if (this.dividendPeriodEndDate != null) { + dividendPeriodEndDate = new LocalDate(this.dividendPeriodEndDate); + } + return dividendPeriodEndDate; + } + + public List<ShareAccountDividendDetails> getAccountDividendDetails() { + return this.accountDividendDetails; + } + + public void approveDividendPayout() { + this.status = ShareProductDividendStatusType.APPROVED.getValue(); + } + + public ShareProductDividendStatusType getStatus() { + return ShareProductDividendStatusType.fromInt(this.status); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividendStatusType.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividendStatusType.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividendStatusType.java new file mode 100644 index 0000000..da65e5c --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividendStatusType.java @@ -0,0 +1,62 @@ +/** + * 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.shareproducts.domain; + + +public enum ShareProductDividendStatusType { + + INVALID(0, "shareAccountDividendStatusType.invalid"), INITIATED(100, "shareAccountDividendStatusType.initiated"), APPROVED(300, + "shareAccountDividendStatusType.approved"); + + private final Integer value; + private final String code; + + private ShareProductDividendStatusType(final Integer value, final String code) { + this.value = value; + this.code = code; + } + + public static ShareProductDividendStatusType fromInt(final Integer type) { + + ShareProductDividendStatusType enumeration = ShareProductDividendStatusType.INVALID; + switch (type) { + case 100: + enumeration = ShareProductDividendStatusType.INITIATED; + break; + case 300: + enumeration = ShareProductDividendStatusType.APPROVED; + break; + + } + return enumeration; + } + + public Integer getValue() { + return this.value; + } + + public String getCode() { + return this.code; + } + + public boolean isApproved() { + return this.value.equals(ShareProductDividendStatusType.APPROVED.getValue()); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividentPayOutDetailsRepository.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividentPayOutDetailsRepository.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividentPayOutDetailsRepository.java new file mode 100644 index 0000000..be74493 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividentPayOutDetailsRepository.java @@ -0,0 +1,27 @@ +/** + * 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.shareproducts.domain; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +public interface ShareProductDividentPayOutDetailsRepository extends JpaRepository<ShareProductDividendPayOutDetails, Long>, + JpaSpecificationExecutor<ShareProductDividendPayOutDetails> { + +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividentPayOutDetailsRepositoryWrapper.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividentPayOutDetailsRepositoryWrapper.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividentPayOutDetailsRepositoryWrapper.java new file mode 100644 index 0000000..8a14a21 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductDividentPayOutDetailsRepositoryWrapper.java @@ -0,0 +1,51 @@ +/** + * 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.shareproducts.domain; + +import org.apache.fineract.portfolio.shareproducts.exception.DividendNotFoundException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class ShareProductDividentPayOutDetailsRepositoryWrapper { + + private final ShareProductDividentPayOutDetailsRepository shareProductDividentPayOutDetailsRepository; + + @Autowired + public ShareProductDividentPayOutDetailsRepositoryWrapper( + final ShareProductDividentPayOutDetailsRepository shareProductDividentPayOutDetailsRepository) { + this.shareProductDividentPayOutDetailsRepository = shareProductDividentPayOutDetailsRepository; + } + + public ShareProductDividendPayOutDetails findOneWithNotFoundDetection(final Long dividendId) { + ShareProductDividendPayOutDetails shareProductDividendPayOutDetails = this.shareProductDividentPayOutDetailsRepository + .findOne(dividendId); + if (shareProductDividendPayOutDetails == null) { throw new DividendNotFoundException(dividendId, "share"); } + return shareProductDividendPayOutDetails; + } + + public void save(final ShareProductDividendPayOutDetails shareProductDividendPayOutDetails) { + this.shareProductDividentPayOutDetailsRepository.save(shareProductDividendPayOutDetails); + } + + public void delete(final ShareProductDividendPayOutDetails shareProductDividendPayOutDetails) { + this.shareProductDividentPayOutDetailsRepository.delete(shareProductDividendPayOutDetails); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductMarketPrice.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductMarketPrice.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductMarketPrice.java new file mode 100644 index 0000000..6042149 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductMarketPrice.java @@ -0,0 +1,77 @@ +/** + * 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.shareproducts.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.springframework.data.jpa.domain.AbstractPersistable; + +@Entity +@Table(name = "m_share_product_market_price") +public class ShareProductMarketPrice extends AbstractPersistable<Long> { + + @ManyToOne(optional = false) + @JoinColumn(name = "product_id", referencedColumnName = "id", nullable = false) + private ShareProduct product; + + @Column(name = "from_date") + @Temporal(TemporalType.DATE) + private Date fromDate; + + @Column(name = "share_value", nullable = false) + private BigDecimal shareValue ; + + public ShareProductMarketPrice() { + + } + + public ShareProductMarketPrice(final Date fromDate, final BigDecimal shareValue) { + this.fromDate = fromDate ; + this.shareValue = shareValue ; + } + + public void setShareProduct(final ShareProduct product) { + this.product = product ; + } + + public Date getStartDate() { + return this.fromDate ; + } + + public BigDecimal getPrice() { + return this.shareValue ; + } + + public void setStartDate(Date date) { + this.fromDate = date ; + } + + public void setShareValue(BigDecimal value) { + this.shareValue = value ; + } +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductRepository.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductRepository.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductRepository.java new file mode 100644 index 0000000..5222151 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductRepository.java @@ -0,0 +1,27 @@ +/** + * 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.shareproducts.domain; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + + +public interface ShareProductRepository extends JpaRepository<ShareProduct, Long>, JpaSpecificationExecutor<ShareProduct> { + +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductRepositoryWrapper.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductRepositoryWrapper.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductRepositoryWrapper.java new file mode 100644 index 0000000..1a448a8 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/domain/ShareProductRepositoryWrapper.java @@ -0,0 +1,50 @@ +/** + * 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.shareproducts.domain; + +import org.apache.fineract.portfolio.products.exception.ProductNotFoundException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class ShareProductRepositoryWrapper { + + private final ShareProductRepository shareProductRepository ; + + @Autowired + public ShareProductRepositoryWrapper(final ShareProductRepository shareProductRepository) { + this.shareProductRepository = shareProductRepository ; + } + + public ShareProduct findOneWithNotFoundDetection(final Long productId) { + ShareProduct product = this.shareProductRepository.findOne(productId) ; + if(product == null) { + throw new ProductNotFoundException(productId, "share") ; + } + return product ; + } + + public void save(ShareProduct product) { + this.shareProductRepository.save(product) ; + } + + public void saveAndFlush(ShareProduct product) { + this.shareProductRepository.saveAndFlush(product) ; + } +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/exception/DividendNotFoundException.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/exception/DividendNotFoundException.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/exception/DividendNotFoundException.java new file mode 100644 index 0000000..ca37806 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/exception/DividendNotFoundException.java @@ -0,0 +1,28 @@ +/** + * 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.shareproducts.exception; + +import org.apache.fineract.infrastructure.core.exception.AbstractPlatformResourceNotFoundException; + +public class DividendNotFoundException extends AbstractPlatformResourceNotFoundException { + + public DividendNotFoundException(final Long id, String type) { + super("error.msg.dividend.id.invalid", type + " dividend with identifier " + id + " does not exist", id); + } +} \ 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/shareproducts/exception/DividentProcessingException.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/exception/DividentProcessingException.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/exception/DividentProcessingException.java new file mode 100644 index 0000000..8ff11ac --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/exception/DividentProcessingException.java @@ -0,0 +1,29 @@ +/** + * 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.shareproducts.exception; + +import org.apache.fineract.infrastructure.core.exception.AbstractPlatformDomainRuleException; + +public class DividentProcessingException extends AbstractPlatformDomainRuleException { + + public DividentProcessingException(final String msgcode, final String defaultUserMessage) { + super("error.msg.divident.processing." + msgcode, defaultUserMessage); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/ApproveShareProductDividendCommandHandler.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/ApproveShareProductDividendCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/ApproveShareProductDividendCommandHandler.java new file mode 100644 index 0000000..4867670 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/ApproveShareProductDividendCommandHandler.java @@ -0,0 +1,47 @@ +/** + * 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.shareproducts.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.shareproducts.service.ShareProductWritePlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@CommandType(entity = "SHAREPRODUCT", action = "APPROVE_DIVIDEND") +public class ApproveShareProductDividendCommandHandler implements NewCommandSourceHandler { + + private final ShareProductWritePlatformService shareProductWritePlatformService; + + @Autowired + public ApproveShareProductDividendCommandHandler(final ShareProductWritePlatformService shareProductWritePlatformService) { + this.shareProductWritePlatformService = shareProductWritePlatformService; + } + + @Transactional + @Override + public CommandProcessingResult processCommand(JsonCommand jsonCommand) { + return this.shareProductWritePlatformService.approveShareProductDividend(jsonCommand.entityId()); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/CreateShareProductCommandHandler.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/CreateShareProductCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/CreateShareProductCommandHandler.java new file mode 100644 index 0000000..7b495c1 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/CreateShareProductCommandHandler.java @@ -0,0 +1,47 @@ +/** + * 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.shareproducts.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.shareproducts.service.ShareProductWritePlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@CommandType(entity = "SHAREPRODUCT", action = "CREATE") +public class CreateShareProductCommandHandler implements NewCommandSourceHandler { + + private final ShareProductWritePlatformService shareProductWritePlatformService ; + + @Autowired + public CreateShareProductCommandHandler(final ShareProductWritePlatformService shareProductWritePlatformService) { + this.shareProductWritePlatformService = shareProductWritePlatformService ; + } + + @Transactional + @Override + public CommandProcessingResult processCommand(JsonCommand jsonCommand) { + return this.shareProductWritePlatformService.createShareProduct(jsonCommand); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/CreateShareProductDividendCommandHandler.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/CreateShareProductDividendCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/CreateShareProductDividendCommandHandler.java new file mode 100644 index 0000000..7f2aa1b --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/CreateShareProductDividendCommandHandler.java @@ -0,0 +1,47 @@ +/** + * 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.shareproducts.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.shareproducts.service.ShareProductWritePlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@CommandType(entity = "SHAREPRODUCT", action = "CREATE_DIVIDEND") +public class CreateShareProductDividendCommandHandler implements NewCommandSourceHandler { + + private final ShareProductWritePlatformService shareProductWritePlatformService; + + @Autowired + public CreateShareProductDividendCommandHandler(final ShareProductWritePlatformService shareProductWritePlatformService) { + this.shareProductWritePlatformService = shareProductWritePlatformService; + } + + @Transactional + @Override + public CommandProcessingResult processCommand(JsonCommand jsonCommand) { + return this.shareProductWritePlatformService.createShareProductDividend(jsonCommand.entityId(), jsonCommand); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/DeleteShareProductDividendCommandHandler.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/DeleteShareProductDividendCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/DeleteShareProductDividendCommandHandler.java new file mode 100644 index 0000000..e9f5b24 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/DeleteShareProductDividendCommandHandler.java @@ -0,0 +1,47 @@ +/** + * 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.shareproducts.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.shareproducts.service.ShareProductWritePlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@CommandType(entity = "SHAREPRODUCT", action = "DELETE_DIVIDEND") +public class DeleteShareProductDividendCommandHandler implements NewCommandSourceHandler { + + private final ShareProductWritePlatformService shareProductWritePlatformService; + + @Autowired + public DeleteShareProductDividendCommandHandler(final ShareProductWritePlatformService shareProductWritePlatformService) { + this.shareProductWritePlatformService = shareProductWritePlatformService; + } + + @Transactional + @Override + public CommandProcessingResult processCommand(JsonCommand jsonCommand) { + return this.shareProductWritePlatformService.deleteShareProductDividend(jsonCommand.entityId()); + } + +} http://git-wip-us.apache.org/repos/asf/incubator-fineract/blob/08c553f9/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/UpdateShareProductCommandHandler.java ---------------------------------------------------------------------- diff --git a/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/UpdateShareProductCommandHandler.java b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/UpdateShareProductCommandHandler.java new file mode 100644 index 0000000..f4b5710 --- /dev/null +++ b/fineract-provider/src/main/java/org/apache/fineract/portfolio/shareproducts/handler/UpdateShareProductCommandHandler.java @@ -0,0 +1,47 @@ +/** + * 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.shareproducts.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.shareproducts.service.ShareProductWritePlatformService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@CommandType(entity = "SHAREPRODUCT", action = "UPDATE") +public class UpdateShareProductCommandHandler implements NewCommandSourceHandler { + + private final ShareProductWritePlatformService shareProductWritePlatformService ; + + @Autowired + public UpdateShareProductCommandHandler(final ShareProductWritePlatformService shareProductWritePlatformService) { + this.shareProductWritePlatformService = shareProductWritePlatformService ; + } + + @Transactional + @Override + public CommandProcessingResult processCommand(JsonCommand jsonCommand) { + return this.shareProductWritePlatformService.updateProduct(jsonCommand.entityId(), jsonCommand); + } + +}
