Merge branch 'pullrequest97' into develop

This commit is contained in:
Nazeer Hussain Shaik
2016-05-04 17:25:06 +05:30
6 changed files with 76 additions and 52 deletions
@@ -58,4 +58,6 @@ public interface SavingsAccountReadPlatformService {
List<Long> retrieveSavingsIdsPendingDormant(LocalDate tenantLocalDate); List<Long> retrieveSavingsIdsPendingDormant(LocalDate tenantLocalDate);
List<Long> retrieveSavingsIdsPendingEscheat(LocalDate tenantLocalDate); List<Long> retrieveSavingsIdsPendingEscheat(LocalDate tenantLocalDate);
boolean isAccountBelongsToClient(final Long clientId, final Long accountId, final DepositAccountType depositAccountType, final String currencyCode) ;
} }
@@ -24,7 +24,6 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Date;
import java.util.List; import java.util.List;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@@ -40,7 +39,6 @@ import org.apache.fineract.organisation.monetary.data.CurrencyData;
import org.apache.fineract.organisation.staff.data.StaffData; import org.apache.fineract.organisation.staff.data.StaffData;
import org.apache.fineract.organisation.staff.service.StaffReadPlatformService; import org.apache.fineract.organisation.staff.service.StaffReadPlatformService;
import org.apache.fineract.portfolio.account.data.AccountTransferData; import org.apache.fineract.portfolio.account.data.AccountTransferData;
import org.apache.fineract.portfolio.calendar.service.CalendarUtils;
import org.apache.fineract.portfolio.charge.data.ChargeData; import org.apache.fineract.portfolio.charge.data.ChargeData;
import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService; import org.apache.fineract.portfolio.charge.service.ChargeReadPlatformService;
import org.apache.fineract.portfolio.client.data.ClientData; import org.apache.fineract.portfolio.client.data.ClientData;
@@ -1156,6 +1154,18 @@ public class SavingsAccountReadPlatformServiceImpl implements SavingsAccountRead
return ret; return ret;
} }
@Override
public boolean isAccountBelongsToClient(final Long clientId, final Long accountId, final DepositAccountType depositAccountType,
final String currencyCode) {
try {
final StringBuffer buff = new StringBuffer("select count(*) from m_savings_account sa ") ;
buff.append(" where sa.id = ? and sa.client_id = ? and sa.deposit_type_enum = ? and sa.currency_code = ? and sa.status_enum = 300");
return this.jdbcTemplate.queryForObject(buff.toString(),
new Object[] { accountId, clientId, depositAccountType.getValue(), currencyCode }, Integer.class) > 0;
} catch (final EmptyResultDataAccessException e) {
throw new SavingsAccountNotFoundException(accountId);
}
}
/* /*
* private static final class SavingsAccountAnnualFeeMapper implements * private static final class SavingsAccountAnnualFeeMapper implements
* RowMapper<SavingsAccountAnnualFeeData> { * RowMapper<SavingsAccountAnnualFeeData> {
@@ -238,7 +238,7 @@ public class ShareAccount extends AbstractPersistable<Long> {
public boolean setExternalId(final String externalId) { public boolean setExternalId(final String externalId) {
boolean toReturn = false; boolean toReturn = false;
if (!this.externalId.equals(externalId)) { if (this.externalId == null || !this.externalId.equals(externalId)) {
this.externalId = externalId; this.externalId = externalId;
toReturn = true; toReturn = true;
} }
@@ -272,10 +272,7 @@ public class ShareAccount extends AbstractPersistable<Long> {
public boolean setAllowDividendCalculationForInactiveClients(Boolean allowDividendCalculationForInactiveClients) { public boolean setAllowDividendCalculationForInactiveClients(Boolean allowDividendCalculationForInactiveClients) {
boolean returnValue = false; boolean returnValue = false;
if (this.allowDividendCalculationForInactiveClients == null) { if (this.allowDividendCalculationForInactiveClients == null || !this.allowDividendCalculationForInactiveClients.equals(allowDividendCalculationForInactiveClients)) {
this.allowDividendCalculationForInactiveClients = allowDividendCalculationForInactiveClients;
returnValue = true;
} else if (!this.allowDividendCalculationForInactiveClients.equals(allowDividendCalculationForInactiveClients)) {
this.allowDividendCalculationForInactiveClients = allowDividendCalculationForInactiveClients; this.allowDividendCalculationForInactiveClients = allowDividendCalculationForInactiveClients;
returnValue = true; returnValue = true;
} }
@@ -293,7 +290,7 @@ public class ShareAccount extends AbstractPersistable<Long> {
public boolean setLockPeriodFrequencyEnum(final PeriodFrequencyType lockinPeriodFrequencyType) { public boolean setLockPeriodFrequencyEnum(final PeriodFrequencyType lockinPeriodFrequencyType) {
boolean returnValue = false; boolean returnValue = false;
if (!this.lockinPeriodFrequencyType.getValue().equals(lockinPeriodFrequencyType.getValue())) { if (this.lockinPeriodFrequencyType == null || !this.lockinPeriodFrequencyType.getValue().equals(lockinPeriodFrequencyType.getValue())) {
this.lockinPeriodFrequencyType = lockinPeriodFrequencyType; this.lockinPeriodFrequencyType = lockinPeriodFrequencyType;
returnValue = true; returnValue = true;
} }
@@ -311,7 +308,7 @@ public class ShareAccount extends AbstractPersistable<Long> {
public boolean setminimumActivePeriodTypeEnum(final PeriodFrequencyType minimumActivePeriodForDividends) { public boolean setminimumActivePeriodTypeEnum(final PeriodFrequencyType minimumActivePeriodForDividends) {
boolean returnValue = false; boolean returnValue = false;
if (!this.minimumActivePeriodFrequencyType.getValue().equals(minimumActivePeriodForDividends.getValue())) { if (this.minimumActivePeriodFrequencyType == null || !this.minimumActivePeriodFrequencyType.getValue().equals(minimumActivePeriodForDividends.getValue())) {
this.minimumActivePeriodFrequencyType = minimumActivePeriodForDividends; this.minimumActivePeriodFrequencyType = minimumActivePeriodForDividends;
returnValue = true; returnValue = true;
} }
@@ -243,5 +243,7 @@ public class ShareAccountTransaction extends AbstractPersistable<Long> {
return this.active ; return this.active ;
} }
public BigDecimal shareValue() {
return this.shareValue ;
}
} }
@@ -49,8 +49,11 @@ import org.apache.fineract.portfolio.client.domain.Client;
import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper; import org.apache.fineract.portfolio.client.domain.ClientRepositoryWrapper;
import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType; import org.apache.fineract.portfolio.common.domain.PeriodFrequencyType;
import org.apache.fineract.portfolio.loanproduct.exception.InvalidCurrencyException; import org.apache.fineract.portfolio.loanproduct.exception.InvalidCurrencyException;
import org.apache.fineract.portfolio.savings.DepositAccountType;
import org.apache.fineract.portfolio.savings.domain.SavingsAccount; import org.apache.fineract.portfolio.savings.domain.SavingsAccount;
import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepositoryWrapper; import org.apache.fineract.portfolio.savings.domain.SavingsAccountRepositoryWrapper;
import org.apache.fineract.portfolio.savings.exception.SavingsAccountNotFoundException;
import org.apache.fineract.portfolio.savings.service.SavingsAccountReadPlatformService;
import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccount; import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccount;
import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccountCharge; import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccountCharge;
import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccountChargePaidBy; import org.apache.fineract.portfolio.shareaccounts.domain.ShareAccountChargePaidBy;
@@ -84,16 +87,20 @@ public class ShareAccountDataSerializer {
private final ShareProductRepositoryWrapper shareProductRepository; private final ShareProductRepositoryWrapper shareProductRepository;
private final SavingsAccountReadPlatformService savingsAccountReadPlatformService ;
@Autowired @Autowired
public ShareAccountDataSerializer(final PlatformSecurityContext platformSecurityContext, final FromJsonHelper fromApiJsonHelper, public ShareAccountDataSerializer(final PlatformSecurityContext platformSecurityContext, final FromJsonHelper fromApiJsonHelper,
final ChargeRepositoryWrapper chargeRepository, final SavingsAccountRepositoryWrapper savingsAccountRepositoryWrapper, final ChargeRepositoryWrapper chargeRepository, final SavingsAccountRepositoryWrapper savingsAccountRepositoryWrapper,
final ClientRepositoryWrapper clientRepositoryWrapper, final ShareProductRepositoryWrapper shareProductRepository) { final ClientRepositoryWrapper clientRepositoryWrapper, final ShareProductRepositoryWrapper shareProductRepository,
final SavingsAccountReadPlatformService savingsAccountReadPlatformService) {
this.platformSecurityContext = platformSecurityContext; this.platformSecurityContext = platformSecurityContext;
this.fromApiJsonHelper = fromApiJsonHelper; this.fromApiJsonHelper = fromApiJsonHelper;
this.chargeRepository = chargeRepository; this.chargeRepository = chargeRepository;
this.savingsAccountRepositoryWrapper = savingsAccountRepositoryWrapper; this.savingsAccountRepositoryWrapper = savingsAccountRepositoryWrapper;
this.clientRepositoryWrapper = clientRepositoryWrapper; this.clientRepositoryWrapper = clientRepositoryWrapper;
this.shareProductRepository = shareProductRepository; this.shareProductRepository = shareProductRepository;
this.savingsAccountReadPlatformService = savingsAccountReadPlatformService ;
} }
public ShareAccount validateAndCreate(JsonCommand jsonCommand) { public ShareAccount validateAndCreate(JsonCommand jsonCommand) {
@@ -120,16 +127,16 @@ public class ShareAccountDataSerializer {
Long savingsAccountId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.savingsaccountid_paramname, element); Long savingsAccountId = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.savingsaccountid_paramname, element);
baseDataValidator.reset().parameter(ShareAccountApiConstants.savingsaccountid_paramname).value(savingsAccountId).notNull() baseDataValidator.reset().parameter(ShareAccountApiConstants.savingsaccountid_paramname).value(savingsAccountId).notNull()
.longGreaterThanZero(); .longGreaterThanZero();
final Long requestedShares = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.requestedshares_paramname, element); final Long requestedShares = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.requestedshares_paramname, element);
baseDataValidator.reset().parameter(ShareAccountApiConstants.requestedshares_paramname).value(requestedShares).notNull() baseDataValidator.reset().parameter(ShareAccountApiConstants.requestedshares_paramname).value(requestedShares).notNull()
.longGreaterThanZero(); .longGreaterThanZero();
if(requestedShares < shareProduct.getMinimumClientShares()) {
if(shareProduct.getMinimumClientShares() != null && requestedShares < shareProduct.getMinimumClientShares()) {
baseDataValidator.reset().parameter(ShareAccountApiConstants.requestedshares_paramname).value(requestedShares) baseDataValidator.reset().parameter(ShareAccountApiConstants.requestedshares_paramname).value(requestedShares)
.failWithCode("client.can.not.purchase.shares.lessthan.product.definition", "Client can not purchase shares less than product definition"); .failWithCode("client.can.not.purchase.shares.lessthan.product.definition", "Client can not purchase shares less than product definition");
} }
if(requestedShares > shareProduct.getMaximumClientShares()) { if(shareProduct.getMaximumClientShares() != null && requestedShares > shareProduct.getMaximumClientShares()) {
baseDataValidator.reset().parameter(ShareAccountApiConstants.requestedshares_paramname).value(requestedShares) baseDataValidator.reset().parameter(ShareAccountApiConstants.requestedshares_paramname).value(requestedShares)
.failWithCode("client.can.not.purchase.shares.morethan.product.definition", "Client can not purchase shares more than product definition"); .failWithCode("client.can.not.purchase.shares.morethan.product.definition", "Client can not purchase shares more than product definition");
} }
@@ -156,7 +163,10 @@ public class ShareAccountDataSerializer {
if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); } if (!dataValidationErrors.isEmpty()) { throw new PlatformApiDataValidationException(dataValidationErrors); }
Client client = this.clientRepositoryWrapper.findOneWithNotFoundDetection(clientId); Client client = this.clientRepositoryWrapper.findOneWithNotFoundDetection(clientId);
SavingsAccount savingsAccount = this.savingsAccountRepositoryWrapper.findOneWithNotFoundDetection(savingsAccountId); if(!this.savingsAccountReadPlatformService.isAccountBelongsToClient(clientId, savingsAccountId, DepositAccountType.SAVINGS_DEPOSIT, shareProduct.getCurrency().getCode())) {
throw new SavingsAccountNotFoundException(savingsAccountId) ;
}
SavingsAccount savingsAccount = this.savingsAccountRepositoryWrapper.findOneWithNotFoundDetection(savingsAccountId, DepositAccountType.SAVINGS_DEPOSIT);
final MonetaryCurrency currency = shareProduct.getCurrency(); final MonetaryCurrency currency = shareProduct.getCurrency();
Set<ShareAccountCharge> charges = assembleListOfAccountCharges(element, currency.getCode()); Set<ShareAccountCharge> charges = assembleListOfAccountCharges(element, currency.getCode());
@@ -266,6 +276,9 @@ public class ShareAccountDataSerializer {
baseDataValidator.reset().parameter(ShareAccountApiConstants.savingsaccountid_paramname).value(savingsAccountId).notNull() baseDataValidator.reset().parameter(ShareAccountApiConstants.savingsaccountid_paramname).value(savingsAccountId).notNull()
.longGreaterThanZero(); .longGreaterThanZero();
if(savingsAccountId != null) { if(savingsAccountId != null) {
if(!this.savingsAccountReadPlatformService.isAccountBelongsToClient(account.getClientId(), savingsAccountId, DepositAccountType.SAVINGS_DEPOSIT, shareProduct.getCurrency().getCode())) {
throw new SavingsAccountNotFoundException(savingsAccountId) ;
}
SavingsAccount savingsAccount = this.savingsAccountRepositoryWrapper.findOneWithNotFoundDetection(savingsAccountId); SavingsAccount savingsAccount = this.savingsAccountRepositoryWrapper.findOneWithNotFoundDetection(savingsAccountId);
if (account.setSavingsAccount(savingsAccount)) { if (account.setSavingsAccount(savingsAccount)) {
actualChanges.put(ShareAccountApiConstants.savingsaccountid_paramname, savingsAccount.getId()); actualChanges.put(ShareAccountApiConstants.savingsaccountid_paramname, savingsAccount.getId());
@@ -273,43 +286,55 @@ public class ShareAccountDataSerializer {
} }
} }
Date existingApplicationDate = null ;
if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.requestedshares_paramname, element) if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.requestedshares_paramname, element)
|| this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.charges_paramname, element)) { || this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.charges_paramname, element)) {
Set<ShareAccountTransaction> transactions = account.getShareAccountTransactions(); Set<ShareAccountTransaction> transactions = account.getShareAccountTransactions();
List<Long> reveralIds = new ArrayList<>(); List<Long> reveralIds = new ArrayList<>();
for (ShareAccountTransaction transaction : transactions) { for (ShareAccountTransaction transaction : transactions) {
transaction.setActive(false);
if(!transaction.isChargeTransaction()) {
existingApplicationDate = transaction.getPurchasedDate() ;
}
reveralIds.add(transaction.getId()); reveralIds.add(transaction.getId());
} }
actualChanges.put("reversalIds", reveralIds); actualChanges.put("reversalIds", reveralIds);
account.removeTransactions(); Set<ShareAccountCharge> charges = account.getCharges() ;
account.removeCharges(); for(ShareAccountCharge charge: charges) {
charge.setActive(false);
}
} }
if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.requestedshares_paramname, element)) { if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.requestedshares_paramname, element)) {
Long requestedShares = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.requestedshares_paramname, element); Long requestedShares = this.fromApiJsonHelper.extractLongNamed(ShareAccountApiConstants.requestedshares_paramname, element);
/* Date applicationDate = null ;
* BigDecimal unitPrice = if(this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.applicationdate_param, element)) {
* this.fromApiJsonHelper.extractBigDecimalNamed applicationDate = this.fromApiJsonHelper.extractLocalDateNamed(ShareAccountApiConstants.applicationdate_param, element)
* (ShareAccountApiConstants.purchasedprice_paramname, element, .toDate();
* locale); }else {
*/ applicationDate = existingApplicationDate ;
Date applicationDate = this.fromApiJsonHelper.extractLocalDateNamed(ShareAccountApiConstants.applicationdate_param, element) }
.toDate();
BigDecimal unitPrice = shareProduct.deriveMarketPrice(applicationDate); BigDecimal unitPrice = shareProduct.deriveMarketPrice(applicationDate);
ShareAccountTransaction transaction = new ShareAccountTransaction(applicationDate, requestedShares, unitPrice); ShareAccountTransaction transaction = new ShareAccountTransaction(applicationDate, requestedShares, unitPrice);
account.addTransaction(transaction); account.addTransaction(transaction);
actualChanges.put(ShareAccountApiConstants.requestedshares_paramname, "Transaction"); actualChanges.put(ShareAccountApiConstants.requestedshares_paramname, "Transaction");
if(requestedShares < shareProduct.getMinimumClientShares()) { if(shareProduct.getMinimumClientShares() != null && requestedShares < shareProduct.getMinimumClientShares()) {
baseDataValidator.reset().parameter(ShareAccountApiConstants.requestedshares_paramname).value(requestedShares) baseDataValidator.reset().parameter(ShareAccountApiConstants.requestedshares_paramname).value(requestedShares)
.failWithCode("client.can.not.purchase.shares.lessthan.product.definition", "Client can not purchase shares less than product definition"); .failWithCode("client.can.not.purchase.shares.lessthan.product.definition", "Client can not purchase shares less than product definition");
} }
if(requestedShares > shareProduct.getMaximumClientShares()) { if(shareProduct.getMaximumClientShares() != null && requestedShares > shareProduct.getMaximumClientShares()) {
baseDataValidator.reset().parameter(ShareAccountApiConstants.requestedshares_paramname).value(requestedShares) baseDataValidator.reset().parameter(ShareAccountApiConstants.requestedshares_paramname).value(requestedShares)
.failWithCode("client.can.not.purchase.shares.morethan.product.definition", "Client can not purchase shares more than product definition"); .failWithCode("client.can.not.purchase.shares.morethan.product.definition", "Client can not purchase shares more than product definition");
} }
} }/*else if(this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.charges_paramname, element)) {
//Since we are removing all purchase transactions when either charge param or requestedShares param exists
for(ShareAccountTransaction transaction:existingTransactions) {
account.addTransaction(transaction);
}
}*/
if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.allowdividendcalculationforinactiveclients_paramname, element)) { if (this.fromApiJsonHelper.parameterExists(ShareAccountApiConstants.allowdividendcalculationforinactiveclients_paramname, element)) {
Boolean allowdividendsForInactiveClients = this.fromApiJsonHelper.extractBooleanNamed( Boolean allowdividendsForInactiveClients = this.fromApiJsonHelper.extractBooleanNamed(
@@ -196,7 +196,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public boolean setDescription(String description) { public boolean setDescription(String description) {
boolean returnValue = false; boolean returnValue = false;
if (!this.description.equals(description)) { if (this.description == null || !this.description.equals(description)) {
this.description = description; this.description = description;
returnValue = true; returnValue = true;
} }
@@ -205,7 +205,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public boolean setExternalId(String externalId) { public boolean setExternalId(String externalId) {
boolean returnValue = false; boolean returnValue = false;
if (!this.externalId.equals(externalId)) { if (this.externalId == null || !this.externalId.equals(externalId)) {
this.externalId = externalId; this.externalId = externalId;
returnValue = true; returnValue = true;
} }
@@ -228,10 +228,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public boolean setTotalIssuedShares(Long totalSharesIssued) { public boolean setTotalIssuedShares(Long totalSharesIssued) {
boolean returnValue = false; boolean returnValue = false;
if(this.totalSharesIssued == null) { if (this.totalSharesIssued == null || !this.totalSharesIssued.equals(totalSharesIssued)) {
this.totalSharesIssued = totalSharesIssued ;
returnValue = true ;
}else if (!this.totalSharesIssued.equals(totalSharesIssued)) {
this.totalSharesIssued = totalSharesIssued; this.totalSharesIssued = totalSharesIssued;
returnValue = true; returnValue = true;
} }
@@ -262,7 +259,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public boolean setMinimumShares(final Long minimumShares) { public boolean setMinimumShares(final Long minimumShares) {
boolean returnValue = false; boolean returnValue = false;
if (!this.minimumShares.equals(minimumShares)) { if (this.minimumShares == null || !this.minimumShares.equals(minimumShares)) {
this.minimumShares = minimumShares; this.minimumShares = minimumShares;
returnValue = true; returnValue = true;
} }
@@ -280,7 +277,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public boolean setMaximumShares(final Long maximumShares) { public boolean setMaximumShares(final Long maximumShares) {
boolean returnValue = false; boolean returnValue = false;
if (!this.maximumShares.equals(maximumShares)) { if (this.maximumShares == null || !this.maximumShares.equals(maximumShares)) {
this.maximumShares = maximumShares; this.maximumShares = maximumShares;
returnValue = true; returnValue = true;
} }
@@ -316,7 +313,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public boolean setAllowDividendCalculationForInactiveClients(Boolean allowDividendCalculationForInactiveClients) { public boolean setAllowDividendCalculationForInactiveClients(Boolean allowDividendCalculationForInactiveClients) {
boolean returnValue = false; boolean returnValue = false;
if (!this.allowDividendCalculationForInactiveClients.equals(allowDividendCalculationForInactiveClients)) { if (this.allowDividendCalculationForInactiveClients == null || !this.allowDividendCalculationForInactiveClients.equals(allowDividendCalculationForInactiveClients)) {
this.allowDividendCalculationForInactiveClients = allowDividendCalculationForInactiveClients; this.allowDividendCalculationForInactiveClients = allowDividendCalculationForInactiveClients;
returnValue = true; returnValue = true;
} }
@@ -325,10 +322,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public boolean setLockinPeriod(final Integer lockinPeriod) { public boolean setLockinPeriod(final Integer lockinPeriod) {
boolean returnValue = false; boolean returnValue = false;
if (this.lockinPeriod == null) { if (this.lockinPeriod == null || !this.lockinPeriod.equals(lockinPeriod)) {
this.lockinPeriod = lockinPeriod;
returnValue = true;
} else if (!this.lockinPeriod.equals(lockinPeriod)) {
this.lockinPeriod = lockinPeriod; this.lockinPeriod = lockinPeriod;
returnValue = true; returnValue = true;
} }
@@ -337,7 +331,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public boolean setLockPeriodFrequencyType(final PeriodFrequencyType lockPeriod) { public boolean setLockPeriodFrequencyType(final PeriodFrequencyType lockPeriod) {
boolean returnValue = false; boolean returnValue = false;
if (!this.lockPeriodType.equals(lockPeriod)) { if (this.lockPeriodType == null || !this.lockPeriodType.equals(lockPeriod)) {
this.lockPeriodType = lockPeriod; this.lockPeriodType = lockPeriod;
returnValue = true; returnValue = true;
} }
@@ -346,10 +340,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public boolean setminimumActivePeriod(final Integer minimumActivePeriod) { public boolean setminimumActivePeriod(final Integer minimumActivePeriod) {
boolean returnValue = false; boolean returnValue = false;
if (this.minimumActivePeriod == null) { if (this.minimumActivePeriod == null || !this.minimumActivePeriod.equals(minimumActivePeriod)) {
this.minimumActivePeriod = minimumActivePeriod;
returnValue = true;
} else if (!this.minimumActivePeriod.equals(minimumActivePeriod)) {
this.minimumActivePeriod = minimumActivePeriod; this.minimumActivePeriod = minimumActivePeriod;
returnValue = true; returnValue = true;
} }
@@ -358,7 +349,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public boolean setminimumActivePeriodFrequencyType(final PeriodFrequencyType minimumActivePeriodForDividends) { public boolean setminimumActivePeriodFrequencyType(final PeriodFrequencyType minimumActivePeriodForDividends) {
boolean returnValue = false; boolean returnValue = false;
if (!this.minimumActivePeriodType.equals(minimumActivePeriodForDividends)) { if (this.minimumActivePeriodType == null || !this.minimumActivePeriodType.equals(minimumActivePeriodForDividends)) {
this.minimumActivePeriodType = minimumActivePeriodForDividends; this.minimumActivePeriodType = minimumActivePeriodForDividends;
returnValue = true; returnValue = true;
} }
@@ -371,10 +362,7 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public boolean setshareCapitalValue(BigDecimal shareCapitalValue) { public boolean setshareCapitalValue(BigDecimal shareCapitalValue) {
boolean updated = false; boolean updated = false;
if (this.shareCapital == null) { if (this.shareCapital == null || !this.shareCapital.equals(shareCapitalValue)) {
this.shareCapital = shareCapitalValue;
updated = true;
} else if (!this.shareCapital.equals(shareCapitalValue)) {
this.shareCapital = shareCapitalValue; this.shareCapital = shareCapitalValue;
updated = true; updated = true;
} }
@@ -451,4 +439,4 @@ public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
public Long getDefaultClientShares() { public Long getDefaultClientShares() {
return this.nominalShares ; return this.nominalShares ;
} }
} }