Skip to content

Commit

Permalink
Merge pull request apache#503 from ShruthiRajaram/FINERACT-680
Browse files Browse the repository at this point in the history
FINERACT-680 market price update issue in share product
  • Loading branch information
ShruthiRajaram authored Dec 31, 2018
2 parents 80261d0 + 73f1e71 commit bff995f
Showing 1 changed file with 22 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
Expand Down Expand Up @@ -48,6 +49,7 @@
import org.apache.fineract.useradministration.domain.AppUser;
import org.joda.time.DateTime;

@SuppressWarnings("serial")
@Entity
@Table(name = "m_share_product")
public class ShareProduct extends AbstractAuditableCustom<AppUser, Long> {
Expand Down Expand Up @@ -282,23 +284,26 @@ public boolean setMaximumShares(final Long maximumShares) {
}

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;
}
}
}
}
boolean update = true;
Set<ShareProductMarketPrice> marketPriceTemp = new HashSet<ShareProductMarketPrice>();
if (marketPrice != null && marketPrice.size() > 0) {
for (ShareProductMarketPriceData data : marketPrice) {
if (data.getId() == null) {
ShareProductMarketPrice entity = new ShareProductMarketPrice(data.getStartDate(), data.getShareValue());
entity.setShareProduct(this);
marketPriceTemp.add(entity);
} else {
for (ShareProductMarketPrice priceData : this.marketPrice) {
if (priceData.getId().equals(data.getId())) {
priceData.setStartDate(data.getStartDate());
priceData.setShareValue(data.getShareValue());
marketPriceTemp.add(priceData);
}
}
}
}
}
this.marketPrice = marketPriceTemp;
return update;
}

Expand Down

0 comments on commit bff995f

Please sign in to comment.